Skip to content

Commit

Permalink
Fix secret and reward issues (LostArtefacts#598)
Browse files Browse the repository at this point in the history
  • Loading branch information
lahm86 authored Jan 15, 2024
1 parent 514129b commit 5b17ebc
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
## [Unreleased](https://github.com/LostArtefacts/TR-Rando/compare/V1.8.2...master) - xxxx-xx-xx
- fixed incorrect items sometimes being allocated as secret rewards in Thames Wharf (#597)
- fixed an inaccessible secret in Offshore Rig when the main area is drained (#597)

## [V1.8.2](https://github.com/LostArtefacts/TR-Rando/compare/V1.8.1...V1.8.2) - 2024-01-14
- fixed some pickups appearing in unreachable locations in TR2 (#591)
Expand Down
2 changes: 1 addition & 1 deletion TRRandomizerCore/Randomizers/TR3/TR3ItemRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public override void Randomize(int seed)
FindUnarmedLevelPistols(_levelInstance);

_picker.Initialise(_levelInstance.Name, GetItemLocationPool(_levelInstance, false), Settings, _generator);
_secretMapping = TR3SecretMapping.Get(GetResourcePath($@"TR3\SecretMapping\{_levelInstance.Name}-SecretMapping.json"), IsJPVersion);
_secretMapping = TR3SecretMapping.Get(_levelInstance);

// #312 If this is the assault course, import required models. On failure, don't perform any item rando.
if (_levelInstance.IsAssault && !ImportAssaultModels(_levelInstance))
Expand Down
2 changes: 1 addition & 1 deletion TRRandomizerCore/Randomizers/TR3/TR3SecretRandomizer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ private TRSecretRoom<TR2Entity> MakePlaceholderRewardRoom(TR3CombinedLevel level

private void ActualiseRewardRoom(TR3CombinedLevel level, TRSecretRoom<TR2Entity> placeholder)
{
TR3SecretMapping secretMapping = TR3SecretMapping.Get(GetResourcePath($@"TR3\SecretMapping\{level.Name}-SecretMapping.json"), IsJPVersion);
TR3SecretMapping secretMapping = TR3SecretMapping.Get(level);
if (secretMapping == null)
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ private void RandomizeRewards(TR3CombinedLevel level)
return;
}

TR3SecretMapping secretMapping = TR3SecretMapping.Get(GetResourcePath($@"TR3\SecretMapping\{level.Name}-SecretMapping.json"), IsJPVersion);
TR3SecretMapping secretMapping = TR3SecretMapping.Get(level);

List<TR3Type> stdItemTypes = TR3TypeUtilities.GetStandardPickupTypes();
// A bit cruel as rewards?
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1492,9 +1492,15 @@
"ConditionalOneOf": [
{
"Condition": {
"Comments": "If room 2 does not contain a secret, drain the plane area.",
"Comments": "If neither rooms 2 nor 96 contain a secret, drain the plane area.",
"ConditionType": 1,
"RoomIndex": 2
"RoomIndex": 2,
"Or": [
{
"ConditionType": 1,
"RoomIndex": 96
}
]
},
"OnFalse": {
"Leader": [
Expand Down
9 changes: 7 additions & 2 deletions TRRandomizerCore/Secrets/TR3SecretMapping.cs
Original file line number Diff line number Diff line change
@@ -1,20 +1,25 @@
using Newtonsoft.Json;
using TREnvironmentEditor;
using TRLevelControl.Helpers;
using TRLevelControl.Model;
using TRRandomizerCore.Levels;

namespace TRRandomizerCore.Secrets;

public class TR3SecretMapping : TRSecretMapping<TR3Entity>
{
public static TR3SecretMapping Get(string packPath, bool japaneseVersion)
public static TR3SecretMapping Get(TR3CombinedLevel level)
{
string packPath = $@"Resources\TR3\SecretMapping\{level.Name}-SecretMapping.json";
if (!File.Exists(packPath))
{
return null;
}

TR3SecretMapping mapping = JsonConvert.DeserializeObject<TR3SecretMapping>(File.ReadAllText(packPath), EMEditorMapping.Converter);
if (japaneseVersion && mapping.JPRewardEntities != null)
if (level.Is(TR3LevelNames.THAMES)
&& level.Data.Entities.Any(e => e.TypeID == TR3Type.TeethSpikesOrBarbedWire && e.Room == 8)
&& mapping.JPRewardEntities != null)
{
mapping.RewardEntities = mapping.JPRewardEntities;
}
Expand Down

0 comments on commit 5b17ebc

Please sign in to comment.