From 3747445dfba9959aac436479e4b1229394608517 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Tue, 9 Jul 2024 07:59:58 +0100 Subject: [PATCH] Handle TR2R docile bird monsters (#724) Resolves #723. --- CHANGELOG.md | 1 + TRLevelControl/Model/TR2/Enums/TR2RAlias.cs | 1 + .../Randomizers/TR2/Classic/TR2EnemyRandomizer.cs | 2 +- .../TR2/Remastered/TR2REnemyRandomizer.cs | 14 ++++++++++++++ .../Randomizers/TR2/Shared/TR2EnemyAllocator.cs | 8 ++++---- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1264ef87..93fe50e0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## [Unreleased](https://github.com/LostArtefacts/TR-Rando/compare/V1.9.1...master) - xxxx-xx-xx +- fixed docile bird monsters causing multiple Laras to spawn in remastered levels (#723) - improved data integrity checks when opening a folder and prior to randomization (#719) ## [V1.9.1](https://github.com/LostArtefacts/TR-Rando/compare/V1.9.0...V1.9.1) - 2024-06-23 diff --git a/TRLevelControl/Model/TR2/Enums/TR2RAlias.cs b/TRLevelControl/Model/TR2/Enums/TR2RAlias.cs index f66ef726..5a694163 100644 --- a/TRLevelControl/Model/TR2/Enums/TR2RAlias.cs +++ b/TRLevelControl/Model/TR2/Enums/TR2RAlias.cs @@ -11,6 +11,7 @@ public enum TR2RAlias BARACUDDA_EMPRTOMB, BARACUDDA_ICECAVE_CATACOMB, BIG_SPIDER_3, + BIG_YETI, BIG_YETI_4_5, BLADE_EMPRTOMB, BLADE_FLOATING_VENICE, diff --git a/TRRandomizerCore/Randomizers/TR2/Classic/TR2EnemyRandomizer.cs b/TRRandomizerCore/Randomizers/TR2/Classic/TR2EnemyRandomizer.cs index fea3e189..870626e8 100644 --- a/TRRandomizerCore/Randomizers/TR2/Classic/TR2EnemyRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR2/Classic/TR2EnemyRandomizer.cs @@ -434,7 +434,7 @@ internal void ApplyRandomization() if (_outer.Settings.DocileChickens && importedCollection.BirdMonsterGuiser != TR2Type.BirdMonster) { - TR2EnemyAllocator.DisguiseType(level.Name, level.Data, importedCollection.BirdMonsterGuiser, TR2Type.BirdMonster); + TR2EnemyAllocator.DisguiseType(level.Name, level.Data.Models, importedCollection.BirdMonsterGuiser, TR2Type.BirdMonster); enemies.BirdMonsterGuiser = importedCollection.BirdMonsterGuiser; } diff --git a/TRRandomizerCore/Randomizers/TR2/Remastered/TR2REnemyRandomizer.cs b/TRRandomizerCore/Randomizers/TR2/Remastered/TR2REnemyRandomizer.cs index 25b4716e..df887758 100644 --- a/TRRandomizerCore/Randomizers/TR2/Remastered/TR2REnemyRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR2/Remastered/TR2REnemyRandomizer.cs @@ -254,6 +254,12 @@ void AddItem(TR2Type type, int count) internal class EnemyProcessor : AbstractProcessorThread { + private static readonly List _birdMonsterTypes = new() + { + TR2RAlias.BIG_YETI, + TR2RAlias.BIG_YETI_4_5, + }; + private readonly Dictionary> _enemyMapping; internal override int LevelCount => _enemyMapping.Count; @@ -331,6 +337,14 @@ internal void ApplyRandomization() All = new(importedCollection.TypesToImport) }; + if (_outer.Settings.DocileChickens && importedCollection.BirdMonsterGuiser != TR2Type.BirdMonster) + { + TR2EnemyAllocator.DisguiseType(level.Name, level.Data.Models, importedCollection.BirdMonsterGuiser, TR2Type.BirdMonster); + TR2EnemyAllocator.DisguiseType(level.Name, level.PDPData, importedCollection.BirdMonsterGuiser, TR2Type.BirdMonster); + level.MapData[importedCollection.BirdMonsterGuiser] = _birdMonsterTypes.RandomItem(_outer._generator); + enemies.BirdMonsterGuiser = importedCollection.BirdMonsterGuiser; + } + _outer.RandomizeEnemies(level, enemies); if (_outer.Settings.DevelopmentMode) { diff --git a/TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs b/TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs index b11e682b..79cb52aa 100644 --- a/TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs +++ b/TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs @@ -313,7 +313,7 @@ public EnemyRandomizationCollection RandomizeEnemiesNatively(string lev if (Settings.DocileChickens && levelName == TR2LevelNames.CHICKEN) { - DisguiseType(levelName, level, TR2Type.MaskedGoon1, TR2Type.BirdMonster); + DisguiseType(levelName, level.Models, TR2Type.MaskedGoon1, TR2Type.BirdMonster); } EnemyRandomizationCollection enemies = new() @@ -330,17 +330,17 @@ public EnemyRandomizationCollection RandomizeEnemiesNatively(string lev return enemies; } - public static void DisguiseType(string levelName, TR2Level level, TR2Type guiser, TR2Type targetType) + public static void DisguiseType(string levelName, TRDictionary modelData, TR2Type guiser, TR2Type targetType) { if (targetType == TR2Type.BirdMonster && levelName == TR2LevelNames.CHICKEN) { // We have to keep the original model for the boss, so in // this instance we just clone the model for the guiser - level.Models[guiser] = level.Models[targetType].Clone(); + modelData[guiser] = modelData[targetType].Clone(); } else { - level.Models.ChangeKey(targetType, guiser); + modelData.ChangeKey(targetType, guiser); } }