Skip to content

Commit

Permalink
Merge pull request #239 from lahm86/master
Browse files Browse the repository at this point in the history
TR3 Globe Display and Reward Cameras
  • Loading branch information
DanzaG authored Nov 11, 2021
2 parents 4a9293f + 53e8a3f commit a6ae200
Show file tree
Hide file tree
Showing 40 changed files with 976 additions and 41 deletions.
70 changes: 70 additions & 0 deletions TRLevelReader/Helpers/LevelNames/TR3LevelNames.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,5 +100,75 @@ public static List<string> AsListGold
};
}
}

public static List<string> IndiaLevels
{
get
{
return new List<string>
{
JUNGLE,
RUINS,
GANGES,
CAVES
};
}
}

public static List<string> SouthPacificLevels
{
get
{
return new List<string>
{
COASTAL,
CRASH,
MADUBU,
PUNA
};
}
}

public static List<string> LondonLevels
{
get
{
return new List<string>
{
THAMES,
ALDWYCH,
LUDS,
CITY,
HALLOWS
};
}
}

public static List<string> NevadaLevels
{
get
{
return new List<string>
{
NEVADA,
HSC,
AREA51
};
}
}

public static List<string> AntarcticaLevels
{
get
{
return new List<string>
{
ANTARC,
RXTECH,
TINNOS,
WILLIE
};
}
}
}
}
8 changes: 8 additions & 0 deletions TRRandomizerCore/Editors/RandomizerSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public class RandomizerSettings
public int StartPositionSeed { get; set; }
public int EnvironmentSeed { get; set; }

public GlobeDisplayOption GlobeDisplay { get; set; }
public bool HardSecrets { get; set; }
public bool IncludeKeyItems { get; set; }
public bool DevelopmentMode { get; set; }
Expand All @@ -41,6 +42,7 @@ public class RandomizerSettings
public bool DocileBirdMonsters { get; set; }
public RandoDifficulty RandoEnemyDifficulty { get; set; }
public bool GlitchedSecrets { get; set; }
public bool UseRewardRoomCameras { get; set; }
public bool PersistOutfits { get; set; }
public bool RemoveRobeDagger { get; set; }
public uint HaircutLevelCount { get; set; }
Expand Down Expand Up @@ -75,10 +77,13 @@ public void ApplyConfig(Config config)
{
int defaultSeed = int.Parse(DateTime.Now.ToString("yyyyMMdd"));

GlobeDisplay = (GlobeDisplayOption)config.GetEnum(nameof(GlobeDisplay), typeof(GlobeDisplayOption), GlobeDisplayOption.Area);

RandomizeSecrets = config.GetBool(nameof(RandomizeSecrets));
SecretSeed = config.GetInt(nameof(SecretSeed), defaultSeed);
HardSecrets = config.GetBool(nameof(HardSecrets));
GlitchedSecrets = config.GetBool(nameof(GlitchedSecrets));
UseRewardRoomCameras = config.GetBool(nameof(UseRewardRoomCameras));

RandomizeItems = config.GetBool(nameof(RandomizeItems));
ItemSeed = config.GetInt(nameof(ItemSeed), defaultSeed);
Expand Down Expand Up @@ -146,10 +151,13 @@ public void ApplyConfig(Config config)

public void StoreConfig(Config config)
{
config[nameof(GlobeDisplay)] = GlobeDisplay;

config[nameof(RandomizeSecrets)] = RandomizeSecrets;
config[nameof(SecretSeed)] = SecretSeed;
config[nameof(HardSecrets)] = HardSecrets;
config[nameof(GlitchedSecrets)] = GlitchedSecrets;
config[nameof(UseRewardRoomCameras)] = UseRewardRoomCameras;

config[nameof(RandomizeItems)] = RandomizeItems;
config[nameof(ItemSeed)] = ItemSeed;
Expand Down
3 changes: 2 additions & 1 deletion TRRandomizerCore/Editors/TR3RandoEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,8 @@ protected override void SaveImpl(AbstractTRScriptEditor scriptEditor, TRSaveMoni
ScriptEditor = tr23ScriptEditor,
Levels = levels,
BasePath = wipDirectory,
SaveMonitor = monitor
SaveMonitor = monitor,
GlobeDisplay = Settings.GlobeDisplay
}.Run();
}

Expand Down
9 changes: 9 additions & 0 deletions TRRandomizerCore/Helpers/GlobeDisplayOption.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace TRRandomizerCore.Helpers
{
public enum GlobeDisplayOption
{
Default,
Area,
Level
}
}
11 changes: 11 additions & 0 deletions TRRandomizerCore/Levels/TR3Adventure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace TRRandomizerCore.Levels
{
public enum TR3Adventure
{
India = 1,
SouthPacific = 5,
London = 9,
Nevada = 13,
Antarctica = 16
}
}
28 changes: 28 additions & 0 deletions TRRandomizerCore/Levels/TR3CombinedLevel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,33 @@ public class TR3CombinedLevel
/// Whether or not the game will account for secrets collected in this level.
/// </summary>
public bool HasSecrets => Script.NumSecrets > 0;

/// <summary>
/// Get the adventure based on this level's name.
/// </summary>
public TR3Adventure Adventure
{
get
{
if (TR3LevelNames.SouthPacificLevels.Contains(Name))
{
return TR3Adventure.SouthPacific;
}
else if (TR3LevelNames.LondonLevels.Contains(Name))
{
return TR3Adventure.London;
}
else if (TR3LevelNames.NevadaLevels.Contains(Name))
{
return TR3Adventure.Nevada;
}
else if (TR3LevelNames.AntarcticaLevels.Contains(Name))
{
return TR3Adventure.Antarctica;
}

return TR3Adventure.India;
}
}
}
}
41 changes: 41 additions & 0 deletions TRRandomizerCore/Processors/TR3/TR3SequenceProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,36 @@ public class TR3SequenceProcessor : TR3LevelProcessor
[TR3Entities.Element115_M_H] = TR3Entities.Key4_M_H,
};

