From 4f2903f1f983b1a05a06085fd4f71abd7e09ad76 Mon Sep 17 00:00:00 2001 From: lahm86 <33758420+lahm86@users.noreply.github.com> Date: Sat, 26 Mar 2022 14:55:09 +0000 Subject: [PATCH] #314 - Enemy Meshes Slight improvement to the logic for swapping enemy meshes. Also adds the potential for abominable Laras (as enemies, not as playable character). --- .../Randomizers/TR2/TR2EnemyRandomizer.cs | 50 +++++++++++++------ 1 file changed, 36 insertions(+), 14 deletions(-) diff --git a/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs b/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs index 6dae78038..c1b17b5ec 100644 --- a/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs +++ b/TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs @@ -680,20 +680,42 @@ private void RandomizeEnemies(TR2CombinedLevel level, EnemyRandomizationCollecti private void RandomizeEnemyMeshes(TR2CombinedLevel level, EnemyRandomizationCollection enemies) { - // #314 A very primitive start to mixing-up enemy meshes - if we have both monk types, and we're - // not using docile chickens, make one set of monks become Lara. - if (Settings.CrossLevelEnemies - && !Settings.DocileBirdMonsters - && enemies.Available.Contains(TR2Entities.MonkWithKnifeStick) - && enemies.Available.Contains(TR2Entities.MonkWithLongStick)) - { - TR2Entities monkType = _generator.Next(0, 2) == 0 ? TR2Entities.MonkWithKnifeStick : TR2Entities.MonkWithLongStick; - List models = level.Data.Models.ToList(); - TRModel laraModel = models.Find(m => m.ID == (uint)TR2Entities.Lara); - TRModel monkModel = models.Find(m => m.ID == (uint)monkType); - monkModel.MeshTree = laraModel.MeshTree; - monkModel.StartingMesh = laraModel.StartingMesh; - monkModel.NumMeshes = laraModel.NumMeshes; + // #314 A very primitive start to mixing-up enemy meshes - monks and yetis can take on Lara's meshes + // without manipulation, so add a random chance of this happening if any of these models are in place. + if (!Settings.CrossLevelEnemies) + { + return; + } + + List laraClones = new List(); + const int chance = 2; + if (!Settings.DocileBirdMonsters) + { + AddRandomLaraClone(enemies, TR2Entities.MonkWithKnifeStick, laraClones, chance); + AddRandomLaraClone(enemies, TR2Entities.MonkWithLongStick, laraClones, chance); + } + + AddRandomLaraClone(enemies, TR2Entities.Yeti, laraClones, chance); + + if (laraClones.Count > 0) + { + List levelModels = level.Data.Models.ToList(); + TRModel laraModel = levelModels.Find(m => m.ID == (uint)TR2Entities.Lara); + foreach (TR2Entities enemyType in laraClones) + { + TRModel enemyModel = levelModels.Find(m => m.ID == (uint)enemyType); + enemyModel.MeshTree = laraModel.MeshTree; + enemyModel.StartingMesh = laraModel.StartingMesh; + enemyModel.NumMeshes = laraModel.NumMeshes; + } + } + } + + private void AddRandomLaraClone(EnemyRandomizationCollection enemies, TR2Entities enemyType, List cloneCollection, int chance) + { + if (enemies.Available.Contains(enemyType) && _generator.Next(0, chance) == 0) + { + cloneCollection.Add(enemyType); } }