Skip to content

Commit

Permalink
LostArtefacts#314 - Enemy Meshes
Browse files Browse the repository at this point in the history
Slight improvement to the logic for swapping enemy meshes. Also adds the potential for abominable Laras (as enemies, not as playable character).
  • Loading branch information
lahm86 committed Mar 26, 2022
1 parent d288abd commit 4f2903f
Showing 1 changed file with 36 additions and 14 deletions.
50 changes: 36 additions & 14 deletions TRRandomizerCore/Randomizers/TR2/TR2EnemyRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<TRModel> 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<TR2Entities> laraClones = new List<TR2Entities>();
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<TRModel> 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<TR2Entities> cloneCollection, int chance)
{
if (enemies.Available.Contains(enemyType) && _generator.Next(0, chance) == 0)
{
cloneCollection.Add(enemyType);
}
}

Expand Down

0 comments on commit 4f2903f

Please sign in to comment.