diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2021-08-21 16:55:00 -0400 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2021-08-21 16:55:00 -0400 |
commit | 02327bf40bb9f6ef8d5e17fa982da70a3fe93eb4 (patch) | |
tree | 35cbc1452dc1f6d45b26a179474f5c4732e18bb5 /Source | |
parent | b8d472ff024ad5b13dfe0c33ae10d5fdf8a2c4cc (diff) | |
download | witness-tutorializer-02327bf40bb9f6ef8d5e17fa982da70a3fe93eb4.tar.gz witness-tutorializer-02327bf40bb9f6ef8d5e17fa982da70a3fe93eb4.tar.bz2 witness-tutorializer-02327bf40bb9f6ef8d5e17fa982da70a3fe93eb4.zip |
Implemented tutorialisation stuff
Diffstat (limited to 'Source')
-rw-r--r-- | Source/Memory.h | 25 | ||||
-rw-r--r-- | Source/Panels.h | 150 | ||||
-rw-r--r-- | Source/Randomizer.cpp | 196 | ||||
-rw-r--r-- | Source/Randomizer.h | 2 |
4 files changed, 270 insertions, 103 deletions
diff --git a/Source/Memory.h b/Source/Memory.h index 1724251..e924bb9 100644 --- a/Source/Memory.h +++ b/Source/Memory.h | |||
@@ -55,6 +55,31 @@ public: | |||
55 | void AddSigScan(const std::vector<byte>& scanBytes, const std::function<void(int index)>& scanFunc); | 55 | void AddSigScan(const std::vector<byte>& scanBytes, const std::function<void(int index)>& scanFunc); |
56 | int ExecuteSigScans(); | 56 | int ExecuteSigScans(); |
57 | 57 | ||
58 | template <typename T> | ||
59 | void CopyEntityData(int fromId, int toId, int offset, int size) { | ||
60 | WriteEntityData<T>(toId, offset, ReadEntityData<T>(fromId, offset, size)); | ||
61 | } | ||
62 | |||
63 | template <typename T> | ||
64 | void CopyArray(int fromId, int toId, int offset, int size) { | ||
65 | if (size == 0) { | ||
66 | WriteEntityData<uintptr_t>(toId, offset, { static_cast<uintptr_t>(0) }); | ||
67 | } | ||
68 | else { | ||
69 | WriteNewArray<T>(toId, offset, ReadArray<T>(fromId, offset, size)); | ||
70 | } | ||
71 | } | ||
72 | |||
73 | template <typename T> | ||
74 | void CopyArrayDynamicSize(int fromId, int toId, int arrayOffset, int sizeOffset) { | ||
75 | CopyArray<T>(fromId, toId, arrayOffset, ReadEntityData<int>(fromId, sizeOffset, sizeof(int))[0]); | ||
76 | } | ||
77 | |||
78 | template <class T> | ||
79 | void WritePanelData(int panel, int offset, const std::vector<T>& data) { | ||
80 | WriteData<T>({ GLOBALS, 0x18, panel * 8, offset }, data); | ||
81 | } | ||
82 | |||
58 | private: | 83 | private: |
59 | template<class T> | 84 | template<class T> |
60 | std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) { | 85 | std::vector<T> ReadData(const std::vector<int>& offsets, size_t numItems) { |
diff --git a/Source/Panels.h b/Source/Panels.h index 4a850ee..ec1686c 100644 --- a/Source/Panels.h +++ b/Source/Panels.h | |||
@@ -67,6 +67,13 @@ std::vector<int> leftForwardRightPanels = { | |||
67 | 0x17E52, // Treehouse Green 4 | 67 | 0x17E52, // Treehouse Green 4 |
68 | }; | 68 | }; |
69 | 69 | ||
70 | std::vector<int> utmPerspective = { | ||
71 | 0x288EA, // UTM Perspective 1 | ||
72 | 0x288FC, // UTM Perspective 2 | ||
73 | 0x289E7, // UTM Perspective 3 | ||
74 | 0x288AA, // UTM Perspective 4 | ||
75 | }; | ||
76 | |||
70 | std::vector<int> pillars = { | 77 | std::vector<int> pillars = { |
71 | 0x0383D, // Mountain 3 Left Pillar 1 | 78 | 0x0383D, // Mountain 3 Left Pillar 1 |
72 | 0x0383F, // Mountain 3 Left Pillar 2 | 79 | 0x0383F, // Mountain 3 Left Pillar 2 |
@@ -117,8 +124,8 @@ std::vector<int> mountainMultipanel = { | |||
117 | }; | 124 | }; |
118 | 125 | ||
119 | std::vector<int> squarePanels = { | 126 | std::vector<int> squarePanels = { |
120 | 0x00064, // Tutorial Straight | 127 | //0x00064, // Tutorial Straight |
121 | 0x00182, // Tutorial Bend | 128 | //0x00182, // Tutorial Bend |
122 | 0x0A3B2, // Tutorial Back Right | 129 | 0x0A3B2, // Tutorial Back Right |
123 | 0x00295, // Tutorial Center Left | 130 | 0x00295, // Tutorial Center Left |
124 | 0x00293, // Tutorial Front Center | 131 | 0x00293, // Tutorial Front Center |
@@ -433,6 +440,145 @@ std::vector<int> squarePanels = { | |||
433 | 0x0A16E, // UTM Challenge Entrance | 440 | 0x0A16E, // UTM Challenge Entrance |
434 | 0x039B4, // Tunnels Theater Catwalk | 441 | 0x039B4, // Tunnels Theater Catwalk |
435 | 0x09E85, // Tunnels Town Shortcut | 442 | 0x09E85, // Tunnels Town Shortcut |
443 | |||
444 | 0x00698, // Desert Surface 1 | ||
445 | 0x0048F, // Desert Surface 2 | ||
446 | 0x09F92, // Desert Surface 3 | ||
447 | 0x0A036, // Desert Surface 4 | ||
448 | 0x09DA6, // Desert Surface 5 | ||
449 | 0x0A049, // Desert Surface 6 | ||
450 | 0x0A053, // Desert Surface 7 | ||
451 | 0x09F94, // Desert Surface 8 | ||
452 | 0x00422, // Desert Light 1 | ||
453 | 0x006E3, // Desert Light 2 | ||
454 | 0x0A02D, // Desert Light 3 | ||
455 | 0x00C72, // Desert Pond 1 | ||
456 | 0x0129D, // Desert Pond 2 | ||
457 | 0x008BB, // Desert Pond 3 | ||
458 | 0x0078D, // Desert Pond 4 | ||
459 | 0x18313, // Desert Pond 5 | ||
460 | 0x04D18, // Desert Flood 1 | ||
461 | 0x01205, // Desert Flood 2 | ||
462 | 0x181AB, // Desert Flood 3 | ||
463 | 0x0117A, // Desert Flood 4 | ||
464 | 0x17ECA, // Desert Flood 5 | ||
465 | 0x18076, // Desert Flood Exit | ||
466 | 0x0A15C, // Desert Final Left Convex | ||
467 | 0x09FFF, // Desert Final Left Concave | ||
468 | 0x0A15F, // Desert Final Near | ||
469 | 0x012D7, // Desert Final Far | ||
470 | 0x09F7D, // Bunker Tutorial 1 | ||
471 | 0x09FDC, // Bunker Tutorial 2 | ||
472 | 0x09FF7, // Bunker Tutorial 3 | ||
473 | 0x09F82, // Bunker Tutorial 4 | ||
474 | 0x09FF8, // Bunker Tutorial 5 | ||
475 | 0x09D9F, // Bunker Advanced 1 | ||
476 | 0x09DA1, // Bunker Advanced 2 | ||
477 | 0x09DA2, // Bunker Advanced 3 | ||
478 | 0x09DAF, // Bunker Advanced 4 | ||
479 | // 0x0A099, // Bunker Glass Door | ||
480 | 0x0A010, // Bunker Glass 1 | ||
481 | 0x0A01B, // Bunker Glass 2 | ||
482 | 0x0A01F, // Bunker Glass 3 | ||
483 | 0x17E63, // Bunker Ultraviolet 1 | ||
484 | 0x17E67, // Bunker Ultraviolet 2 | ||
485 | 0x002C4, // Jungle Waves 1 | ||
486 | 0x00767, // Jungle Waves 2 | ||
487 | 0x002C6, // Jungle Waves 3 | ||
488 | 0x0070E, // Jungle Waves 4 | ||
489 | 0x0070F, // Jungle Waves 5 | ||
490 | 0x0087D, // Jungle Waves 6 | ||
491 | 0x002C7, // Jungle Waves 7 | ||
492 | // 0x17CAB, // Jungle Pop-up Wall | ||
493 | 0x0026D, // Jungle Dots 1 | ||
494 | 0x0026E, // Jungle Dots 2 | ||
495 | 0x0026F, // Jungle Dots 3 | ||
496 | 0x00C3F, // Jungle Dots 4 | ||
497 | 0x00C41, // Jungle Dots 5 | ||
498 | 0x014B2, // Jungle Dots 6 | ||
499 | 0x198B5, // Shadows Tutorial 1 | ||
500 | 0x198BD, // Shadows Tutorial 2 | ||
501 | 0x198BF, // Shadows Tutorial 3 | ||
502 | 0x19771, // Shadows Tutorial 4 | ||
503 | 0x0A8DC, // Shadows Tutorial 5 | ||
504 | 0x0AC74, // Shadows Tutorial 6 | ||
505 | 0x0AC7A, // Shadows Tutorial 7 | ||
506 | 0x0A8E0, // Shadows Tutorial 8 | ||
507 | 0x386FA, // Shadows Avoid 1 | ||
508 | 0x1C33F, // Shadows Avoid 2 | ||
509 | 0x196E2, // Shadows Avoid 3 | ||
510 | 0x1972A, // Shadows Avoid 4 | ||
511 | 0x19809, // Shadows Avoid 5 | ||
512 | 0x19806, // Shadows Avoid 6 | ||
513 | 0x196F8, // Shadows Avoid 7 | ||
514 | 0x1972F, // Shadows Avoid 8 | ||
515 | 0x19797, // Shadows Follow 1 | ||
516 | 0x1979A, // Shadows Follow 2 | ||
517 | 0x197E0, // Shadows Follow 3 | ||
518 | 0x197E8, // Shadows Follow 4 | ||
519 | 0x197E5, // Shadows Follow 5 | ||
520 | 0x19650, // Shadows Laser | ||
521 | |||
522 | 0x09FCC, // Mountain 2 Multipanel 1 | ||
523 | 0x09FCE, // Mountain 2 Multipanel 2 | ||
524 | 0x09FCF, // Mountain 2 Multipanel 3 | ||
525 | 0x09FD0, // Mountain 2 Multipanel 4 | ||
526 | 0x09FD1, // Mountain 2 Multipanel 5 | ||
527 | 0x09FD2, // Mountain 2 Multipanel 6 | ||
528 | |||
529 | 0x00290, // Monastery Exterior 1 | ||
530 | 0x00038, // Monastery Exterior 2 | ||
531 | 0x00037, // Monastery Exterior 3 | ||
532 | // 0x09D9B, // Monastery Bonsai | ||
533 | 0x193A7, // Monastery Interior 1 | ||
534 | 0x193AA, // Monastery Interior 2 | ||
535 | 0x193AB, // Monastery Interior 3 | ||
536 | 0x193A6, // Monastery Interior 4 | ||
537 | |||
538 | |||
539 | |||
540 | 0x03629, // Tutorial Gate Open | ||
541 | |||
542 | 0x0C373, // Tutorial Patio floor | ||
543 | 0x1C349, // Symmetry Island Door 2 - Collision fails here, sadly | ||
544 | |||
545 | 0x28A69, // Town Lattice | ||
546 | 0x28A79, // Town Maze | ||
547 | 0x28B39, // Town Red Hexagonal | ||
548 | |||
549 | 0x18590, // Town Transparent | ||
550 | 0x28AE3, // Town Wire | ||
551 | |||
552 | |||
553 | |||
554 | 0x0383D, // Mountain 3 Left Pillar 1 | ||
555 | 0x0383F, // Mountain 3 Left Pillar 2 | ||
556 | 0x03859, // Mountain 3 Left Pillar 3 | ||
557 | 0x339BB, // Mountain 3 Left Pillar 4 | ||
558 | |||
559 | 0x0383A, // Mountain 3 Right Pillar 1 | ||
560 | 0x09E56, // Mountain 3 Right Pillar 2 | ||
561 | 0x09E5A, // Mountain 3 Right Pillar 3 | ||
562 | 0x33961, // Mountain 3 Right Pillar 4 | ||
563 | |||
564 | 0x09DD5, // UTM Challenge Pillar | ||
565 | |||
566 | |||
567 | 0x09FD8, // Mountain 2 Rainbow 5 | ||
568 | 0x17CAA, // Jungle Courtyard Gate | ||
569 | 0x0005C, // Glass Factory Vertical Symmetry 5 | ||
570 | 0x17C31, // Desert Final Transparent | ||
571 | |||
572 | 0x00143, // Orchard Apple Tree 1 | ||
573 | 0x0003B, // Orchard Apple Tree 2 | ||
574 | 0x00055, // Orchard Apple Tree 3 | ||
575 | 0x032F7, // Orchard Apple Tree 4 | ||
576 | 0x032FF, // Orchard Apple Tree 5 | ||
577 | 0x009B8, // Symmetry Island Transparent 1 | ||
578 | 0x003E8, // Symmetry Island Transparent 2 | ||
579 | 0x00A15, // Symmetry Island Transparent 3 | ||
580 | 0x00B53, // Symmetry Island Transparent 4 | ||
581 | 0x00B8D, // Symmetry Island Transparent 5 | ||
436 | }; | 582 | }; |
437 | 583 | ||
438 | std::vector<int> desertPanels = { | 584 | std::vector<int> desertPanels = { |
diff --git a/Source/Randomizer.cpp b/Source/Randomizer.cpp index 72072a8..74166af 100644 --- a/Source/Randomizer.cpp +++ b/Source/Randomizer.cpp | |||
@@ -130,10 +130,18 @@ void Randomizer::Randomize() { | |||
130 | MEMORY_CATCH(RandomizeChallenge()); | 130 | MEMORY_CATCH(RandomizeChallenge()); |
131 | 131 | ||
132 | // Content swaps -- must happen before squarePanels | 132 | // Content swaps -- must happen before squarePanels |
133 | MEMORY_CATCH(Randomize(upDownPanels, SWAP::LINES | SWAP::COLORS)); | 133 | //MEMORY_CATCH(Randomize(upDownPanels, SWAP::LINES | SWAP::COLORS)); |
134 | MEMORY_CATCH(Randomize(leftForwardRightPanels, SWAP::LINES | SWAP::COLORS)); | 134 | //MEMORY_CATCH(Randomize(leftForwardRightPanels, SWAP::LINES | SWAP::COLORS)); |
135 | 135 | ||
136 | MEMORY_CATCH(Randomize(squarePanels, SWAP::LINES | SWAP::COLORS)); | 136 | // Tutorial Bend |
137 | for (int panel : utmPerspective) { | ||
138 | Tutorialise(panel, 0x00182); | ||
139 | } | ||
140 | // Tutorial Straight | ||
141 | for (int panel : squarePanels) { | ||
142 | Tutorialise(panel, 0x00064); | ||
143 | } | ||
144 | //Randomize(squarePanels, SWAP::LINES | SWAP::COLORS); | ||
137 | 145 | ||
138 | // Individual area modifications | 146 | // Individual area modifications |
139 | MEMORY_CATCH(RandomizeTutorial()); | 147 | MEMORY_CATCH(RandomizeTutorial()); |
@@ -171,9 +179,9 @@ void Randomizer::RandomizeLasers() { | |||
171 | void Randomizer::PreventSnipes() | 179 | void Randomizer::PreventSnipes() |
172 | { | 180 | { |
173 | // Distance-gate swamp snipe 1 to prevent RNG swamp snipe | 181 | // Distance-gate swamp snipe 1 to prevent RNG swamp snipe |
174 | _memory->WriteEntityData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); | 182 | //_memory->WriteEntityData<float>(0x17C05, MAX_BROADCAST_DISTANCE, {15.0}); |
175 | // Distance-gate shadows laser to prevent sniping through the bars | 183 | // Distance-gate shadows laser to prevent sniping through the bars |
176 | _memory->WriteEntityData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); | 184 | //_memory->WriteEntityData<float>(0x19650, MAX_BROADCAST_DISTANCE, {2.5}); |
177 | } | 185 | } |
178 | 186 | ||
179 | // Private methods | 187 | // Private methods |
@@ -186,21 +194,21 @@ void Randomizer::RandomizeTutorial() { | |||
186 | } | 194 | } |
187 | 195 | ||
188 | void Randomizer::RandomizeSymmetry() { | 196 | void Randomizer::RandomizeSymmetry() { |
189 | std::vector<int> randomOrder(transparent.size(), 0); | 197 | /*std::vector<int> randomOrder(transparent.size(), 0); |
190 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 198 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
191 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); | 199 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); |
192 | ReassignTargets(transparent, randomOrder); | 200 | ReassignTargets(transparent, randomOrder);*/ |
193 | } | 201 | } |
194 | 202 | ||
195 | void Randomizer::RandomizeDesert() { | 203 | void Randomizer::RandomizeDesert() { |
196 | Randomize(desertPanels, SWAP::LINES); | 204 | //Randomize(desertPanels, SWAP::LINES); |
197 | 205 | ||
198 | // Turn off desert surface 8 | 206 | // Turn off desert surface 8 |
199 | _memory->WriteEntityData<float>(0x09F94, POWER, {0.0, 0.0}); | 207 | /*_memory->WriteEntityData<float>(0x09F94, POWER, {0.0, 0.0}); |
200 | // Turn off desert flood final | 208 | // Turn off desert flood final |
201 | _memory->WriteEntityData<float>(0x18076, POWER, {0.0, 0.0}); | 209 | _memory->WriteEntityData<float>(0x18076, POWER, {0.0, 0.0}); |
202 | // Change desert floating target to desert flood final | 210 | // Change desert floating target to desert flood final |
203 | _memory->WriteEntityData<int>(0x17ECA, TARGET, {0x18077}); | 211 | _memory->WriteEntityData<int>(0x17ECA, TARGET, {0x18077});*/ |
204 | } | 212 | } |
205 | 213 | ||
206 | void Randomizer::RandomizeQuarry() { | 214 | void Randomizer::RandomizeQuarry() { |
@@ -228,7 +236,7 @@ void Randomizer::RandomizeShadows() { | |||
228 | // Change shadows avoid 8 to power shadows follow | 236 | // Change shadows avoid 8 to power shadows follow |
229 | _memory->WriteEntityData<int>(0x1972F, TARGET, {0x1C34C}); | 237 | _memory->WriteEntityData<int>(0x1972F, TARGET, {0x1C34C}); |
230 | 238 | ||
231 | std::vector<int> randomOrder(shadowsPanels.size(), 0); | 239 | /*std::vector<int> randomOrder(shadowsPanels.size(), 0); |
232 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 240 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
233 | RandomizeRange(randomOrder, SWAP::NONE, 0, 8); // Tutorial | 241 | RandomizeRange(randomOrder, SWAP::NONE, 0, 8); // Tutorial |
234 | RandomizeRange(randomOrder, SWAP::NONE, 8, 16); // Avoid | 242 | RandomizeRange(randomOrder, SWAP::NONE, 8, 16); // Avoid |
@@ -237,12 +245,12 @@ void Randomizer::RandomizeShadows() { | |||
237 | // Turn off original starting panel | 245 | // Turn off original starting panel |
238 | _memory->WriteEntityData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); | 246 | _memory->WriteEntityData<float>(shadowsPanels[0], POWER, {0.0f, 0.0f}); |
239 | // Turn on new starting panel | 247 | // Turn on new starting panel |
240 | _memory->WriteEntityData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f}); | 248 | _memory->WriteEntityData<float>(shadowsPanels[randomOrder[0]], POWER, {1.0f, 1.0f});*/ |
241 | } | 249 | } |
242 | 250 | ||
243 | void Randomizer::RandomizeTown() { | 251 | void Randomizer::RandomizeTown() { |
244 | // @Hack...? To open the gate at the end | 252 | // @Hack...? To open the gate at the end |
245 | std::vector<int> randomOrder(orchard.size() + 1, 0); | 253 | /*std::vector<int> randomOrder(orchard.size() + 1, 0); |
246 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 254 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
247 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); | 255 | RandomizeRange(randomOrder, SWAP::NONE, 1, 5); |
248 | // Ensure that we open the gate before the final puzzle (by swapping) | 256 | // Ensure that we open the gate before the final puzzle (by swapping) |
@@ -250,18 +258,18 @@ void Randomizer::RandomizeTown() { | |||
250 | int panel4Index = find(randomOrder, 4); | 258 | int panel4Index = find(randomOrder, 4); |
251 | randomOrder[std::min(panel3Index, panel4Index)] = 3; | 259 | randomOrder[std::min(panel3Index, panel4Index)] = 3; |
252 | randomOrder[std::max(panel3Index, panel4Index)] = 4; | 260 | randomOrder[std::max(panel3Index, panel4Index)] = 4; |
253 | ReassignTargets(orchard, randomOrder); | 261 | ReassignTargets(orchard, randomOrder);*/ |
254 | } | 262 | } |
255 | 263 | ||
256 | void Randomizer::RandomizeMonastery() { | 264 | void Randomizer::RandomizeMonastery() { |
257 | std::vector<int> randomOrder(monasteryPanels.size(), 0); | 265 | /*std::vector<int> randomOrder(monasteryPanels.size(), 0); |
258 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 266 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
259 | RandomizeRange(randomOrder, SWAP::NONE, 3, 9); // Outer 2 & 3, Inner 1-4 | 267 | RandomizeRange(randomOrder, SWAP::NONE, 3, 9); // Outer 2 & 3, Inner 1-4 |
260 | ReassignTargets(monasteryPanels, randomOrder); | 268 | ReassignTargets(monasteryPanels, randomOrder);*/ |
261 | } | 269 | } |
262 | 270 | ||
263 | void Randomizer::RandomizeBunker() { | 271 | void Randomizer::RandomizeBunker() { |
264 | std::vector<int> randomOrder(bunkerPanels.size(), 0); | 272 | /*std::vector<int> randomOrder(bunkerPanels.size(), 0); |
265 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 273 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
266 | // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 | 274 | // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 |
267 | // Tutorial 1 cannot be randomized, since no other panel can start on | 275 | // Tutorial 1 cannot be randomized, since no other panel can start on |
@@ -270,16 +278,16 @@ void Randomizer::RandomizeBunker() { | |||
270 | // Randomize Glass 1-3 into everything after the door/glass 1 | 278 | // Randomize Glass 1-3 into everything after the door/glass 1 |
271 | const size_t glass1Index = find(randomOrder, 9); | 279 | const size_t glass1Index = find(randomOrder, 9); |
272 | RandomizeRange(randomOrder, SWAP::NONE, glass1Index + 1, 12); | 280 | RandomizeRange(randomOrder, SWAP::NONE, glass1Index + 1, 12); |
273 | ReassignTargets(bunkerPanels, randomOrder); | 281 | ReassignTargets(bunkerPanels, randomOrder);*/ |
274 | } | 282 | } |
275 | 283 | ||
276 | void Randomizer::RandomizeJungle() { | 284 | void Randomizer::RandomizeJungle() { |
277 | std::vector<int> randomOrder(junglePanels.size(), 0); | 285 | /*std::vector<int> randomOrder(junglePanels.size(), 0); |
278 | std::iota(randomOrder.begin(), randomOrder.end(), 0); | 286 | std::iota(randomOrder.begin(), randomOrder.end(), 0); |
279 | // Waves 1 cannot be randomized, since no other panel can start on | 287 | // Waves 1 cannot be randomized, since no other panel can start on |
280 | RandomizeRange(randomOrder, SWAP::NONE, 1, 7); // Waves 2-7 | 288 | RandomizeRange(randomOrder, SWAP::NONE, 1, 7); // Waves 2-7 |
281 | RandomizeRange(randomOrder, SWAP::NONE, 8, 13); // Pitches 1-6 | 289 | RandomizeRange(randomOrder, SWAP::NONE, 8, 13); // Pitches 1-6 |
282 | ReassignTargets(junglePanels, randomOrder); | 290 | ReassignTargets(junglePanels, randomOrder);*/ |
283 | 291 | ||
284 | // Fix the wall's target to point back to the cable, and the cable to point to the pitches panel. | 292 | // Fix the wall's target to point back to the cable, and the cable to point to the pitches panel. |
285 | // auto wallTarget = _memory->ReadPanelData<int>(junglePanels[7], TARGET, 1); | 293 | // auto wallTarget = _memory->ReadPanelData<int>(junglePanels[7], TARGET, 1); |
@@ -292,10 +300,10 @@ void Randomizer::RandomizeSwamp() { | |||
292 | 300 | ||
293 | void Randomizer::RandomizeMountain() { | 301 | void Randomizer::RandomizeMountain() { |
294 | // Randomize multipanel | 302 | // Randomize multipanel |
295 | Randomize(mountainMultipanel, SWAP::LINES | SWAP::COLORS); | 303 | //Randomize(mountainMultipanel, SWAP::LINES | SWAP::COLORS); |
296 | 304 | ||
297 | // Randomize final pillars order | 305 | // Randomize final pillars order |
298 | std::vector<int> targets = {pillars[0] + 1}; | 306 | /*std::vector<int> targets = {pillars[0] + 1}; |
299 | for (const int pillar : pillars) { | 307 | for (const int pillar : pillars) { |
300 | int target = _memory->ReadEntityData<int>(pillar, TARGET, 1)[0]; | 308 | int target = _memory->ReadEntityData<int>(pillar, TARGET, 1)[0]; |
301 | targets.push_back(target); | 309 | targets.push_back(target); |
@@ -312,14 +320,14 @@ void Randomizer::RandomizeMountain() { | |||
312 | _memory->WriteEntityData<float>(pillars[5], POWER, {0.0f, 0.0f}); | 320 | _memory->WriteEntityData<float>(pillars[5], POWER, {0.0f, 0.0f}); |
313 | // Turn on new starting panels | 321 | // Turn on new starting panels |
314 | _memory->WriteEntityData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); | 322 | _memory->WriteEntityData<float>(pillars[randomOrder[0]], POWER, {1.0f, 1.0f}); |
315 | _memory->WriteEntityData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f}); | 323 | _memory->WriteEntityData<float>(pillars[randomOrder[5]], POWER, {1.0f, 1.0f});*/ |
316 | } | 324 | } |
317 | 325 | ||
318 | void Randomizer::RandomizeChallenge() { | 326 | void Randomizer::RandomizeChallenge() { |
319 | ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block | 327 | /*ChallengeRandomizer cr(_memory, Random::RandInt(1, 0x7FFFFFFF)); // 0 will trigger an "RNG not initialized" block |
320 | for (int panel : challengePanels) { | 328 | for (int panel : challengePanels) { |
321 | _memory->WriteEntityData<int>(panel, POWER_OFF_ON_FAIL, {0}); | 329 | _memory->WriteEntityData<int>(panel, POWER_OFF_ON_FAIL, {0}); |
322 | } | 330 | }*/ |
323 | } | 331 | } |
324 | 332 | ||
325 | void Randomizer::RandomizeAudioLogs() { | 333 | void Randomizer::RandomizeAudioLogs() { |
@@ -338,92 +346,80 @@ void Randomizer::RandomizeRange(std::vector<int> &panels, int flags, size_t star | |||
338 | if (panels.size() == 0) return; | 346 | if (panels.size() == 0) return; |
339 | if (startIndex >= endIndex) return; | 347 | if (startIndex >= endIndex) return; |
340 | if (endIndex >= panels.size()) endIndex = static_cast<int>(panels.size()); | 348 | if (endIndex >= panels.size()) endIndex = static_cast<int>(panels.size()); |
341 | for (size_t i = endIndex-1; i > startIndex; i--) { | 349 | for (size_t i = 0; i < panels.size(); i++) { |
342 | const int target = Random::RandInt(static_cast<int>(startIndex), static_cast<int>(i)); | 350 | /*const int target = Random::RandInt(static_cast<int>(startIndex), static_cast<int>(i)); |
343 | if (i != target) { | 351 | if (i != target) { |
344 | // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; | 352 | // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; |
345 | SwapPanels(panels[i], panels[target], flags); | 353 | SwapPanels(panels[i], panels[target], flags); |
346 | std::swap(panels[i], panels[target]); // Panel indices in the array | 354 | //std::swap(panels[i], panels[target]); // Panel indices in the array |
347 | } | 355 | }*/ |
356 | |||
348 | } | 357 | } |
349 | } | 358 | } |
350 | 359 | ||
351 | void Randomizer::SwapPanels(int panel1, int panel2, int flags) { | 360 | void Randomizer::Tutorialise(int panel1, int tutorialStraight) { |
352 | std::map<int, int> offsets; | 361 | //const int tutorialStraight = 0x00064; |
353 | 362 | ||
354 | if (flags & SWAP::TARGETS) { | 363 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PATH_COLOR, 16); |
355 | offsets[TARGET] = sizeof(int); | 364 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, REFLECTION_PATH_COLOR, 16); |
356 | } | 365 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, DOT_COLOR, 16); |
357 | if (flags & SWAP::AUDIO_NAMES) { | 366 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, ACTIVE_COLOR, 16); |
358 | offsets[AUDIO_LOG_NAME] = sizeof(void*); | 367 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, BACKGROUND_REGION_COLOR, 12); |
359 | } | 368 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SUCCESS_COLOR_A, 16); |
360 | if (flags & SWAP::COLORS) { | 369 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SUCCESS_COLOR_B, 16); |
361 | offsets[PATH_COLOR] = 16; | 370 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, STROBE_COLOR_A, 16); |
362 | offsets[REFLECTION_PATH_COLOR] = 16; | 371 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, STROBE_COLOR_B, 16); |
363 | offsets[DOT_COLOR] = 16; | 372 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, ERROR_COLOR, 16); |
364 | offsets[ACTIVE_COLOR] = 16; | 373 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PATTERN_POINT_COLOR, 16); |
365 | offsets[BACKGROUND_REGION_COLOR] = 12; // Not copying alpha to preserve transparency. | 374 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PATTERN_POINT_COLOR_A, 16); |
366 | offsets[SUCCESS_COLOR_A] = 16; | 375 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PATTERN_POINT_COLOR_B, 16); |
367 | offsets[SUCCESS_COLOR_B] = 16; | 376 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SYMBOL_A, 16); |
368 | offsets[STROBE_COLOR_A] = 16; | 377 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SYMBOL_B, 16); |
369 | offsets[STROBE_COLOR_B] = 16; | 378 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SYMBOL_C, 16); |
370 | offsets[ERROR_COLOR] = 16; | 379 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SYMBOL_D, 16); |
371 | offsets[PATTERN_POINT_COLOR] = 16; | 380 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SYMBOL_E, 16); |
372 | offsets[PATTERN_POINT_COLOR_A] = 16; | 381 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PUSH_SYMBOL_COLORS, sizeof(int)); |
373 | offsets[PATTERN_POINT_COLOR_B] = 16; | 382 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, OUTER_BACKGROUND, 16); |
374 | offsets[SYMBOL_A] = 16; | 383 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, OUTER_BACKGROUND_MODE, sizeof(int)); |
375 | offsets[SYMBOL_B] = 16; | 384 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, NUM_COLORED_REGIONS, sizeof(int)); |
376 | offsets[SYMBOL_C] = 16; | 385 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, COLORED_REGIONS, NUM_COLORED_REGIONS); |
377 | offsets[SYMBOL_D] = 16; | 386 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, TRACED_EDGES, 16); |
378 | offsets[SYMBOL_E] = 16; | 387 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, PATH_WIDTH_SCALE, sizeof(float)); |
379 | offsets[PUSH_SYMBOL_COLORS] = sizeof(int); | 388 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, STARTPOINT_SCALE, sizeof(float)); |
380 | offsets[OUTER_BACKGROUND] = 16; | 389 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, NUM_DOTS, sizeof(int)); |
381 | offsets[OUTER_BACKGROUND_MODE] = sizeof(int); | 390 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, NUM_CONNECTIONS, sizeof(int)); |
382 | // These two control the "burn intensity", but I can't swap out burn marks in new ver, so they should probably stay tied to each frame. | 391 | _memory->CopyArray<float>(tutorialStraight, panel1, DOT_POSITIONS, _memory->ReadEntityData<int>(tutorialStraight, NUM_DOTS, sizeof(int))[0]*2); |
383 | // offsets[SPECULAR_ADD] = sizeof(float); | 392 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DOT_FLAGS, NUM_DOTS); |
384 | // offsets[SPECULAR_POWER] = sizeof(int); | 393 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DOT_CONNECTION_A, NUM_CONNECTIONS); |
385 | offsets[NUM_COLORED_REGIONS] = sizeof(int); | 394 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DOT_CONNECTION_B, NUM_CONNECTIONS); |
386 | offsets[COLORED_REGIONS] = sizeof(void*); | 395 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, NUM_DECORATIONS, sizeof(int)); |
387 | } | 396 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DECORATIONS, NUM_DECORATIONS); |
388 | if (flags & SWAP::LINES) { | 397 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DECORATION_FLAGS, NUM_DECORATIONS); |
389 | offsets[TRACED_EDGES] = 16; | 398 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DECORATION_COLORS, NUM_DECORATIONS); |
390 | offsets[AUDIO_PREFIX] = sizeof(void*); | 399 | //_memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, REFLECTION_DATA, NUM_DOTS); |
400 | _memory->WritePanelData<long long>(panel1, REFLECTION_DATA, { 0 }); | ||
401 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, SEQUENCE_LEN, sizeof(int)); | ||
402 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, SEQUENCE, SEQUENCE_LEN); | ||
403 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, DOT_SEQUENCE_LEN, sizeof(int)); | ||
404 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DOT_SEQUENCE, DOT_SEQUENCE_LEN); | ||
405 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, DOT_SEQUENCE_LEN_REFLECTION, sizeof(int)); | ||
406 | _memory->CopyArrayDynamicSize<int>(tutorialStraight, panel1, DOT_SEQUENCE_REFLECTION, DOT_SEQUENCE_LEN_REFLECTION); | ||
407 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, GRID_SIZE_X, sizeof(int)); | ||
408 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, GRID_SIZE_Y, sizeof(int)); | ||
409 | _memory->CopyEntityData<byte>(tutorialStraight, panel1, STYLE_FLAGS, sizeof(int)); | ||
410 | |||
411 | |||
412 | |||
413 | |||
414 | //arrays.push_back(AUDIO_PREFIX); | ||
391 | // offsets[IS_CYLINDER] = sizeof(int); | 415 | // offsets[IS_CYLINDER] = sizeof(int); |
392 | // offsets[CYLINDER_Z0] = sizeof(float); | 416 | // offsets[CYLINDER_Z0] = sizeof(float); |
393 | // offsets[CYLINDER_Z1] = sizeof(float); | 417 | // offsets[CYLINDER_Z1] = sizeof(float); |
394 | // offsets[CYLINDER_RADIUS] = sizeof(float); | 418 | // offsets[CYLINDER_RADIUS] = sizeof(float); |
395 | offsets[PATH_WIDTH_SCALE] = sizeof(float); | ||
396 | offsets[STARTPOINT_SCALE] = sizeof(float); | ||
397 | offsets[NUM_DOTS] = sizeof(int); | ||
398 | offsets[NUM_CONNECTIONS] = sizeof(int); | ||
399 | offsets[DOT_POSITIONS] = sizeof(void*); | ||
400 | offsets[DOT_FLAGS] = sizeof(void*); | ||
401 | offsets[DOT_CONNECTION_A] = sizeof(void*); | ||
402 | offsets[DOT_CONNECTION_B] = sizeof(void*); | ||
403 | offsets[DECORATIONS] = sizeof(void*); | ||
404 | offsets[DECORATION_FLAGS] = sizeof(void*); | ||
405 | offsets[DECORATION_COLORS] = sizeof(void*); | ||
406 | offsets[NUM_DECORATIONS] = sizeof(int); | ||
407 | offsets[REFLECTION_DATA] = sizeof(void*); | ||
408 | offsets[GRID_SIZE_X] = sizeof(int); | ||
409 | offsets[GRID_SIZE_Y] = sizeof(int); | ||
410 | offsets[STYLE_FLAGS] = sizeof(int); | ||
411 | offsets[SEQUENCE_LEN] = sizeof(int); | ||
412 | offsets[SEQUENCE] = sizeof(void*); | ||
413 | offsets[DOT_SEQUENCE_LEN] = sizeof(int); | ||
414 | offsets[DOT_SEQUENCE] = sizeof(void*); | ||
415 | offsets[DOT_SEQUENCE_LEN_REFLECTION] = sizeof(int); | ||
416 | offsets[DOT_SEQUENCE_REFLECTION] = sizeof(void*); | ||
417 | offsets[PANEL_TARGET] = sizeof(void*); | ||
418 | offsets[SPECULAR_TEXTURE] = sizeof(void*); | ||
419 | } | ||
420 | 419 | ||
421 | for (auto const& [offset, size] : offsets) { | 420 | //arrays.push_back(PANEL_TARGET); |
422 | std::vector<byte> panel1data = _memory->ReadEntityData<byte>(panel1, offset, size); | 421 | //arrays.push_back(SPECULAR_TEXTURE); |
423 | std::vector<byte> panel2data = _memory->ReadEntityData<byte>(panel2, offset, size); | 422 | |
424 | _memory->WriteEntityData<byte>(panel2, offset, panel1data); | ||
425 | _memory->WriteEntityData<byte>(panel1, offset, panel2data); | ||
426 | } | ||
427 | } | 423 | } |
428 | 424 | ||
429 | void Randomizer::ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets) { | 425 | void Randomizer::ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets) { |
diff --git a/Source/Randomizer.h b/Source/Randomizer.h index bd8895b..ae89dc9 100644 --- a/Source/Randomizer.h +++ b/Source/Randomizer.h | |||
@@ -37,7 +37,7 @@ private: | |||
37 | 37 | ||
38 | void Randomize(std::vector<int>& panels, int flags); | 38 | void Randomize(std::vector<int>& panels, int flags); |
39 | void RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex); | 39 | void RandomizeRange(std::vector<int> &panels, int flags, size_t startIndex, size_t endIndex); |
40 | void SwapPanels(int panel1, int panel2, int flags); | 40 | void Tutorialise(int panel1, int copyFrom); |
41 | void ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets = {}); | 41 | void ReassignTargets(const std::vector<int>& panels, const std::vector<int>& order, std::vector<int> targets = {}); |
42 | void ReassignNames(const std::vector<int>& panels, const std::vector<int>& order); | 42 | void ReassignNames(const std::vector<int>& panels, const std::vector<int>& order); |
43 | 43 | ||