private static readonly Dictionary<TR3Adventure, int> _adventureStringSequences = new Dictionary<TR3Adventure, int>
{
[TR3Adventure.SouthPacific] = 87,
[TR3Adventure.London] = 85,
[TR3Adventure.Nevada] = 86,
[TR3Adventure.Antarctica] = 88
};

private Dictionary<string, List<Location>> _upvLocations;

private Dictionary<TR3Adventure, string> _adventureNames;
private List<string> _gameStrings;

public GlobeDisplayOption GlobeDisplay { get; set; }

public void Run()
{
_upvLocations = JsonConvert.DeserializeObject<Dictionary<string, List<Location>>>(ReadResource(@"TR3\Locations\upv_locations.json"));

_gameStrings = new List<string>(ScriptEditor.Script.GameStrings1);
_adventureNames = new Dictionary<TR3Adventure, string>
{
[TR3Adventure.India] = "India" // Not stored in script
};

foreach (TR3Adventure sequence in _adventureStringSequences.Keys)
{
_adventureNames[sequence] = ScriptEditor.Script.GameStrings1[_adventureStringSequences[sequence]];
}

foreach (TR3ScriptedLevel lvl in Levels)
{
LoadLevelInstance(lvl);
Expand All @@ -49,6 +73,9 @@ public void Run()
break;
}
}

ScriptEditor.Script.GameStrings1 = _gameStrings.ToArray();
SaveScript();
}

private void AdjustLevel(TR3CombinedLevel level)
Expand Down Expand Up @@ -86,6 +113,20 @@ private void AdjustLevel(TR3CombinedLevel level)
// on the level sequencing. So if out of sequence, perform the raising here.
AmendSouthPacificSpikes(level);
}

// If this level is the first in an adventure, update the globe string to match
if (_adventureStringSequences.ContainsKey((TR3Adventure)level.Sequence))
{
switch (GlobeDisplay)
{
case GlobeDisplayOption.Area:
_gameStrings[_adventureStringSequences[(TR3Adventure)level.Sequence]] = _adventureNames[level.Adventure];
break;
case GlobeDisplayOption.Level:
_gameStrings[_adventureStringSequences[(TR3Adventure)level.Sequence]] = level.Script.Name;
break;
}
}
}

private void ImportUPV(TR3CombinedLevel level)
Expand Down
Loading

0 comments on commit a6ae200

Please sign in to comment.