Skip to content

Commit

Permalink
Handle TR2R docile bird monsters (LostArtefacts#724)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 authored Jul 9, 2024
1 parent 5361dad commit 3747445
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions TRLevelControl/Model/TR2/Enums/TR2RAlias.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
14 changes: 14 additions & 0 deletions TRRandomizerCore/Randomizers/TR2/Remastered/TR2REnemyRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,12 @@ void AddItem(TR2Type type, int count)

internal class EnemyProcessor : AbstractProcessorThread<TR2REnemyRandomizer>
{
private static readonly List<TR2RAlias> _birdMonsterTypes = new()
{
TR2RAlias.BIG_YETI,
TR2RAlias.BIG_YETI_4_5,
};

private readonly Dictionary<TR2RCombinedLevel, EnemyTransportCollection<TR2Type>> _enemyMapping;

internal override int LevelCount => _enemyMapping.Count;
Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 4 additions & 4 deletions TRRandomizerCore/Randomizers/TR2/Shared/TR2EnemyAllocator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ public EnemyRandomizationCollection<TR2Type> 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<TR2Type> enemies = new()
Expand All @@ -330,17 +330,17 @@ public EnemyRandomizationCollection<TR2Type> RandomizeEnemiesNatively(string lev
return enemies;
}

public static void DisguiseType(string levelName, TR2Level level, TR2Type guiser, TR2Type targetType)
public static void DisguiseType(string levelName, TRDictionary<TR2Type, TRModel> 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);
}
}

Expand Down

0 comments on commit 3747445

Please sign in to comment.