Skip to content

Commit ba9b942

Browse files
committed
Add extra pickups option to TR2X
Resolves LostArtefacts#832.
1 parent 8860d40 commit ba9b942

5 files changed

Lines changed: 36 additions & 1 deletion

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
- added support for TR1X 4.14 (now the minimum version supported) (#803)
33
- added support TR2X (#821)
44
- added Spanish translations for TR1 (#800)
5+
- added an option to include extra pickups in certain levels in TR2X (#832)
56
- added pickup items to Lara's Home for item randomization in TR2X (#832)
67
- fixed a crash at the end of Diving Area in TR2R (#814)
78
- fixed a potential key softlock in City of Khamoon if "large" range is selected and either return paths are disabled in classic, or playing remastered (#820)

TRRandomizerCore/Editors/TR2RemasteredEditor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ protected override void ApplyConfig(Config config)
1919
Settings.AllowReturnPathLocations = false;
2020
Settings.AddReturnPaths = false;
2121
Settings.FixOGBugs = false;
22+
Settings.IncludeExtraPickups = false;
2223
Settings.ReplaceRequiredEnemies = false;
2324
Settings.SwapEnemyAppearance = false;
2425
}

TRRandomizerCore/Randomizers/TR2/Shared/TR2ItemAllocator.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ namespace TRRandomizerCore.Randomizers;
88

99
public class TR2ItemAllocator : ItemAllocator<TR2Type, TR2Entity>
1010
{
11+
private static readonly Dictionary<string, int> _extraItemCounts = new()
12+
{
13+
[TR2LevelNames.GW]
14+
= 13, // Default = 5
15+
[TR2LevelNames.VENICE]
16+
= 4, // Default = 20
17+
[TR2LevelNames.BARTOLI]
18+
= 4, // Default = 20
19+
[TR2LevelNames.RIG]
20+
= 2, // Default = 22
21+
[TR2LevelNames.FATHOMS]
22+
= 13, // Default = 7
23+
[TR2LevelNames.LQ]
24+
= 10, // Default = 8
25+
};
26+
1127
public short DefaultItemShade { get; set; }
1228

1329
public TR2ItemAllocator()
@@ -45,6 +61,7 @@ public void RandomizeItems(string levelName, TR2Level level, AbstractTRScriptedL
4561
}
4662

4763
InitialisePicker(levelName, level, Settings.ItemMode == ItemMode.Default ? LocationMode.Default : LocationMode.ExistingItems);
64+
AddExtraPickups(levelName, level.Entities);
4865

4966
if (Settings.ItemMode == ItemMode.Default)
5067
{
@@ -131,4 +148,19 @@ private List<Location> GetItemLocationPool(string levelName, TR2Level level, boo
131148
TR2LocationGenerator generator = new();
132149
return generator.Generate(level, exclusions, keyItemMode);
133150
}
151+
152+
private void AddExtraPickups(string levelName, List<TR2Entity> allItems)
153+
{
154+
if (!Settings.IncludeExtraPickups || !_extraItemCounts.TryGetValue(levelName, out var count))
155+
{
156+
return;
157+
}
158+
159+
var types = TR2TypeUtilities.GetAmmoTypes();
160+
for (int i = 0; i < count; i++)
161+
{
162+
var item = ItemFactory.CreateItem(levelName, allItems, _picker.GetRandomLocation());
163+
item.TypeID = types.RandomItem(Generator);
164+
}
165+
}
134166
}

TRRandomizerCore/TRVersionSupport.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ internal class TRVersionSupport
9999
TRRandomizerType.DynamicTextures,
100100
TRRandomizerType.Enemy,
101101
TRRandomizerType.Environment,
102+
TRRandomizerType.ExtraPickups,
102103
TRRandomizerType.GeneralBugFixes,
103104
TRRandomizerType.GlitchedSecrets,
104105
TRRandomizerType.HardSecrets,

TRRandomizerView/Model/ControllerOptions.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2708,7 +2708,7 @@ public ControllerOptions()
27082708
};
27092709
ItemBoolItemControls = new()
27102710
{
2711-
_randomizeItemTypes, _randomizeItemLocations, _includeKeyItems, _allowReturnPathLocations, _allowEnemyKeyDrops, _randomizeVehicles, _oneItemDifficulty, _maintainKeyContinuity, _includeExtraPickups
2711+
_randomizeItemTypes, _randomizeItemLocations, _includeKeyItems, _allowReturnPathLocations, _allowEnemyKeyDrops, _randomizeVehicles, _oneItemDifficulty, _includeExtraPickups, _maintainKeyContinuity
27122712
};
27132713
EnemyBoolItemControls = new()
27142714
{

0 commit comments

Comments
 (0)