Skip to content

Commit

Permalink
Make Tihocan Pierre index constant
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 committed Nov 17, 2023
1 parent fde37e1 commit 6fa41dc
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions TRRandomizerCore/Randomizers/TR1/TR1EnemyRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -704,10 +704,10 @@ private void RandomizeEnemies(TR1CombinedLevel level, EnemyRandomizationCollecti

if (level.Is(TR1LevelNames.TIHOCAN) && (!Settings.RandomizeItems || !Settings.IncludeKeyItems))
{
if (TR1EnemyUtilities.CanDropItems(level.Data.Entities[82], level, floorData))
if (TR1EnemyUtilities.CanDropItems(level.Data.Entities[TR1ItemRandomizer.TihocanPierreIndex], level, floorData))
{
// Whichever enemy has taken Pierre's place will drop the items.
level.Script.AddItemDrops(82, TR1ItemRandomizer.TihocanEndItems
level.Script.AddItemDrops(TR1ItemRandomizer.TihocanPierreIndex, TR1ItemRandomizer.TihocanEndItems
.Select(e => ItemUtilities.ConvertToScriptItem(e.TypeID)));
}
else
Expand Down
6 changes: 4 additions & 2 deletions TRRandomizerCore/Randomizers/TR1/TR1ItemRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ namespace TRRandomizerCore.Randomizers;

public class TR1ItemRandomizer : BaseTR1Randomizer
{
public const int TihocanPierreIndex = 82;

public static readonly List<TR1Entity> TihocanEndItems = new()
{
new()
Expand Down Expand Up @@ -401,9 +403,9 @@ private void RandomizeKeyItems(TR1CombinedLevel level)
{
// Enemy rando may not be selected or Pierre may have ended up at the
// end as usual. Remove his key and scion drops and place them as items.
if (level.Data.Entities[82].TypeID == TR1Type.Pierre)
if (level.Data.Entities[TihocanPierreIndex].TypeID == TR1Type.Pierre)
{
level.Script.ItemDrops.Find(d => d.EnemyNum == 82)?.ObjectIds
level.Script.ItemDrops.Find(d => d.EnemyNum == TihocanPierreIndex)?.ObjectIds
.RemoveAll(e => TihocanEndItems.Select(i => ItemUtilities.ConvertToScriptItem(i.TypeID)).Contains(e));
}
level.Data.Entities.AddRange(TihocanEndItems);
Expand Down

0 comments on commit 6fa41dc

Please sign in to comment.