From eb420604814dfdfa37fd542dda9ba7477c198b39 Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Mon, 19 Nov 2018 09:27:29 -0800 Subject: Cleanup packaging story, add more settings --- App/App.vcxproj | 3 + App/Main.cpp | 63 ++++---- App/Version.h | 4 +- GithubPackage/WitnessRandomizer.exe | Bin 0 -> 379392 bytes GithubPackage/WitnessRandomizerInstaller.msi | Bin 0 -> 389632 bytes GithubPackage/setup.exe | Bin 0 -> 791040 bytes Installer/Installer.vdproj | 12 +- Source/ChallengeRandomizer.cpp | 218 +++++++++++++++------------ Source/ChallengeRandomizer.h | 5 + Source/Memory.h | 4 +- Source/Randomizer.cpp | 29 ++-- Source/Randomizer.h | 3 +- 12 files changed, 195 insertions(+), 146 deletions(-) create mode 100644 GithubPackage/WitnessRandomizer.exe create mode 100644 GithubPackage/WitnessRandomizerInstaller.msi create mode 100644 GithubPackage/setup.exe diff --git a/App/App.vcxproj b/App/App.vcxproj index 2597b8d..9b10e92 100644 --- a/App/App.vcxproj +++ b/App/App.vcxproj @@ -85,6 +85,7 @@ false WitnessRandomizer + ..\GithubPackage\ @@ -140,6 +141,7 @@ true true true + UseLinkTimeCodeGeneration @@ -162,6 +164,7 @@ true true true + UseLinkTimeCodeGeneration diff --git a/App/Main.cpp b/App/Main.cpp index 7e802e9..82600bf 100644 --- a/App/Main.cpp +++ b/App/Main.cpp @@ -18,8 +18,10 @@ #define IDC_WRITE 0x407 #define IDC_DUMP 0x408 #define IDT_RANDOMIZED 0x409 +#define IDC_TOGGLELASERS 0x410 +#define IDC_TOGGLESNIPES 0x411 -HWND hwndSeed, hwndRandomize, hwndDebug; +HWND hwndSeed, hwndRandomize; // int panel = 0x18AF; int panel = 0x33D4; std::shared_ptr _panel; @@ -38,13 +40,15 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) seedIsRNG = false; } switch (LOWORD(wParam)) { - // Speed checkbox + // Checkboxes case IDC_TOGGLESPEED: - if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { - CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_UNCHECKED); - } else { - CheckDlgButton(hwnd, IDC_TOGGLESPEED, BST_CHECKED); - } + CheckDlgButton(hwnd, IDC_TOGGLESPEED, !IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)); + break; + case IDC_TOGGLELASERS: + CheckDlgButton(hwnd, IDC_TOGGLELASERS, !IsDlgButtonChecked(hwnd, IDC_TOGGLELASERS)); + break; + case IDC_TOGGLESNIPES: + CheckDlgButton(hwnd, IDC_TOGGLESNIPES, !IsDlgButtonChecked(hwnd, IDC_TOGGLESNIPES)); break; // Randomize button @@ -70,30 +74,27 @@ LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) if (randomizer->GameIsRandomized()) break; Random::SetSeed(seed); - - std::wstringstream debug; - + // Show seed and force redraw std::wstring seedString = std::to_wstring(seed); SetWindowText(hwndRandomize, L"Randomizing..."); SetWindowText(hwndSeed, seedString.c_str()); RedrawWindow(hwnd, NULL, NULL, RDW_UPDATENOW); + // Randomize, then apply settings randomizer->Randomize(); - debug << Random::RandInt(0, 1000) << " "; - debug << Random::RandInt(0, 1000) << "\n"; - debug << Random::RandInt(0, 1000) << " "; - debug << Random::RandInt(0, 1000); - SetWindowText(hwndDebug, debug.str().c_str()); - if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) { - randomizer->AdjustSpeed(); - } - SetWindowText(hwndRandomize, L"Randomized!"); + if (IsDlgButtonChecked(hwnd, IDC_TOGGLESPEED)) randomizer->AdjustSpeed(); + if (IsDlgButtonChecked(hwnd, IDC_TOGGLELASERS)) randomizer->RandomizeLasers(); + if (IsDlgButtonChecked(hwnd, IDC_TOGGLESNIPES)) randomizer->PreventSnipes(); + + // Cleanup, and set timer for "randomization done" + SetWindowText(hwndRandomize, L"Randomized!"); SetTimer(hwnd, IDT_RANDOMIZED, 10000, NULL); break; } case IDT_RANDOMIZED: SetWindowText(hwndRandomize, L"Randomize"); + randomizer->GameIsRandomized(); // "Check" if the game is randomized to update the last known safe frame. break; case IDC_READ: _panel = std::make_shared(panel); @@ -171,11 +172,22 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd 10, 52, 12, 12, hwnd, (HMENU)IDC_TOGGLESPEED, hInstance, NULL); CreateWindow(L"STATIC", L"Speed up various autoscrollers", WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, - 27, 50, 205, 16, hwnd, NULL, hInstance, NULL); + 27, 50, 210, 16, hwnd, NULL, hInstance, NULL); + + CreateWindow(L"BUTTON", L"", + WS_VISIBLE | WS_CHILD | BS_CHECKBOX, + 10, 72, 12, 12, hwnd, (HMENU)IDC_TOGGLELASERS, hInstance, NULL); + CreateWindow(L"STATIC", L"Randomize laser activations", + WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, + 27, 70, 210, 16, hwnd, NULL, hInstance, NULL); - hwndDebug = CreateWindow(L"STATIC", L"", + CreateWindow(L"BUTTON", L"", + WS_VISIBLE | WS_CHILD | BS_CHECKBOX, + 10, 92, 12, 12, hwnd, (HMENU)IDC_TOGGLESNIPES, hInstance, NULL); + CheckDlgButton(hwnd, IDC_TOGGLESNIPES, TRUE); + CreateWindow(L"STATIC", L"Prevent sniping certain puzzles", WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, - 200, 200, 100, 100, hwnd, NULL, hInstance, NULL); + 27, 90, 210, 16, hwnd, NULL, hInstance, NULL); /* CreateWindow(L"BUTTON", L"", @@ -206,13 +218,6 @@ int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmd WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, 27, 50, 205, 16, hwnd, NULL, hInstance, NULL); - CreateWindow(L"BUTTON", L"", - WS_VISIBLE | WS_CHILD | BS_CHECKBOX, - 10, 52, 12, 12, hwnd, (HMENU)IDC_BANSNIPES, hInstance, NULL); - CreateWindow(L"STATIC", L"Prevent sniping certain puzzles", - WS_TABSTOP | WS_VISIBLE | WS_CHILD | SS_LEFT, - 27, 50, 205, 16, hwnd, NULL, hInstance, NULL); - */ ShowWindow(hwnd, nCmdShow); diff --git a/App/Version.h b/App/Version.h index 61473e6..1167925 100644 --- a/App/Version.h +++ b/App/Version.h @@ -3,9 +3,9 @@ #define TO_STRING2(s) L#s #define TO_STRING(s) TO_STRING2(s) -#define MAJOR 4 +#define MAJOR 5 #define MINOR 0 -#define PATCH 6 +#define PATCH 0 #define VERSION_STR TO_STRING(MAJOR) L"." TO_STRING(MINOR) L"." TO_STRING(PATCH) #define VERSION MAJOR, MINOR, PATCH diff --git a/GithubPackage/WitnessRandomizer.exe b/GithubPackage/WitnessRandomizer.exe new file mode 100644 index 0000000..11a154e Binary files /dev/null and b/GithubPackage/WitnessRandomizer.exe differ diff --git a/GithubPackage/WitnessRandomizerInstaller.msi b/GithubPackage/WitnessRandomizerInstaller.msi new file mode 100644 index 0000000..b2afff9 Binary files /dev/null and b/GithubPackage/WitnessRandomizerInstaller.msi differ diff --git a/GithubPackage/setup.exe b/GithubPackage/setup.exe new file mode 100644 index 0000000..223753d Binary files /dev/null and b/GithubPackage/setup.exe differ diff --git a/Installer/Installer.vdproj b/Installer/Installer.vdproj index cd1c976..4677dbb 100644 --- a/Installer/Installer.vdproj +++ b/Installer/Installer.vdproj @@ -27,7 +27,7 @@ "DisplayName" = "8:Debug" "IsDebugOnly" = "11:TRUE" "IsReleaseOnly" = "11:FALSE" - "OutputFilename" = "8:WitnessRandomizerInstaller.msi" + "OutputFilename" = "8:..\\GithubPackage\\WitnessRandomizerInstaller.msi" "PackageFilesAs" = "3:2" "PackageFileSize" = "3:-2147483648" "CabType" = "3:1" @@ -59,7 +59,7 @@ "DisplayName" = "8:Release" "IsDebugOnly" = "11:FALSE" "IsReleaseOnly" = "11:TRUE" - "OutputFilename" = "8:WitnessRandomizerInstaller.msi" + "OutputFilename" = "8:..\\GithubPackage\\WitnessRandomizerInstaller.msi" "PackageFilesAs" = "3:2" "PackageFileSize" = "3:-2147483648" "CabType" = "3:1" @@ -162,15 +162,15 @@ { "Name" = "8:Microsoft Visual Studio" "ProductName" = "8:Witness Randomizer" - "ProductCode" = "8:{ED6B3515-B039-4560-B97F-A61695CCDE5F}" - "PackageCode" = "8:{4C062EDD-4A06-4DC6-9C37-82A2BD37A0B5}" + "ProductCode" = "8:{2AC8C329-8190-4A51-9861-5C922763C6F3}" + "PackageCode" = "8:{05B49C89-4B7E-4E42-B061-3BAB51527E54}" "UpgradeCode" = "8:{4CB5496B-A47E-41D3-B4A7-677E29AB7513}" "AspNetVersion" = "8:2.0.50727.0" "RestartWWWService" = "11:FALSE" "RemovePreviousVersions" = "11:FALSE" "DetectNewerInstalledVersion" = "11:TRUE" "InstallAllUsers" = "11:FALSE" - "ProductVersion" = "8:4.0.8" + "ProductVersion" = "8:5.0.0" "Manufacturer" = "8:jbzdarkid" "ARPHELPTELEPHONE" = "8:" "ARPHELPLINK" = "8:https://www.github.com/jbzdarkid/witness-randomizer/issues" @@ -698,7 +698,7 @@ { "{5259A561-127C-4D43-A0A1-72F10C7B3BF8}:_F4835D5BBF3E437390127C4C49888F07" { - "SourcePath" = "8:..\\x64\\Release\\WitnessRandomizer.exe" + "SourcePath" = "8:..\\x64\\Debug\\WitnessRandomizer.exe" "TargetName" = "8:" "Tag" = "8:" "Folder" = "8:_8E9D847124D34D9D9008762077D816DE" diff --git a/Source/ChallengeRandomizer.cpp b/Source/ChallengeRandomizer.cpp index 0bc51f6..401771e 100644 --- a/Source/ChallengeRandomizer.cpp +++ b/Source/ChallengeRandomizer.cpp @@ -16,116 +16,33 @@ int find(const std::vector &data, const std::vector& search, size_t return -1; } +// Reads the (relative!) address of the RNG, then shifts it to point at RNG2 void ChallengeRandomizer::AdjustRng(int offset) { int currentRng = _memory->ReadData({offset}, 0x1)[0]; _memory->WriteData({offset}, {currentRng + 0x20}); } +// Overwrite the pointer for the lightmap_generator (which is unused, afaict) to point to a secondary RNG. +// Then, adjust all the RNG functions in challenge/doors to use this RNG. ChallengeRandomizer::ChallengeRandomizer(const std::shared_ptr& memory, int seed) : _memory(memory) { - int RNG_ADDR = _memory->ReadData({GLOBALS + 0x10}, 1)[0]; - int RNG2_ADDR = _memory->ReadData({GLOBALS + 0x30}, 1)[0]; - _memory->WriteData({GLOBALS + 0x30}, {RNG_ADDR + 4}); - if (RNG2_ADDR == RNG_ADDR + 4) return; // Already applied hack + RNG_ADDR = _memory->ReadData({GLOBALS + 0x10}, 1)[0]; + RNG2_ADDR = _memory->ReadData({GLOBALS + 0x30}, 1)[0]; + bool alreadyInjected = (RNG2_ADDR == RNG_ADDR + 4); + + if (!alreadyInjected) _memory->WriteData({GLOBALS + 0x30}, {RNG_ADDR + 4}); + _memory->WriteData({GLOBALS + 0x30, 0}, {seed}); - int shuffle_integers = -1; - int cut_random_edges = -1; - int get_empty_decoration_slot = -1; - int get_empty_dot_spot = -1; - int add_exactly_this_many_bisection_dots = -1; - int make_a_shaper = -1; - int init_pattern_data_lotus = -1; - int reroll_lotus_eater_stuff = -1; - int do_lotus_minutes = -1; - int do_lotus_eighths = -1; int do_success_side_effects = -1; for (int i=0; i<0x200000; i+=0x1000) { std::vector data = _memory->ReadData({i}, 0x1100); std::cout << data.size() << std::endl; - if (shuffle_integers == -1) { - int index = find(data, {0x48, 0x89, 0x5C, 0x24, 0x10, 0x56, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x63, 0xDA, 0x48, 0x8B, 0xF1, 0x83, 0xFB, 0x01}); - if (index != -1) { - shuffle_integers = i + index; - AdjustRng(shuffle_integers + 0x23); - } - } - if (cut_random_edges == -1) { - int index = find(data, {0x89, 0x44, 0x24, 0x3C, 0x33, 0xC0, 0x85, 0xC0, 0x75, 0xFA}); - if (index != -1) { - cut_random_edges = i + index - 0x22; - AdjustRng(cut_random_edges + 0x5D); - } - } - if (get_empty_decoration_slot == -1) { - int index = find(data, {0x57, 0x48, 0x83, 0xEC, 0x20, 0x8B, 0xB9, 0x38, 0x04}); // TODO: Sync versions - if (index != -1) { - get_empty_decoration_slot = i + index - 0x5; - AdjustRng(get_empty_decoration_slot + 0x16); - } - } - if (get_empty_dot_spot == -1) { - int index = find(data, {0xF7, 0xF3, 0x85, 0xD2, 0x74, 0xEC}); // TODO: Sync versions - if (index != -1) { - get_empty_dot_spot = i + index - 0x2E; - AdjustRng(get_empty_dot_spot + 0x23); - } - } - if (add_exactly_this_many_bisection_dots == -1) { - int index = find(data, {0x48, 0x8B, 0xB4, 0x24, 0xB8, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xBC, 0x24, 0xB0, 0x00, 0x00, 0x00}); // TODO: Sync versions - if (index != -1) { - add_exactly_this_many_bisection_dots = i + index - 0x20; - AdjustRng(add_exactly_this_many_bisection_dots + 0x1C); - } - } - if (make_a_shaper == -1) { - int index = find(data, {0xF7, 0xE3, 0xD1, 0xEA, 0x8D, 0x0C, 0x52}); // TODO: Sync versions - if (index != -1) { - make_a_shaper = i + index - 0x19; - AdjustRng(make_a_shaper + 0x9); - AdjustRng(make_a_shaper + 0x35); - AdjustRng(make_a_shaper + 0x62); - } - } - if (/*Entity_Machine_Panel::*/init_pattern_data_lotus == -1) { - int index = find(data, {0x40, 0x55, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xB1}); // TODO: Sync versions - if (index != -1) { - init_pattern_data_lotus = i + index; - AdjustRng(init_pattern_data_lotus + 0x433); - AdjustRng(init_pattern_data_lotus + 0x45B); - AdjustRng(init_pattern_data_lotus + 0x5A7); - AdjustRng(init_pattern_data_lotus + 0x5D6); - AdjustRng(init_pattern_data_lotus + 0x6F6); - AdjustRng(init_pattern_data_lotus + 0xD17); - AdjustRng(init_pattern_data_lotus + 0xFDA); - } - } - if (/*Entity_Record_Player::*/reroll_lotus_eater_stuff == -1) { - int index = find(data, {0xB8, 0xAB, 0xAA, 0xAA, 0xAA, 0x41, 0xC1, 0xE8}); // TODO: Sync versions - if (index != -1) { - reroll_lotus_eater_stuff = i + index - 0x37; - AdjustRng(reroll_lotus_eater_stuff + 0x24); - AdjustRng(reroll_lotus_eater_stuff + 0x6B); - } - } - // These disable the random locations on timer panels, which would otherwise increment the RNG. - if (do_lotus_minutes == -1) { - int index = find(data, {0x0F, 0xBE, 0x6C, 0x08, 0xFF, 0x45}); // TODO: Sync versions - if (index != -1) { - do_lotus_minutes = i + index - 0x2B; - _memory->WriteData({do_lotus_minutes + 0x43B}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 - _memory->WriteData({do_lotus_minutes + 0x5B3}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 - } - } - if (do_lotus_eighths == -1) { - int index = find(data, {0x75, 0xF5, 0x0F, 0xBE, 0x44, 0x08, 0xFF}); // TODO: Sync versions - if (index != -1) { - do_lotus_eighths = i + index - 0x39; - _memory->WriteData({do_lotus_eighths + 0x1E7}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 - } - } + if (!alreadyInjected) HandleSigScans(i, data); + // This injection ensures that the seed is set every time the challenge is started. + // We always do this sigscan since it affects the seed. if (do_success_side_effects == -1) { int index = find(data, {0xFF, 0xC8, 0x99, 0x2B, 0xC2, 0xD1, 0xF8, 0x8B, 0xD0}); if (index != -1) { @@ -144,3 +61,114 @@ ChallengeRandomizer::ChallengeRandomizer(const std::shared_ptr& memory, } } } + +void ChallengeRandomizer::HandleSigScans(int i, const std::vector& data) { + static int shuffle_integers = -1; + static int shuffle_int = -1; + static int cut_random_edges = -1; + static int get_empty_decoration_slot = -1; + static int get_empty_dot_spot = -1; + static int add_exactly_this_many_bisection_dots = -1; + static int make_a_shaper = -1; + static int init_pattern_data_lotus = -1; + static int reroll_lotus_eater_stuff = -1; + static int do_lotus_minutes = -1; + static int do_lotus_tenths = -1; + static int do_lotus_eighths = -1; + + if (shuffle_integers == -1) { + int index = find(data, {0x48, 0x89, 0x5C, 0x24, 0x10, 0x56, 0x48, 0x83, 0xEC, 0x20, 0x48, 0x63, 0xDA, 0x48, 0x8B, 0xF1, 0x83, 0xFB, 0x01}); + if (index != -1) { + shuffle_integers = i + index; + AdjustRng(shuffle_integers + 0x23); + } + } + // shuffle + if (shuffle_int == -1) { + int index = find(data, {0x33, 0xF6, 0x48, 0x8B, 0xD9, 0x39, 0x31, 0x7E, 0x51}); + if (index != -1) { + shuffle_int = i + index - 0x16; + AdjustRng(shuffle_int + 0x12); + } + } + if (cut_random_edges == -1) { + int index = find(data, {0x89, 0x44, 0x24, 0x3C, 0x33, 0xC0, 0x85, 0xC0, 0x75, 0xFA}); + if (index != -1) { + cut_random_edges = i + index - 0x22; + AdjustRng(cut_random_edges + 0x5D); + } + } + if (get_empty_decoration_slot == -1) { + int index = find(data, {0x42, 0x83, 0x3C, 0x80, 0x00, 0x75, 0xDF}); + if (index != -1) { + get_empty_decoration_slot = i + index - 0x2D; + AdjustRng(get_empty_decoration_slot + 0x16); + } + } + if (get_empty_dot_spot == -1) { + int index = find(data, {0xF7, 0xF3, 0x85, 0xD2, 0x74, 0xEC}); + if (index != -1) { + get_empty_dot_spot = i + index - 0x2E; + AdjustRng(get_empty_dot_spot + 0x23); + } + } + if (add_exactly_this_many_bisection_dots == -1) { + int index = find(data, {0x48, 0x8B, 0xB4, 0x24, 0xB8, 0x00, 0x00, 0x00, 0x48, 0x8B, 0xBC, 0x24, 0xB0, 0x00, 0x00, 0x00}); + if (index != -1) { + add_exactly_this_many_bisection_dots = i + index - 0x20; + AdjustRng(add_exactly_this_many_bisection_dots + 0x1C); + } + } + if (make_a_shaper == -1) { + int index = find(data, {0xF7, 0xE3, 0xD1, 0xEA, 0x8D, 0x0C, 0x52}); + if (index != -1) { + make_a_shaper = i + index - 0x19; + AdjustRng(make_a_shaper + 0x9); + AdjustRng(make_a_shaper + 0x35); + AdjustRng(make_a_shaper + 0x62); + } + } + if (/*Entity_Machine_Panel::*/init_pattern_data_lotus == -1) { + int index = find(data, {0x40, 0x55, 0x56, 0x48, 0x8D, 0x6C, 0x24, 0xB1}); + if (index != -1) { + init_pattern_data_lotus = i + index; + AdjustRng(init_pattern_data_lotus + 0x433); + AdjustRng(init_pattern_data_lotus + 0x45B); + AdjustRng(init_pattern_data_lotus + 0x5A7); + AdjustRng(init_pattern_data_lotus + 0x5D6); + AdjustRng(init_pattern_data_lotus + 0x6F6); + AdjustRng(init_pattern_data_lotus + 0xD17); + AdjustRng(init_pattern_data_lotus + 0xFDA); + } + } + if (/*Entity_Record_Player::*/reroll_lotus_eater_stuff == -1) { + int index = find(data, {0xB8, 0xAB, 0xAA, 0xAA, 0xAA, 0x41, 0xC1, 0xE8}); + if (index != -1) { + reroll_lotus_eater_stuff = i + index - 0x37; + AdjustRng(reroll_lotus_eater_stuff + 0x24); + AdjustRng(reroll_lotus_eater_stuff + 0x6B); + } + } + // These disable the random locations on timer panels, which would otherwise increment the RNG. + if (do_lotus_minutes == -1) { + int index = find(data, {0x0F, 0xBE, 0x6C, 0x08, 0xFF, 0x45}); + if (index != -1) { + do_lotus_minutes = i + index - 0x2B; + _memory->WriteData({do_lotus_minutes + 0x43B}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 + } + } + if (do_lotus_tenths == -1) { + int index = find(data, {0x00, 0x04, 0x00, 0x00, 0x41, 0x8D, 0x50, 0x09}); + if (index != -1) { + do_lotus_tenths = i + index - 0x61; + _memory->WriteData({do_lotus_tenths + 0x103}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 + } + } + if (do_lotus_eighths == -1) { + int index = find(data, {0x75, 0xF5, 0x0F, 0xBE, 0x44, 0x08, 0xFF}); + if (index != -1) { + do_lotus_eighths = i + index - 0x39; + _memory->WriteData({do_lotus_eighths + 0x1E7}, {0x31, 0xC0, 0x90, 0x90, 0x90}); // xor eax, eax ;RNG returns 0 + } + } +} \ No newline at end of file diff --git a/Source/ChallengeRandomizer.h b/Source/ChallengeRandomizer.h index 267c5cb..e642685 100644 --- a/Source/ChallengeRandomizer.h +++ b/Source/ChallengeRandomizer.h @@ -7,6 +7,11 @@ public: ChallengeRandomizer(const std::shared_ptr& memory, int seed); private: + void HandleSigScans(int i, const std::vector& data); + void AdjustRng(int offset); std::shared_ptr _memory; + + int RNG_ADDR; + int RNG2_ADDR; }; diff --git a/Source/Memory.h b/Source/Memory.h index 278ce36..403b94a 100644 --- a/Source/Memory.h +++ b/Source/Memory.h @@ -3,8 +3,8 @@ #include #include -#define GLOBALS 0x5B28C0 -// #define GLOBALS 0x62A080 +// #define GLOBALS 0x5B28C0 +#define GLOBALS 0x62A080 // https://github.com/erayarslan/WriteProcessMemory-Example // http://stackoverflow.com/q/32798185 diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 2f3e72a..48e9a4b 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp @@ -89,6 +89,22 @@ void Randomizer::AdjustSpeed() { _memory->WritePanelData(0x09EEC, OPEN_RATE, {0.075f}); // 3x } +void Randomizer::RandomizeLasers() { + Randomize(lasers, SWAP::TARGETS); + // Read the target of keep front laser, and write it to keep back laser. + std::vector keepFrontLaserTarget = _memory->ReadPanelData(0x0360E, TARGET, 1); + _memory->WritePanelData(0x03317, TARGET, keepFrontLaserTarget); +} + +void Randomizer::PreventSnipes() +{ + // Distance-gate swamp snipe 1 to prevent RNG swamp snipe + _memory->WritePanelData(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); + // Distance-gate shadows laser to prevent sniping through the bars + _memory->WritePanelData(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); +} + +// Private methods void Randomizer::RandomizeTutorial() { // Disable tutorial cursor speed modifications (not working?) _memory->WritePanelData(0x00295, CURSOR_SPEED_SCALE, {1.0}); @@ -130,8 +146,6 @@ void Randomizer::RandomizeKeep() { } void Randomizer::RandomizeShadows() { - // Distance-gate shadows laser to prevent sniping through the bars - _memory->WritePanelData(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); // Change the shadows tutorial cable to only activate avoid _memory->WritePanelData(0x319A8, CABLE_TARGET_2, {0}); // Change shadows avoid 8 to power shadows follow @@ -182,13 +196,10 @@ void Randomizer::RandomizeJungle() { } void Randomizer::RandomizeSwamp() { - // Distance-gate swamp snipe 1 to prevent RNG swamp snipe - _memory->WritePanelData(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); } void Randomizer::RandomizeMountain() { - // Randomize lasers & some of mountain - Randomize(lasers, SWAP::TARGETS); + // Randomize multipanel Randomize(mountainMultipanel, SWAP::LINES); // Randomize final pillars order @@ -210,14 +221,10 @@ void Randomizer::RandomizeMountain() { // Turn on new starting panels _memory->WritePanelData(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); _memory->WritePanelData(pillars[randomOrder[5]], POWER, {1.0f, 1.0f}); - - // Read the target of keep front laser, and write it to keep back laser. - std::vector keepFrontLaserTarget = _memory->ReadPanelData(0x0360E, TARGET, 1); - _memory->WritePanelData(0x03317, TARGET, keepFrontLaserTarget); } void Randomizer::RandomizeChallenge() { - ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x1000)); + ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block } void Randomizer::RandomizeAudioLogs() { diff --git a/Source/Randomizer.h b/Source/Randomizer.h index 1180d43..88afcc6 100644 --- a/Source/Randomizer.h +++ b/Source/Randomizer.h @@ -8,6 +8,8 @@ public: bool GameIsRandomized(); void AdjustSpeed(); + void RandomizeLasers(); + void PreventSnipes(); void ClearOffsets() {_memory->ClearOffsets();} @@ -19,7 +21,6 @@ public: }; private: - int _lastRandomizedFrame = 1 << 30; void RandomizeTutorial(); void RandomizeSymmetry(); -- cgit 1.4.1