diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-08-21 17:18:02 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-08-21 17:18:02 -0400 |
commit | ba04ac934dea549497e2e89fa7a9e5bc8723f5f8 (patch) | |
tree | f852810377bfe663dfd73bedfaaf4dca8c657f37 /Source/Randomizer.cpp | |
parent | c60df0e75e63f488d94fd744ad70df8124dc7724 (diff) | |
download | witness-tutorializer-ba04ac934dea549497e2e89fa7a9e5bc8723f5f8.tar.gz witness-tutorializer-ba04ac934dea549497e2e89fa7a9e5bc8723f5f8.tar.bz2 witness-tutorializer-ba04ac934dea549497e2e89fa7a9e5bc8723f5f8.zip |
Cleaned up a bunch of stuff I'm not using
Diffstat (limited to 'Source/Randomizer.cpp')
-rw-r--r-- | Source/Randomizer.cpp | 251 |
1 files changed, 8 insertions, 243 deletions
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 74166af..5239cd6 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp | |||
@@ -93,7 +93,6 @@ Things to do for V2: | |||
93 | */ | 93 | */ |
94 | #include "pch.h" | 94 | #include "pch.h" |
95 | #include "Randomizer.h" | 95 | #include "Randomizer.h" |
96 | #include "ChallengeRandomizer.h" | ||
97 | #include "Panels.h" | 96 | #include "Panels.h" |
98 | #include "Random.h" | 97 | #include "Random.h" |
99 | 98 | ||
@@ -124,14 +123,6 @@ void Randomizer::Randomize() { | |||
124 | } | 123 | } |
125 | _memory->WriteData<byte>({index}, {0xEB}); // jz -> jmp | 124 | _memory->WriteData<byte>({index}, {0xEB}); // jz -> jmp |
126 | }); | 125 | }); |
127 | // Sig scans will be run during challenge randomization. | ||
128 | |||
129 | // Seed challenge first for future-proofing | ||
130 | MEMORY_CATCH(RandomizeChallenge()); | ||
131 | |||
132 | // Content swaps -- must happen before squarePanels | ||
133 | //MEMORY_CATCH(Randomize(upDownPanels, SWAP::LINES | SWAP::COLORS)); | ||
134 | //MEMORY_CATCH(Randomize(leftForwardRightPanels, SWAP::LINES | SWAP::COLORS)); | ||
135 | 126 | ||
136 | // Tutorial Bend | 127 | // Tutorial Bend |
137 | for (int panel : utmPerspective) { | 128 | for (int panel : utmPerspective) { |
@@ -141,220 +132,23 @@ void Randomizer::Randomize() { | |||
141 | for (int panel : squarePanels) { | 132 | for (int panel : squarePanels) { |
142 | Tutorialise(panel, 0x00064); | 133 | Tutorialise(panel, 0x00064); |
143 | } | 134 | } |
144 | //Randomize(squarePanels, SWAP::LINES | SWAP::COLORS); | ||
145 | |||
146 | // Individual area modifications | ||
147 | MEMORY_CATCH(RandomizeTutorial()); | ||
148 | MEMORY_CATCH(RandomizeDesert()); | ||
149 | MEMORY_CATCH(RandomizeQuarry()); | ||
150 | MEMORY_CATCH(RandomizeTreehouse()); | ||
151 | MEMORY_CATCH(RandomizeKeep()); | ||
152 | MEMORY_CATCH(RandomizeShadows()); | ||
153 | MEMORY_CATCH(RandomizeMonastery()); | ||
154 | MEMORY_CATCH(RandomizeBunker()); | ||
155 | MEMORY_CATCH(RandomizeJungle()); | ||
156 | MEMORY_CATCH(RandomizeSwamp()); | ||
157 | MEMORY_CATCH(RandomizeMountain()); | ||
158 | MEMORY_CATCH(RandomizeTown()); | ||
159 | MEMORY_CATCH(RandomizeSymmetry()); | ||
160 | // RandomizeAudioLogs(); | ||
161 | } | ||
162 | |||
163 | void Randomizer::AdjustSpeed() { | ||
164 | // Desert Surface Final Control | ||
165 | _memory->WriteEntityData<float>(0x09F95, OPEN_RATE, {0.04f}); // 4x | ||
166 | // Swamp Sliding Bridge | ||
167 | _memory->WriteEntityData<float>(0x0061A, OPEN_RATE, {0.1f}); // 4x | ||
168 | // Mountain 2 Elevator | ||
169 | _memory->WriteEntityData<float>(0x09EEC, OPEN_RATE, {0.075f}); // 3x | ||
170 | } | ||
171 | |||
172 | void Randomizer::RandomizeLasers() { | ||
173 | Randomize(lasers, SWAP::TARGETS); | ||
174 | // Read the target of keep front laser, and write it to keep back laser. | ||
175 | std::vector<int> keepFrontLaserTarget = _memory->ReadEntityData<int>(0x0360E, TARGET, 1); | ||
176 | _memory->WriteEntityData<int>(0x03317, TARGET, keepFrontLaserTarget); | ||
177 | } | ||
178 | 135 | ||
179 | void Randomizer::PreventSnipes() | ||
180 | { | ||
181 | // Distance-gate swamp snipe 1 to prevent RNG swamp snipe | ||
182 | //_memory->WriteEntityData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); | ||
183 | // Distance-gate shadows laser to prevent sniping through the bars | ||
184 | //_memory->WriteEntityData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); | ||
185 | } | ||
186 | |||
187 | // Private methods | ||
188 | void Randomizer::RandomizeTutorial() { | ||
189 | // Disable tutorial cursor speed modifications (not working?) | 136 | // Disable tutorial cursor speed modifications (not working?) |
190 | _memory->WriteEntityData<float>(0x00295, CURSOR_SPEED_SCALE, {1.0}); | 137 | _memory->WriteEntityData<float>(0x00295, CURSOR_SPEED_SCALE, { 1.0 }); |
191 | _memory->WriteEntityData<float>(0x0C373, CURSOR_SPEED_SCALE, {1.0}); | 138 | _memory->WriteEntityData<float>(0x0C373, CURSOR_SPEED_SCALE, { 1.0 }); |
192 | _memory->WriteEntityData<float>(0x00293, CURSOR_SPEED_SCALE, {1.0}); | 139 | _memory->WriteEntityData<float>(0x00293, CURSOR_SPEED_SCALE, { 1.0 }); |
193 | _memory->WriteEntityData<float>(0x002C2, CURSOR_SPEED_SCALE, {1.0}); | 140 | _memory->WriteEntityData<float>(0x002C2, CURSOR_SPEED_SCALE, { 1.0 }); |
194 | } | ||
195 | |||
196 | void Randomizer::RandomizeSymmetry() { | ||
197 | /*std::vector<int> randomOrder(transparent.size(), 0); | ||
198 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
199 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); | ||
200 | ReassignTargets(transparent, randomOrder);*/ | ||
201 | } | ||
202 | |||
203 | void Randomizer::RandomizeDesert() { | ||
204 | //Randomize(desertPanels, SWAP::LINES); | ||
205 | |||
206 | // Turn off desert surface 8 | ||
207 | /*_memory->WriteEntityData<float>(0x09F94, POWER, {0.0, 0.0}); | ||
208 | // Turn off desert flood final | ||
209 | _memory->WriteEntityData<float>(0x18076, POWER, {0.0, 0.0}); | ||
210 | // Change desert floating target to desert flood final | ||
211 | _memory->WriteEntityData<int>(0x17ECA, TARGET, {0x18077});*/ | ||
212 | } | ||
213 | |||
214 | void Randomizer::RandomizeQuarry() { | ||
215 | } | ||
216 | 141 | ||
217 | void Randomizer::RandomizeTreehouse() { | ||
218 | // Ensure that whatever pivot panels we have are flagged as "pivotable" | 142 | // Ensure that whatever pivot panels we have are flagged as "pivotable" |
219 | // @Bug: Can return {}, be careful! | 143 | // @Bug: Can return {}, be careful! |
220 | int panelFlags = _memory->ReadEntityData<int>(0x17DD1, STYLE_FLAGS, 1)[0]; | 144 | int panelFlags = _memory->ReadEntityData<int>(0x17DD1, STYLE_FLAGS, 1)[0]; |
221 | _memory->WriteEntityData<int>(0x17DD1, STYLE_FLAGS, {panelFlags | 0x8000}); | 145 | _memory->WriteEntityData<int>(0x17DD1, STYLE_FLAGS, { panelFlags | 0x8000 }); |
222 | panelFlags = _memory->ReadEntityData<int>(0x17CE3, STYLE_FLAGS, 1)[0]; | 146 | panelFlags = _memory->ReadEntityData<int>(0x17CE3, STYLE_FLAGS, 1)[0]; |
223 | _memory->WriteEntityData<int>(0x17CE3, STYLE_FLAGS, {panelFlags | 0x8000}); | 147 | _memory->WriteEntityData<int>(0x17CE3, STYLE_FLAGS, { panelFlags | 0x8000 }); |
224 | panelFlags = _memory->ReadEntityData<int>(0x17DB7, STYLE_FLAGS, 1)[0]; | 148 | panelFlags = _memory->ReadEntityData<int>(0x17DB7, STYLE_FLAGS, 1)[0]; |
225 | _memory->WriteEntityData<int>(0x17DB7, STYLE_FLAGS, {panelFlags | 0x8000}); | 149 | _memory->WriteEntityData<int>(0x17DB7, STYLE_FLAGS, { panelFlags | 0x8000 }); |
226 | panelFlags = _memory->ReadEntityData<int>(0x17E52, STYLE_FLAGS, 1)[0]; | 150 | panelFlags = _memory->ReadEntityData<int>(0x17E52, STYLE_FLAGS, 1)[0]; |
227 | _memory->WriteEntityData<int>(0x17E52, STYLE_FLAGS, {panelFlags | 0x8000}); | 151 | _memory->WriteEntityData<int>(0x17E52, STYLE_FLAGS, { panelFlags | 0x8000 }); |
228 | } | ||
229 | |||
230 | void Randomizer::RandomizeKeep() { | ||
231 | } | ||
232 | |||
233 | void Randomizer::RandomizeShadows() { | ||
234 | // Change the shadows tutorial cable to only activate avoid | ||
235 | _memory->WriteEntityData<int>(0x319A8, CABLE_TARGET_2, {0}); | ||
236 | // Change shadows avoid 8 to power shadows follow | ||
237 | _memory->WriteEntityData<int>(0x1972F, TARGET, {0x1C34C}); | ||
238 | |||
239 | /*std::vector<int> randomOrder(shadowsPanels.size(), 0); | ||
240 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
241 | RandomizeRange(randomOrder, SWAP::NONE, 0, 8); // Tutorial | ||
242 | RandomizeRange(randomOrder, SWAP::NONE, 8, 16); // Avoid | ||
243 | RandomizeRange(randomOrder, SWAP::NONE, 16, 21); // Follow | ||
244 | ReassignTargets(shadowsPanels, randomOrder); | ||
245 | // Turn off original starting panel | ||
246 | _memory->WriteEntityData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); | ||
247 | // Turn on new starting panel | ||
248 | _memory->WriteEntityData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});*/ | ||
249 | } | ||
250 | |||
251 | void Randomizer::RandomizeTown() { | ||
252 | // @Hack...? To open the gate at the end | ||
253 | /*std::vector<int> randomOrder(orchard.size() + 1, 0); | ||
254 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
255 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); | ||
256 | // Ensure that we open the gate before the final puzzle (by swapping) | ||
257 | int panel3Index = find(randomOrder, 3); | ||
258 | int panel4Index = find(randomOrder, 4); | ||
259 | randomOrder[std::min(panel3Index, panel4Index)] = 3; | ||
260 | randomOrder[std::max(panel3Index, panel4Index)] = 4; | ||
261 | ReassignTargets(orchard, randomOrder);*/ | ||
262 | } | ||
263 | |||
264 | void Randomizer::RandomizeMonastery() { | ||
265 | /*std::vector<int> randomOrder(monasteryPanels.size(), 0); | ||
266 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
267 | RandomizeRange(randomOrder, SWAP::NONE, 3, 9); // Outer 2 & 3, Inner 1-4 | ||
268 | ReassignTargets(monasteryPanels, randomOrder);*/ | ||
269 | } | ||
270 | |||
271 | void Randomizer::RandomizeBunker() { | ||
272 | /*std::vector<int> randomOrder(bunkerPanels.size(), 0); | ||
273 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
274 | // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 | ||
275 | // Tutorial 1 cannot be randomized, since no other panel can start on | ||
276 | // Glass 1 will become door + glass 1, due to the targetting system | ||
277 | RandomizeRange(randomOrder, SWAP::NONE, 1, 10); | ||
278 | // Randomize Glass 1-3 into everything after the door/glass 1 | ||
279 | const size_t glass1Index = find(randomOrder, 9); | ||
280 | RandomizeRange(randomOrder, SWAP::NONE, glass1Index + 1, 12); | ||
281 | ReassignTargets(bunkerPanels, randomOrder);*/ | ||
282 | } | ||
283 | |||
284 | void Randomizer::RandomizeJungle() { | ||
285 | /*std::vector<int> randomOrder(junglePanels.size(), 0); | ||
286 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
287 | // Waves 1 cannot be randomized, since no other panel can start on | ||
288 | RandomizeRange(randomOrder, SWAP::NONE, 1, 7); // Waves 2-7 | ||
289 | RandomizeRange(randomOrder, SWAP::NONE, 8, 13); // Pitches 1-6 | ||
290 | ReassignTargets(junglePanels, randomOrder);*/ | ||
291 | |||
292 | // Fix the wall's target to point back to the cable, and the cable to point to the pitches panel. | ||
293 | // auto wallTarget = _memory->ReadPanelData<int>(junglePanels[7], TARGET, 1); | ||
294 | // _memory->WritePanelData<int>(junglePanels[7], TARGET, {0x3C113}); | ||
295 | // _memory->WritePanelData<int>(0x3C112, CABLE_TARGET_1, wallTarget); | ||
296 | } | ||
297 | |||
298 | void Randomizer::RandomizeSwamp() { | ||
299 | } | ||
300 | |||
301 | void Randomizer::RandomizeMountain() { | ||
302 | // Randomize multipanel | ||
303 | //Randomize(mountainMultipanel, SWAP::LINES | SWAP::COLORS); | ||
304 | |||
305 | // Randomize final pillars order | ||
306 | /*std::vector<int> targets = {pillars[0] + 1}; | ||
307 | for (const int pillar : pillars) { | ||
308 | int target = _memory->ReadEntityData<int>(pillar, TARGET, 1)[0]; | ||
309 | targets.push_back(target); | ||
310 | } | ||
311 | targets[5] = pillars[5] + 1; | ||
312 | |||
313 | std::vector<int> randomOrder(pillars.size(), 0); | ||
314 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
315 | RandomizeRange(randomOrder, SWAP::NONE, 0, 4); // Left Pillars 1-4 | ||
316 | RandomizeRange(randomOrder, SWAP::NONE, 5, 9); // Right Pillars 1-4 | ||
317 | ReassignTargets(pillars, randomOrder, targets); | ||
318 | // Turn off original starting panels | ||
319 | _memory->WriteEntityData<float>(pillars[0], POWER, {0.0f, 0.0f}); | ||
320 | _memory->WriteEntityData<float>(pillars[5], POWER, {0.0f, 0.0f}); | ||
321 | // Turn on new starting panels | ||
322 | _memory->WriteEntityData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); | ||
323 | _memory->WriteEntityData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f});*/ | ||
324 | } | ||
325 | |||
326 | void Randomizer::RandomizeChallenge() { | ||
327 | /*ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block | ||
328 | for (int panel : challengePanels) { | ||
329 | _memory->WriteEntityData<int>(panel, POWER_OFF_ON_FAIL, {0}); | ||
330 | }*/ | ||
331 | } | ||
332 | |||
333 | void Randomizer::RandomizeAudioLogs() { | ||
334 | std::vector<int> randomOrder(audiologs.size(), 0); | ||
335 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | ||
336 | Randomize(randomOrder, SWAP::NONE); | ||
337 | ReassignNames(audiologs, randomOrder); | ||
338 | } | ||
339 | |||
340 | void Randomizer::Randomize(std::vector<int>& panels, int flags) { | ||
341 | return RandomizeRange(panels, flags, 0, panels.size()); | ||
342 | } | ||
343 | |||
344 | // Range is [start, end) | ||
345 | void Randomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex) { | ||
346 | if (panels.size() == 0) return; | ||
347 | if (startIndex >= endIndex) return; | ||
348 | if (endIndex >= panels.size()) endIndex = static_cast<int>(panels.size()); | ||
349 | for (size_t i = 0; i < panels.size(); i++) { | ||
350 | /*const int target = Random::RandInt(static_cast<int>(startIndex), static_cast<int>(i)); | ||
351 | if (i != target) { | ||
352 | // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; | ||
353 | SwapPanels(panels[i], panels[target], flags); | ||
354 | //std::swap(panels[i], panels[target]); // Panel indices in the array | ||
355 | }*/ | ||
356 | |||
357 | } | ||
358 | } | 152 | } |
359 | 153 | ||
360 | void Randomizer::Tutorialise(int panel1, int tutorialStraight) { | 154 | void Randomizer::Tutorialise(int panel1, int tutorialStraight) { |
@@ -421,32 +215,3 @@ void Randomizer::Tutorialise(int panel1, int tutorialStraight) { | |||
421 | //arrays.push_back(SPECULAR_TEXTURE); | 215 | //arrays.push_back(SPECULAR_TEXTURE); |
422 | 216 | ||
423 | } | 217 | } |
424 | |||
425 | void Randomizer::ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets) { | ||
426 | if (targets.empty()) { | ||
427 | // This list is offset by 1, so the target of the Nth panel is in position N (aka the N+1th element) | ||
428 | // The first panel may not have a wire to power it, so we use the panel ID itself. | ||
429 | targets = {panels[0] + 1}; | ||
430 | for (const int panel : panels) { | ||
431 | int target = _memory->ReadEntityData<int>(panel, TARGET, 1)[0]; | ||
432 | targets.push_back(target); | ||
433 | } | ||
434 | } | ||
435 | |||
436 | for (size_t i=0; i<order.size() - 1; i++) { | ||
437 | // Set the target of order[i] to order[i+1], using the "real" target as determined above. | ||
438 | const int panelTarget = targets[order[i+1]]; | ||
439 | _memory->WriteEntityData<int>(panels[order[i]], TARGET, {panelTarget}); | ||
440 | } | ||
441 | } | ||
442 | |||
443 | void Randomizer::ReassignNames(const std::vector<int>& panels, const std::vector<int>& order) { | ||
444 | std::vector<int64_t> names; | ||
445 | for (const int panel : panels) { | ||
446 | names.push_back(_memory->ReadEntityData<int64_t>(panel, AUDIO_LOG_NAME, 1)[0]); | ||
447 | } | ||
448 | |||
449 | for (int i=0; i<panels.size(); i++) { | ||
450 | _memory->WriteEntityData<int64_t>(panels[i], AUDIO_LOG_NAME, {names[order[i]]}); | ||
451 | } | ||
452 | } | ||