Skip to content

Commit

Permalink
Add support for random seed on restart
Browse files Browse the repository at this point in the history
  • Loading branch information
gmjosack committed Apr 28, 2024
1 parent b3603a0 commit 15be4a6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## Unreleased

## [0.0.40] - 2023-04-27

### Added

- Ability to draw lines between follower/following Player/HH links
- Option for Seeded to choose new seed on reset

## [0.0.39] - 2023-10-07

Expand Down
12 changes: 12 additions & 0 deletions specs/specs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ FullSpelunkyState gFullSpelunkyState = {};
struct SeededModeState {
uint32_t seed = 1;
bool useDailySeeding = false;
bool randomSeedOnRestart = false;
};
SeededModeState gSeededModeState = {};

Expand Down Expand Up @@ -324,6 +325,7 @@ void preGenerateRoomBiglunky();
void prePlaceRoomsBiglunky();
void postPlaceRoomsBiglunky();
void resetTunnelManState();
void chooseRandomSeed();
Entity *postSpawnEntityTunnelMan(Entity *);

TextureDefinition *getTextureById(int32_t texture_id) {
Expand Down Expand Up @@ -512,6 +514,9 @@ void __declspec(naked) hookPreResetForRun() {
if (gModsState.TunnelMan) {
resetTunnelManState();
}
if (gModsState.SeededMode && gSeededModeState.randomSeedOnRestart) {
chooseRandomSeed();
}

__asm {
; Restore all registers
Expand Down Expand Up @@ -3299,6 +3304,8 @@ void resetTunnelManState() {
}
}

void chooseRandomSeed() { gSeededModeState.seed = mersenne_random(); }

void resetFullSpelunkyState() {
gFullSpelunkyState.allCharacters = {
CHARACTER_GUY,
Expand Down Expand Up @@ -4097,6 +4104,11 @@ void drawModsTab() {
applyPatches(gSeededModeDailySeedingPatches, true);
}
}

ImGui::Text("");
ImGui::SameLine(20.0f * io.FontGlobalScale);
ImGui::Checkbox("Random Seed On Restart##SeededMode",
&gSeededModeState.randomSeedOnRestart);
}

void drawToggleEntityTab(const char *preText, EnabledEntities &enabledEnts) {
Expand Down

0 comments on commit 15be4a6

Please sign in to comment.