From 69a8f903ef70845894ff07e0805d9cc60597cc7c Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Wed, 24 Oct 2018 20:20:12 -0700 Subject: progress of various sorts --- WitnessRandomizer/Memory.cpp | 4 ++-- WitnessRandomizer/Memory.h | 5 +++++ WitnessRandomizer/Panels.h | 36 +++++++++++++++++++++++++------- WitnessRandomizer/WitnessRandomizer.cpp | 37 ++++++++++++++++++++++++++------- WitnessRandomizer/WitnessRandomizer.h | 2 +- 5 files changed, 67 insertions(+), 17 deletions(-) diff --git a/WitnessRandomizer/Memory.cpp b/WitnessRandomizer/Memory.cpp index 7005455..304b7b4 100644 --- a/WitnessRandomizer/Memory.cpp +++ b/WitnessRandomizer/Memory.cpp @@ -18,7 +18,7 @@ Memory::Memory(const std::string& processName) { } } if (!_handle) { - OutputDebugStringA("Process is not open!"); + OutputDebugStringA("Process is not open!\n"); exit(EXIT_FAILURE); } @@ -38,7 +38,7 @@ Memory::Memory(const std::string& processName) { } } if (_baseAddress == 0) { - OutputDebugStringA("Couldn't find base address!"); + OutputDebugStringA("Couldn't find base address!\n"); exit(EXIT_FAILURE); } } diff --git a/WitnessRandomizer/Memory.h b/WitnessRandomizer/Memory.h index dc92349..adc1287 100644 --- a/WitnessRandomizer/Memory.h +++ b/WitnessRandomizer/Memory.h @@ -2,6 +2,9 @@ #include #include #include +#include +#include +using namespace std::chrono_literals; // https://github.com/erayarslan/WriteProcessMemory-Example // http://stackoverflow.com/q/32798185 @@ -22,6 +25,7 @@ public: { return data; } + // std::this_thread::sleep_for(10ms); } ThrowError(); } @@ -32,6 +36,7 @@ public: if (WriteProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), NULL)) { return; } + // std::this_thread::sleep_for(10ms); } ThrowError(); } diff --git a/WitnessRandomizer/Panels.h b/WitnessRandomizer/Panels.h index 3a54ac1..8d594b1 100644 --- a/WitnessRandomizer/Panels.h +++ b/WitnessRandomizer/Panels.h @@ -13,6 +13,26 @@ std::vector lasers = { 0x03616, // Jungle }; +std::vector burnablePanels = { + 0x17D9C, // Treehouse Yellow 7 + 0x17DC2, // Treehouse Yellow 8 + 0x17DC4, // Treehouse Yellow 9 + 0x00999, // Swamp Discontinuous 1 + 0x0099D, // Swamp Discontinuous 2 + 0x009A0, // Swamp Discontinuous 3 + 0x009A1, // Swamp Discontinuous 4 + 0x00007, // Swamp Rotation Tutorial 1 + 0x00008, // Swamp Rotation Tutorial 2 + 0x00009, // Swamp Rotation Tutorial 3 + 0x0000A, // Swamp Rotation Tutorial 4 + 0x28AC7, // Town Blue 1 + 0x28AC8, // Town Blue 2 + 0x28ACA, // Town Blue 3 + 0x28ACB, // Town Blue 4 + 0x28ACC, // Town Blue 5 + 0x17CF0, // Mill Discard +}; + std::vector tutorialPanels = { // 0x0A3B5, // Back Left 0x0A3B2, // Back Right @@ -49,9 +69,9 @@ std::vector outsideTutorialPanels = { // 0x032F7, // Orchard Apple Tree 4 // 0x032FF, // Orchard Apple Tree 5 }; - + std::vector symmetryPanels = { -// 0x3C12B, // Glass Factory Discard + 0x3C12B, // Glass Factory Discard 0x01A54, // Glass Factory Entry 0x00086, // Glass Factory Vertical Symmetry 1 0x00087, // Glass Factory Vertical Symmetry 2 @@ -97,11 +117,11 @@ std::vector symmetryPanels = { 0x00A61, // Symmetry Island Laser Blue 1 0x00A64, // Symmetry Island Laser Blue 2 0x00A68, // Symmetry Island Laser Blue 3 + 0x17CE7, // Desert Discard + 0x0CC7B, // Desert Vault }; std::vector desertPanels = { -// 0x17CE7, // Desert Discard -// 0x0CC7B, // Desert Vault // 0x0339E, // Desert Vault Box 0x00698, // Desert Surface 1 0x0048F, // Desert Surface 2 @@ -172,7 +192,7 @@ std::vector quarryPanels = { // 0x275ED, // Mill EP Door // 0x17CAC, // Mill Stairs Shortcut Door 0x03677, // Mill Stairs Control -// 0x17CF0, // Mill Discard + 0x17CF0, // Mill Discard // 0x17CC4, // Mill Elevator Control 0x021D5, // Boathouse Ramp Activation Shapers 0x034D4, // Boathouse Ramp Activation Stars @@ -258,7 +278,7 @@ std::vector treehousePanels = { //worked fine until I commented out pivotin 0x17E3C, // Treehouse Green 1 0x17E4D, // Treehouse Green 2 0x17E4F, // Treehouse Green 3 -// 0x17E52, // Treehouse Green 4 +// 0x17E52, // Treehouse Green 4 has to pivot 0x17E5B, // Treehouse Green 5 0x17E5F, // Treehouse Green 6 0x17E61, // Treehouse Green 7 @@ -401,7 +421,7 @@ std::vector junglePanels = { 0x00C3F, // Jungle Dots 4 0x00C41, // Jungle Dots 5 0x014B2, // Jungle Dots 6 -// 0x17CAB, // Jungle Pop - up Wall +// 0x17CAB, // Jungle Pop-up Wall // 0x337FA, // Jungle Shortcut }; @@ -548,6 +568,8 @@ std::vector pillars = { 0x09E5A, // Mountain 3 Right Pillar 3 0x33961, // Mountain 3 Right Pillar 4 0x09DD5, // UTM Challenge Pillar +// 0x1C31A, // Challenge Left Pillar +// 0x1C319, // Challenge Right Pillar }; std::vector mountainMultipanel = { diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp index 8a966d4..79fb721 100644 --- a/WitnessRandomizer/WitnessRandomizer.cpp +++ b/WitnessRandomizer/WitnessRandomizer.cpp @@ -2,11 +2,9 @@ * BUGS: * Bunker has physical panel objects which I can't move :( * Shipwreck vault does not copy well - * Pillars can be swapped but they don't zoom you out enough. Maybe SWAP_DISTANCE? * FEATURES: * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?) * Randomize audio logs - * Separate panels out by "square", which can probably be anywhere * List of panels which can be valid "Burn" (aka desert) substitutes: Prevent (or limit) panel counting * List of panels which split left/right (for left/right controls) * List of panels which split up/down (for up/down controls) @@ -62,17 +60,39 @@ int main(int argc, char** argv) int PILLAR_L_1 = 0x383D; int PILLAR_L_4 = 0x339BB; int PILLAR_C = 0x9DD5; + int PILLAR_C_L = 0x1C31A; + int DESERT_1 = 0x00698; + int DESERT_L_2 = 0x006E3; + int TOWN_S_1 = 0x28AC7; - randomizer.SwapPanels(PILLAR_L_1, PILLAR_C, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE); + std::vector squarePanels; + for (auto panelSet : {outsideTutorialPanels, symmetryPanels, quarryPanels, keepPanels, townPanels, bunkerPanels, swampPanels, mountainPanels, utmPanels, treehousePanels}) { + squarePanels.insert(squarePanels.end(), panelSet.begin(), panelSet.end()); + } + for (int panel : squarePanels) { + randomizer.SwapPanels(DESERT_L_2, panel, SWAP_LINES | SWAP_STYLE); + } + + + //randomizer.SwapPanels(PILLAR_L_1, PILLAR_C_L, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE); + //randomizer.SwapPanelData(PILLAR_L_1, PILLAR_C_L, 0x200, 0x50); + // Turn on the panel + //randomizer._memory.WriteData({0x5B28C0, 0x18, PILLAR_L_1*8, 0x2A8}, {1.0f, 1.0f}); + + // randomizer.SwapPanels(PILLAR_L_1, PILLAR_C_L, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE); //*/ } -WitnessRandomizer::WitnessRandomizer() : _memory(Memory("witness64_d3d11.exe")) +WitnessRandomizer::WitnessRandomizer() : _memory("witness64_d3d11.exe") { // Turn off desert flood final _memory.WriteData({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f, 0.0f}); // Change desert floating target to desert flood final _memory.WriteData({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077}); + // Explicitly set back-off distance for the challenge entry & final 2 pillars + _memory.WriteData({0x5B28C0, 0x18, 0x9DD5*8, 0x22C}, {2.5f}); + _memory.WriteData({0x5B28C0, 0x18, 0x1C31A*8, 0x22C}, {3.0f}); + _memory.WriteData({0x5B28C0, 0x18, 0x1C319*8, 0x22C}, {3.0f}); } void WitnessRandomizer::Randomize(std::vector panels, int flags) { @@ -95,7 +115,7 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) { } if (flags & SWAP_LINES) { offsets[0x230] = 16; // traced_edges -// offsets[0x220] = sizeof(void*); // *pattern_name + offsets[0x220] = sizeof(void*); // *pattern_name // offsets[0x240] = sizeof(void*); // *mesh_name offsets[0x2FC] = sizeof(int); // is_cylinder offsets[0x300] = sizeof(float); // cylinder_z0 @@ -104,6 +124,8 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) { // offsets[0x35C] = sizeof(int); // solvable_from_behind // offsets[0x30C] = sizeof(float); // uv_to_world_scale + offsets[0x398] = sizeof(float); // specular_add + offsets[0x39C] = sizeof(int); // specular_power offsets[0x3A4] = sizeof(float); // path_width_scale offsets[0x3A8] = sizeof(float); // startpoint_scale offsets[0x3B8] = sizeof(int); // num_dots @@ -112,6 +134,7 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) { offsets[0x3D0] = sizeof(void*); // *dot_flags offsets[0x3D8] = sizeof(void*); // *dot_connection_a offsets[0x3E0] = sizeof(void*); // *dot_connection_b +// offsets[0x3E8] = sizeof(int); // randomize_on_power_on offsets[0x420] = sizeof(void*); // *decorations offsets[0x428] = sizeof(void*); // *decoration_flags offsets[0x438] = sizeof(int); // num_decorations @@ -173,8 +196,8 @@ void WitnessRandomizer::SwapPanelData(int panel1, int panel2, int finalOffset, i std::vector panel2Offset = {0x5B28C0, 0x18, panel2*8, finalOffset}; std::vector panel1Data = _memory.ReadData(panel1Offset, dataSize); - std::vector panel2Data = _memory.ReadData(panel2Offset, dataSize); + //std::vector panel2Data = _memory.ReadData(panel2Offset, dataSize); _memory.WriteData(panel2Offset, panel1Data); - _memory.WriteData(panel1Offset, panel2Data); + //_memory.WriteData(panel1Offset, panel2Data); } diff --git a/WitnessRandomizer/WitnessRandomizer.h b/WitnessRandomizer/WitnessRandomizer.h index af1f785..7618e91 100644 --- a/WitnessRandomizer/WitnessRandomizer.h +++ b/WitnessRandomizer/WitnessRandomizer.h @@ -13,7 +13,7 @@ public: void Randomize(std::vector panels, int flags); void SwapPanels(int panel1, int panel2, int flags); -private: +//private: void SwapPanelData(int panel1, int panel2, int finalOffset, int dataSize); Memory _memory; -- cgit 1.4.1