about summary refs log tree commit diff stats
path: root/WitnessRandomizer
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-10-24 20:20:12 -0700
committerjbzdarkid <jbzdarkid@gmail.com>2018-10-24 20:20:12 -0700
commit69a8f903ef70845894ff07e0805d9cc60597cc7c (patch)
treeb3a91870eea300b95732ce22c6ac8c1e94307bc9 /WitnessRandomizer
parent4f9229dfe609632a193ce515f8fa83b494948e48 (diff)
downloadwitness-tutorializer-69a8f903ef70845894ff07e0805d9cc60597cc7c.tar.gz
witness-tutorializer-69a8f903ef70845894ff07e0805d9cc60597cc7c.tar.bz2
witness-tutorializer-69a8f903ef70845894ff07e0805d9cc60597cc7c.zip
progress of various sorts
Diffstat (limited to 'WitnessRandomizer')
-rw-r--r--WitnessRandomizer/Memory.cpp4
-rw-r--r--WitnessRandomizer/Memory.h5
-rw-r--r--WitnessRandomizer/Panels.h36
-rw-r--r--WitnessRandomizer/WitnessRandomizer.cpp37
-rw-r--r--WitnessRandomizer/WitnessRandomizer.h2
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) {
18 } 18 }
19 } 19 }
20 if (!_handle) { 20 if (!_handle) {
21 OutputDebugStringA("Process is not open!"); 21 OutputDebugStringA("Process is not open!\n");
22 exit(EXIT_FAILURE); 22 exit(EXIT_FAILURE);
23 } 23 }
24 24
@@ -38,7 +38,7 @@ Memory::Memory(const std::string& processName) {
38 } 38 }
39 } 39 }
40 if (_baseAddress == 0) { 40 if (_baseAddress == 0) {
41 OutputDebugStringA("Couldn't find base address!"); 41 OutputDebugStringA("Couldn't find base address!\n");
42 exit(EXIT_FAILURE); 42 exit(EXIT_FAILURE);
43 } 43 }
44} 44}
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 @@
2#include <vector> 2#include <vector>
3#include <map> 3#include <map>
4#include <windows.h> 4#include <windows.h>
5#include <thread>
6#include <chrono>
7using namespace std::chrono_literals;
5 8
6// https://github.com/erayarslan/WriteProcessMemory-Example 9// https://github.com/erayarslan/WriteProcessMemory-Example
7// http://stackoverflow.com/q/32798185 10// http://stackoverflow.com/q/32798185
@@ -22,6 +25,7 @@ public:
22 { 25 {
23 return data; 26 return data;
24 } 27 }
28 // std::this_thread::sleep_for(10ms);
25 } 29 }
26 ThrowError(); 30 ThrowError();
27 } 31 }
@@ -32,6 +36,7 @@ public:
32 if (WriteProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), NULL)) { 36 if (WriteProcessMemory(_handle, (LPVOID)ComputeOffset(offsets), &data[0], sizeof(T) * data.size(), NULL)) {
33 return; 37 return;
34 } 38 }
39 // std::this_thread::sleep_for(10ms);
35 } 40 }
36 ThrowError(); 41 ThrowError();
37 } 42 }
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<int> lasers = {
13 0x03616, // Jungle 13 0x03616, // Jungle
14}; 14};
15 15
16std::vector<int> burnablePanels = {
17 0x17D9C, // Treehouse Yellow 7
18 0x17DC2, // Treehouse Yellow 8
19 0x17DC4, // Treehouse Yellow 9
20 0x00999, // Swamp Discontinuous 1
21 0x0099D, // Swamp Discontinuous 2
22 0x009A0, // Swamp Discontinuous 3
23 0x009A1, // Swamp Discontinuous 4
24 0x00007, // Swamp Rotation Tutorial 1
25 0x00008, // Swamp Rotation Tutorial 2
26 0x00009, // Swamp Rotation Tutorial 3
27 0x0000A, // Swamp Rotation Tutorial 4
28 0x28AC7, // Town Blue 1
29 0x28AC8, // Town Blue 2
30 0x28ACA, // Town Blue 3
31 0x28ACB, // Town Blue 4
32 0x28ACC, // Town Blue 5
33 0x17CF0, // Mill Discard
34};
35
16std::vector<int> tutorialPanels = { 36std::vector<int> tutorialPanels = {
17// 0x0A3B5, // Back Left 37// 0x0A3B5, // Back Left
18 0x0A3B2, // Back Right 38 0x0A3B2, // Back Right
@@ -49,9 +69,9 @@ std::vector<int> outsideTutorialPanels = {
49// 0x032F7, // Orchard Apple Tree 4 69// 0x032F7, // Orchard Apple Tree 4
50// 0x032FF, // Orchard Apple Tree 5 70// 0x032FF, // Orchard Apple Tree 5
51}; 71};
52 72
53std::vector<int> symmetryPanels = { 73std::vector<int> symmetryPanels = {
54// 0x3C12B, // Glass Factory Discard 74 0x3C12B, // Glass Factory Discard
55 0x01A54, // Glass Factory Entry 75 0x01A54, // Glass Factory Entry
56 0x00086, // Glass Factory Vertical Symmetry 1 76 0x00086, // Glass Factory Vertical Symmetry 1
57 0x00087, // Glass Factory Vertical Symmetry 2 77 0x00087, // Glass Factory Vertical Symmetry 2
@@ -97,11 +117,11 @@ std::vector<int> symmetryPanels = {
97 0x00A61, // Symmetry Island Laser Blue 1 117 0x00A61, // Symmetry Island Laser Blue 1
98 0x00A64, // Symmetry Island Laser Blue 2 118 0x00A64, // Symmetry Island Laser Blue 2
99 0x00A68, // Symmetry Island Laser Blue 3 119 0x00A68, // Symmetry Island Laser Blue 3
120 0x17CE7, // Desert Discard
121 0x0CC7B, // Desert Vault
100}; 122};
101 123
102std::vector<int> desertPanels = { 124std::vector<int> desertPanels = {
103// 0x17CE7, // Desert Discard
104// 0x0CC7B, // Desert Vault
105// 0x0339E, // Desert Vault Box 125// 0x0339E, // Desert Vault Box
106 0x00698, // Desert Surface 1 126 0x00698, // Desert Surface 1
107 0x0048F, // Desert Surface 2 127 0x0048F, // Desert Surface 2
@@ -172,7 +192,7 @@ std::vector<int> quarryPanels = {
172// 0x275ED, // Mill EP Door 192// 0x275ED, // Mill EP Door
173// 0x17CAC, // Mill Stairs Shortcut Door 193// 0x17CAC, // Mill Stairs Shortcut Door
174 0x03677, // Mill Stairs Control 194 0x03677, // Mill Stairs Control
175// 0x17CF0, // Mill Discard 195 0x17CF0, // Mill Discard
176// 0x17CC4, // Mill Elevator Control 196// 0x17CC4, // Mill Elevator Control
177 0x021D5, // Boathouse Ramp Activation Shapers 197 0x021D5, // Boathouse Ramp Activation Shapers
178 0x034D4, // Boathouse Ramp Activation Stars 198 0x034D4, // Boathouse Ramp Activation Stars
@@ -258,7 +278,7 @@ std::vector<int> treehousePanels = { //worked fine until I commented out pivotin
258 0x17E3C, // Treehouse Green 1 278 0x17E3C, // Treehouse Green 1
259 0x17E4D, // Treehouse Green 2 279 0x17E4D, // Treehouse Green 2
260 0x17E4F, // Treehouse Green 3 280 0x17E4F, // Treehouse Green 3
261// 0x17E52, // Treehouse Green 4 281// 0x17E52, // Treehouse Green 4 has to pivot
262 0x17E5B, // Treehouse Green 5 282 0x17E5B, // Treehouse Green 5
263 0x17E5F, // Treehouse Green 6 283 0x17E5F, // Treehouse Green 6
264 0x17E61, // Treehouse Green 7 284 0x17E61, // Treehouse Green 7
@@ -401,7 +421,7 @@ std::vector<int> junglePanels = {
401 0x00C3F, // Jungle Dots 4 421 0x00C3F, // Jungle Dots 4
402 0x00C41, // Jungle Dots 5 422 0x00C41, // Jungle Dots 5
403 0x014B2, // Jungle Dots 6 423 0x014B2, // Jungle Dots 6
404// 0x17CAB, // Jungle Pop - up Wall 424// 0x17CAB, // Jungle Pop-up Wall
405// 0x337FA, // Jungle Shortcut 425// 0x337FA, // Jungle Shortcut
406}; 426};
407 427
@@ -548,6 +568,8 @@ std::vector<int> pillars = {
548 0x09E5A, // Mountain 3 Right Pillar 3 568 0x09E5A, // Mountain 3 Right Pillar 3
549 0x33961, // Mountain 3 Right Pillar 4 569 0x33961, // Mountain 3 Right Pillar 4
550 0x09DD5, // UTM Challenge Pillar 570 0x09DD5, // UTM Challenge Pillar
571// 0x1C31A, // Challenge Left Pillar
572// 0x1C319, // Challenge Right Pillar
551}; 573};
552 574
553std::vector<int> mountainMultipanel = { 575std::vector<int> 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 @@
2 * BUGS: 2 * BUGS:
3 * Bunker has physical panel objects which I can't move :( 3 * Bunker has physical panel objects which I can't move :(
4 * Shipwreck vault does not copy well 4 * Shipwreck vault does not copy well
5 * Pillars can be swapped but they don't zoom you out enough. Maybe SWAP_DISTANCE?
6 * FEATURES: 5 * FEATURES:
7 * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?) 6 * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?)
8 * Randomize audio logs 7 * Randomize audio logs
9 * Separate panels out by "square", which can probably be anywhere
10 * List of panels which can be valid "Burn" (aka desert) substitutes: Prevent (or limit) panel counting 8 * List of panels which can be valid "Burn" (aka desert) substitutes: Prevent (or limit) panel counting
11 * List of panels which split left/right (for left/right controls) 9 * List of panels which split left/right (for left/right controls)
12 * List of panels which split up/down (for up/down controls) 10 * List of panels which split up/down (for up/down controls)
@@ -62,17 +60,39 @@ int main(int argc, char** argv)
62 int PILLAR_L_1 = 0x383D; 60 int PILLAR_L_1 = 0x383D;
63 int PILLAR_L_4 = 0x339BB; 61 int PILLAR_L_4 = 0x339BB;
64 int PILLAR_C = 0x9DD5; 62 int PILLAR_C = 0x9DD5;
63 int PILLAR_C_L = 0x1C31A;
64 int DESERT_1 = 0x00698;
65 int DESERT_L_2 = 0x006E3;
66 int TOWN_S_1 = 0x28AC7;
65 67
66 randomizer.SwapPanels(PILLAR_L_1, PILLAR_C, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE); 68 std::vector<int> squarePanels;
69 for (auto panelSet : {outsideTutorialPanels, symmetryPanels, quarryPanels, keepPanels, townPanels, bunkerPanels, swampPanels, mountainPanels, utmPanels, treehousePanels}) {
70 squarePanels.insert(squarePanels.end(), panelSet.begin(), panelSet.end());
71 }
72 for (int panel : squarePanels) {
73 randomizer.SwapPanels(DESERT_L_2, panel, SWAP_LINES | SWAP_STYLE);
74 }
75
76
77 //randomizer.SwapPanels(PILLAR_L_1, PILLAR_C_L, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE);
78 //randomizer.SwapPanelData(PILLAR_L_1, PILLAR_C_L, 0x200, 0x50);
79 // Turn on the panel
80 //randomizer._memory.WriteData<float>({0x5B28C0, 0x18, PILLAR_L_1*8, 0x2A8}, {1.0f, 1.0f});
81
82 // randomizer.SwapPanels(PILLAR_L_1, PILLAR_C_L, SWAP_LINES | SWAP_STYLE | SWAP_BACK_DISTANCE);
67 //*/ 83 //*/
68} 84}
69 85
70WitnessRandomizer::WitnessRandomizer() : _memory(Memory("witness64_d3d11.exe")) 86WitnessRandomizer::WitnessRandomizer() : _memory("witness64_d3d11.exe")
71{ 87{
72 // Turn off desert flood final 88 // Turn off desert flood final
73 _memory.WriteData<float>({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f, 0.0f}); 89 _memory.WriteData<float>({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f, 0.0f});
74 // Change desert floating target to desert flood final 90 // Change desert floating target to desert flood final
75 _memory.WriteData<int>({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077}); 91 _memory.WriteData<int>({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077});
92 // Explicitly set back-off distance for the challenge entry & final 2 pillars
93 _memory.WriteData<float>({0x5B28C0, 0x18, 0x9DD5*8, 0x22C}, {2.5f});
94 _memory.WriteData<float>({0x5B28C0, 0x18, 0x1C31A*8, 0x22C}, {3.0f});
95 _memory.WriteData<float>({0x5B28C0, 0x18, 0x1C319*8, 0x22C}, {3.0f});
76} 96}
77 97
78void WitnessRandomizer::Randomize(std::vector<int> panels, int flags) { 98void WitnessRandomizer::Randomize(std::vector<int> panels, int flags) {
@@ -95,7 +115,7 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
95 } 115 }
96 if (flags & SWAP_LINES) { 116 if (flags & SWAP_LINES) {
97 offsets[0x230] = 16; // traced_edges 117 offsets[0x230] = 16; // traced_edges
98// offsets[0x220] = sizeof(void*); // *pattern_name 118 offsets[0x220] = sizeof(void*); // *pattern_name
99// offsets[0x240] = sizeof(void*); // *mesh_name 119// offsets[0x240] = sizeof(void*); // *mesh_name
100 offsets[0x2FC] = sizeof(int); // is_cylinder 120 offsets[0x2FC] = sizeof(int); // is_cylinder
101 offsets[0x300] = sizeof(float); // cylinder_z0 121 offsets[0x300] = sizeof(float); // cylinder_z0
@@ -104,6 +124,8 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
104// offsets[0x35C] = sizeof(int); // solvable_from_behind 124// offsets[0x35C] = sizeof(int); // solvable_from_behind
105 125
106// offsets[0x30C] = sizeof(float); // uv_to_world_scale 126// offsets[0x30C] = sizeof(float); // uv_to_world_scale
127 offsets[0x398] = sizeof(float); // specular_add
128 offsets[0x39C] = sizeof(int); // specular_power
107 offsets[0x3A4] = sizeof(float); // path_width_scale 129 offsets[0x3A4] = sizeof(float); // path_width_scale
108 offsets[0x3A8] = sizeof(float); // startpoint_scale 130 offsets[0x3A8] = sizeof(float); // startpoint_scale
109 offsets[0x3B8] = sizeof(int); // num_dots 131 offsets[0x3B8] = sizeof(int); // num_dots
@@ -112,6 +134,7 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
112 offsets[0x3D0] = sizeof(void*); // *dot_flags 134 offsets[0x3D0] = sizeof(void*); // *dot_flags
113 offsets[0x3D8] = sizeof(void*); // *dot_connection_a 135 offsets[0x3D8] = sizeof(void*); // *dot_connection_a
114 offsets[0x3E0] = sizeof(void*); // *dot_connection_b 136 offsets[0x3E0] = sizeof(void*); // *dot_connection_b
137// offsets[0x3E8] = sizeof(int); // randomize_on_power_on
115 offsets[0x420] = sizeof(void*); // *decorations 138 offsets[0x420] = sizeof(void*); // *decorations
116 offsets[0x428] = sizeof(void*); // *decoration_flags 139 offsets[0x428] = sizeof(void*); // *decoration_flags
117 offsets[0x438] = sizeof(int); // num_decorations 140 offsets[0x438] = sizeof(int); // num_decorations
@@ -173,8 +196,8 @@ void WitnessRandomizer::SwapPanelData(int panel1, int panel2, int finalOffset, i
173 std::vector<int> panel2Offset = {0x5B28C0, 0x18, panel2*8, finalOffset}; 196 std::vector<int> panel2Offset = {0x5B28C0, 0x18, panel2*8, finalOffset};
174 197
175 std::vector<byte> panel1Data = _memory.ReadData<byte>(panel1Offset, dataSize); 198 std::vector<byte> panel1Data = _memory.ReadData<byte>(panel1Offset, dataSize);
176 std::vector<byte> panel2Data = _memory.ReadData<byte>(panel2Offset, dataSize); 199 //std::vector<byte> panel2Data = _memory.ReadData<byte>(panel2Offset, dataSize);
177 200
178 _memory.WriteData<byte>(panel2Offset, panel1Data); 201 _memory.WriteData<byte>(panel2Offset, panel1Data);
179 _memory.WriteData<byte>(panel1Offset, panel2Data); 202 //_memory.WriteData<byte>(panel1Offset, panel2Data);
180} 203}
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:
13 void Randomize(std::vector<int> panels, int flags); 13 void Randomize(std::vector<int> panels, int flags);
14 void SwapPanels(int panel1, int panel2, int flags); 14 void SwapPanels(int panel1, int panel2, int flags);
15 15
16private: 16//private:
17 void SwapPanelData(int panel1, int panel2, int finalOffset, int dataSize); 17 void SwapPanelData(int panel1, int panel2, int finalOffset, int dataSize);
18 18
19 Memory _memory; 19 Memory _memory;