summary refs log tree commit diff stats
path: root/WitnessRandomizer
diff options
context:
space:
mode:
authorjbzdarkid <jbzdarkid@gmail.com>2018-10-23 20:05:01 -0700
committerjbzdarkid <jbzdarkid@gmail.com>2018-10-23 20:05:01 -0700
commitfac6378cf7370b93099ff73851cc9a0b68497335 (patch)
tree4d3003a24fd48280629121ab1ca9cb24bcfedaef /WitnessRandomizer
parent3af3ceaa7480f64ae5ccd9ee2c16fcf5e46bae3b (diff)
downloadwitness-tutorializer-fac6378cf7370b93099ff73851cc9a0b68497335.tar.gz
witness-tutorializer-fac6378cf7370b93099ff73851cc9a0b68497335.tar.bz2
witness-tutorializer-fac6378cf7370b93099ff73851cc9a0b68497335.zip
Fix bugs
Diffstat (limited to 'WitnessRandomizer')
-rw-r--r--WitnessRandomizer/WitnessRandomizer.cpp77
-rw-r--r--WitnessRandomizer/WitnessRandomizer.h10
2 files changed, 44 insertions, 43 deletions
diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp index 586731f..9178888 100644 --- a/WitnessRandomizer/WitnessRandomizer.cpp +++ b/WitnessRandomizer/WitnessRandomizer.cpp
@@ -1,10 +1,8 @@
1/* BUGS: 1/*
2 * Quarry colors are broken (specfically boathouse row 2 is translating wrong) 2 * BUGS:
3 * Desert flood exit isn't off properly 3 * Something is wrong with bunker
4 * FEATURES: 4 * FEATURES:
5 * Randomize audio logs 5 * Randomize audio logs
6 * Randomize lasers
7 * Tackle remaining areas (Treehouse, Keep, Shadows, Town, Monastery, Jungle, Bunker, Swamp)
8 * Compile panel lists in a more reasonable way 6 * Compile panel lists in a more reasonable way
9 * Separate panels out by "square", which can probably be anywhere 7 * 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
@@ -19,6 +17,21 @@ int main(int argc, char** argv)
19 WitnessRandomizer randomizer = WitnessRandomizer(); 17 WitnessRandomizer randomizer = WitnessRandomizer();
20 18
21 //* 19 //*
20
21 std::vector<int> lasers = {
22 0x0360D, // Symmetry
23 0x03615, // Swamp
24 0x09DE0, // Bunker
25 0x17CA4, // Monastery
26 0x032F5, // Town
27 0x03613, // Treehouse
28// 0x03608, // Desert
29 0x03612, // Quarry
30 0x03616, // Jungle
31 };
32 randomizer.Randomize(lasers, SWAP_TARGETS);
33
34
22 if (argc == 2) { 35 if (argc == 2) {
23 srand(atoi(argv[1])); // Seed with RNG from command line 36 srand(atoi(argv[1])); // Seed with RNG from command line
24 } 37 }
@@ -61,7 +74,7 @@ int main(int argc, char** argv)
61// 0x032F7. //Orchard Apple Tree 4 74// 0x032F7. //Orchard Apple Tree 4
62// 0x032FF. //Orchard Apple Tree 5 75// 0x032FF. //Orchard Apple Tree 5
63 }; 76 };
64 randomizer.Randomize(outsidetutorialPanels, SWAP_PATHWAYS | SWAP_COLORS); 77 randomizer.Randomize(outsidetutorialPanels, SWAP_LINES | SWAP_COLORS);
65 78
66 79
67 std::vector<int> symmetryPanels = { 80 std::vector<int> symmetryPanels = {
@@ -111,9 +124,8 @@ int main(int argc, char** argv)
111 0x00A61, // Symmetry Island Laser Blue 1 124 0x00A61, // Symmetry Island Laser Blue 1
112 0x00A64, // Symmetry Island Laser Blue 2 125 0x00A64, // Symmetry Island Laser Blue 2
113 0x00A68, // Symmetry Island Laser Blue 3 126 0x00A68, // Symmetry Island Laser Blue 3
114 // 0x0360D, // Symmetry Island Laser
115 }; 127 };
116 randomizer.Randomize(symmetryPanels, SWAP_PATHWAYS | SWAP_COLORS); 128 randomizer.Randomize(symmetryPanels, SWAP_LINES | SWAP_COLORS);
117 129
118 130
119 131
@@ -162,10 +174,9 @@ int main(int argc, char** argv)
162// 0x17C31, // Desert Final Transparent 174// 0x17C31, // Desert Final Transparent
163 0x012D7, // Desert Final Far 175 0x012D7, // Desert Final Far
164// 0x0A015, // Desert Final Far Control 176// 0x0A015, // Desert Final Far Control
165// 0x03608, // Desert Laser
166 }; 177 };
167 178
168 randomizer.Randomize(desertPanels, SWAP_PATHWAYS); 179 randomizer.Randomize(desertPanels, SWAP_LINES);
169 180
170 std::vector<int> quarryPanels = { 181 std::vector<int> quarryPanels = {
171 0x01E5A, // Mill Entry Door Left 182 0x01E5A, // Mill Entry Door Left
@@ -221,9 +232,8 @@ int main(int argc, char** argv)
221// 0x275FA, // Boathouse Hook Control 232// 0x275FA, // Boathouse Hook Control
222 0x09E57, // Quarry Entry Gate 1 233 0x09E57, // Quarry Entry Gate 1
223 0x17C09, // Quarry Entry Gate 2 234 0x17C09, // Quarry Entry Gate 2
224// 0x03612, // Quarry Laser
225 }; 235 };
226 randomizer.Randomize(quarryPanels, SWAP_PATHWAYS | SWAP_COLORS); 236 randomizer.Randomize(quarryPanels, SWAP_LINES | SWAP_COLORS);
227 237
228 std::vector<int> treehousePanels = { //worked fine until I commented out pivoting panels, puzzles solve fine if you know solution but star and dot colors are all messed up 238 std::vector<int> treehousePanels = { //worked fine until I commented out pivoting panels, puzzles solve fine if you know solution but star and dot colors are all messed up
229// 0x17C95, // Treehouse Summon Boat 239// 0x17C95, // Treehouse Summon Boat
@@ -289,10 +299,9 @@ int main(int argc, char** argv)
289 0x17FA0, // Treehouse Laser Discard 299 0x17FA0, // Treehouse Laser Discard
290// 0x2700B, // Treehouse Exterior Door Control 300// 0x2700B, // Treehouse Exterior Door Control
291// 0x17CBC, // Treehouse Interior Door Control 301// 0x17CBC, // Treehouse Interior Door Control
292// 0x03613, // Treehouse Laser
293// 0x037FF, // Treehouse Drawbridge Control 302// 0x037FF, // Treehouse Drawbridge Control
294 }; 303 };
295 randomizer.Randomize(treehousePanels, SWAP_PATHWAYS | SWAP_COLORS); 304 randomizer.Randomize(treehousePanels, SWAP_LINES | SWAP_COLORS);
296 305
297 std::vector<int> keepPanels = { 306 std::vector<int> keepPanels = {
298 0x00139, // Keep Hedges 1 307 0x00139, // Keep Hedges 1
@@ -316,7 +325,7 @@ int main(int argc, char** argv)
316 0x00AFB, // Shipwreck Vault 325 0x00AFB, // Shipwreck Vault
317// 0x03535, // Shipwreck Vault Box 326// 0x03535, // Shipwreck Vault Box
318 }; 327 };
319 randomizer.Randomize(keepPanels, SWAP_PATHWAYS | SWAP_COLORS); 328 randomizer.Randomize(keepPanels, SWAP_LINES | SWAP_COLORS);
320 329
321 std::vector<int> shadowsPanels = { //works beautifully, can solve based on panel color and where start/end points are if your memory is good 330 std::vector<int> shadowsPanels = { //works beautifully, can solve based on panel color and where start/end points are if your memory is good
322 0x386FA, //Shadows Avoid 1 331 0x386FA, //Shadows Avoid 1
@@ -344,7 +353,7 @@ int main(int argc, char** argv)
344 0x0AC7A, //Shadows Tutorial 7 353 0x0AC7A, //Shadows Tutorial 7
345 0x0A8E0, //Shadows Tutorial 8 354 0x0A8E0, //Shadows Tutorial 8
346 }; 355 };
347 randomizer.Randomize(shadowsPanels, SWAP_PATHWAYS | SWAP_COLORS); 356 randomizer.Randomize(shadowsPanels, SWAP_LINES | SWAP_COLORS);
348 357
349 std::vector<int> townPanels = { //appears to be ok but keeps crashing game? 358 std::vector<int> townPanels = { //appears to be ok but keeps crashing game?
350 0x2899C, //Town 25 Dots 1 359 0x2899C, //Town 25 Dots 1
@@ -363,7 +372,6 @@ int main(int argc, char** argv)
363 0x28A0D, //Town Church Stars 372 0x28A0D, //Town Church Stars
364 0x28AD9, //Town Eraser 373 0x28AD9, //Town Eraser
365 0x28998, //Town Green Door 374 0x28998, //Town Green Door
366// 0x032F5, //Town Laser
367// 0x09F98, //Town Laser Redirect Control 375// 0x09F98, //Town Laser Redirect Control
368// 0x1C344, //Town Laser Redirect Panel 1 376// 0x1C344, //Town Laser Redirect Panel 1
369// 0x1C343, //Town Laser Redirect Panel 2 377// 0x1C343, //Town Laser Redirect Panel 2
@@ -395,7 +403,7 @@ int main(int argc, char** argv)
395 0x33AB2, //Theater Corona Exit 403 0x33AB2, //Theater Corona Exit
396 0x0A168, //Theater Sun Exit 404 0x0A168, //Theater Sun Exit
397 }; 405 };
398 randomizer.Randomize(townPanels, SWAP_PATHWAYS | SWAP_COLORS); 406 randomizer.Randomize(townPanels, SWAP_LINES | SWAP_COLORS);
399 407
400 std::vector<int> monasteryPanels = { 408 std::vector<int> monasteryPanels = {
401// 0x00B10, //Monastery Left Door 409// 0x00B10, //Monastery Left Door
@@ -408,7 +416,6 @@ int main(int argc, char** argv)
408 0x193AA, //Monastery Interior 2 416 0x193AA, //Monastery Interior 2
409 0x193AB, //Monastery Interior 3 417 0x193AB, //Monastery Interior 3
410 0x193A6, //Monastery Interior 4 418 0x193A6, //Monastery Interior 4
411// 0x17CA4, //Monastery Laser if something else activates laser then you can't turn on any more panels as the activation string breaks
412 0x03713, //Monastery Shortcut 419 0x03713, //Monastery Shortcut
413 }; 420 };
414 randomizer.Randomize(monasteryPanels, SWAP_TARGETS); 421 randomizer.Randomize(monasteryPanels, SWAP_TARGETS);
@@ -434,9 +441,8 @@ int main(int argc, char** argv)
434 0x014B2, //Jungle Dots 6 441 0x014B2, //Jungle Dots 6
435// 0x17CAB, //Jungle Pop - up Wall 442// 0x17CAB, //Jungle Pop - up Wall
436// 0x337FA, //Jungle Shortcut 443// 0x337FA, //Jungle Shortcut
437// 0x03616, //Jungle Laser
438 }; 444 };
439 randomizer.Randomize(junglePanels, SWAP_PATHWAYS | SWAP_COLORS); 445 randomizer.Randomize(junglePanels, SWAP_LINES | SWAP_COLORS);
440 446
441// std::vector<int> bunkerPanels = { this doesn't want to behave, I have no idea 447// std::vector<int> bunkerPanels = { this doesn't want to behave, I have no idea
442// 0x17C2E, //Bunker Entry Door 448// 0x17C2E, //Bunker Entry Door
@@ -458,9 +464,8 @@ int main(int argc, char** argv)
458// 0x17E63, //Bunker Ultraviolet 1 464// 0x17E63, //Bunker Ultraviolet 1
459// 0x17E67, //Bunker Ultraviolet 2 465// 0x17E67, //Bunker Ultraviolet 2
460// 0x0A079, //Bunker Elevator 466// 0x0A079, //Bunker Elevator
461// // 0x09DE0, //Bunker Laser
462// }; 467// };
463// randomizer.Randomize(bunkerPanels, SWAP_PATHWAYS | SWAP_COLORS); 468// randomizer.Randomize(bunkerPanels, SWAP_LINES | SWAP_COLORS);
464 469
465 std::vector<int> swampPanels = { //appears to work ok swapping panels but keeps crashing game? 470 std::vector<int> swampPanels = { //appears to work ok swapping panels but keeps crashing game?
466 0x0056E, //Swamp Entry 471 0x0056E, //Swamp Entry
@@ -520,9 +525,8 @@ int main(int argc, char** argv)
520 0x17E07, //Swamp Island Control 2 525 0x17E07, //Swamp Island Control 2
521 0x17C05, //Swamp Laser Shortcut 1 526 0x17C05, //Swamp Laser Shortcut 1
522 0x17C02, //Swamp Laser Shortcut 2 527 0x17C02, //Swamp Laser Shortcut 2
523// 0x03615, //Swamp Laser
524 }; 528 };
525 randomizer.Randomize(swampPanels, SWAP_PATHWAYS | SWAP_COLORS); 529 randomizer.Randomize(swampPanels, SWAP_LINES | SWAP_COLORS);
526 530
527 std::vector<int> mountainPanels = { 531 std::vector<int> mountainPanels = {
528// 0x09E39, //Mountain 1 Purple Pathway 532// 0x09E39, //Mountain 1 Purple Pathway
@@ -588,7 +592,7 @@ int main(int argc, char** argv)
588// 0x17C34, //Mountaintop Perspective 592// 0x17C34, //Mountaintop Perspective
589 0x0042D, //Mountaintop River 593 0x0042D, //Mountaintop River
590 }; 594 };
591 randomizer.Randomize(mountainPanels, SWAP_PATHWAYS | SWAP_COLORS); 595 randomizer.Randomize(mountainPanels, SWAP_LINES | SWAP_COLORS);
592 596
593// std::vector<int> utmPanels = { this looks like it swaps ok but crashes to much to tell, not sure why it's not happy 597// std::vector<int> utmPanels = { this looks like it swaps ok but crashes to much to tell, not sure why it's not happy
594// 0x0A16E, //UTM Challenge Entrance 598// 0x0A16E, //UTM Challenge Entrance
@@ -649,26 +653,27 @@ int main(int argc, char** argv)
649// // 0x2FAF6, //Tunnels Vault Box 653// // 0x2FAF6, //Tunnels Vault Box
650// 0x09E85, //Tunnels Town Shortcut 654// 0x09E85, //Tunnels Town Shortcut
651// }; 655// };
652// randomizer.Randomize(utmPanels, SWAP_PATHWAYS | SWAP_COLORS); 656// randomizer.Randomize(utmPanels, SWAP_LINES | SWAP_COLORS);
653 657
654 658
655 /*/ 659 /*/
656 660
657 661
662 int BOATH_3_1 = 0x21B5;
658 int MILL_L_1 = 0xE0C; 663 int MILL_L_1 = 0xE0C;
659 int MILL_U_1 = 0x557; 664 int MILL_U_1 = 0x557;
660 int QUARRY_E_1 = 0x9E57; 665 int QUARRY_E_1 = 0x9E57;
661 int QUARRY_E_2 = 0x17C09; 666 int QUARRY_E_2 = 0x17C09;
662 int MILL_E_1 = 0x1E5A; 667 int MILL_E_1 = 0x1E5A;
663 668
664 randomizer.SwapPanels(QUARRY_E_2, MILL_E_1, SWAP_PATHWAYS | SWAP_COLORS); 669 randomizer.SwapPanels(BOATH_3_1, QUARRY_E_1, SWAP_LINES | SWAP_COLORS);
665 //*/ 670 //*/
666} 671}
667 672
668WitnessRandomizer::WitnessRandomizer() : _memory(Memory("witness64_d3d11.exe")) 673WitnessRandomizer::WitnessRandomizer() : _memory(Memory("witness64_d3d11.exe"))
669{ 674{
670 // Turn off desert flood final 675 // Turn off desert flood final
671 _memory.WriteData<float>({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f}); 676 _memory.WriteData<float>({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f, 0.0f});
672 // Change desert floating target to desert flood final 677 // Change desert floating target to desert flood final
673 _memory.WriteData<int>({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077}); 678 _memory.WriteData<int>({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077});
674} 679}
@@ -677,7 +682,7 @@ void WitnessRandomizer::Randomize(std::vector<int> panels, int flags) {
677 for (size_t i=panels.size() - 1; i > 1; i--) { 682 for (size_t i=panels.size() - 1; i > 1; i--) {
678 int target = rand() % i; 683 int target = rand() % i;
679 if (i != target) { 684 if (i != target) {
680 std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; 685 // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl;
681 SwapPanels(panels[i], panels[target], flags); 686 SwapPanels(panels[i], panels[target], flags);
682 std::swap(panels[i], panels[target]); // Panel indices in the array 687 std::swap(panels[i], panels[target]); // Panel indices in the array
683 } 688 }
@@ -690,7 +695,7 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
690 if (flags & SWAP_TARGETS) { 695 if (flags & SWAP_TARGETS) {
691 offsets[0x2BC] = sizeof(int); 696 offsets[0x2BC] = sizeof(int);
692 } 697 }
693 if (flags & SWAP_PATHWAYS) { 698 if (flags & SWAP_LINES) {
694 offsets[0x3B8] = sizeof(int); // num_dots 699 offsets[0x3B8] = sizeof(int); // num_dots
695 offsets[0x3BC] = sizeof(int); // num_connections 700 offsets[0x3BC] = sizeof(int); // num_connections
696 offsets[0x3C8] = sizeof(void*); // *dot_positions 701 offsets[0x3C8] = sizeof(void*); // *dot_positions
@@ -718,15 +723,18 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
718 offsets[0x3A4] = sizeof(float); // path_width_scale 723 offsets[0x3A4] = sizeof(float); // path_width_scale
719 offsets[0x3A8] = sizeof(float); // startpoint_scale 724 offsets[0x3A8] = sizeof(float); // startpoint_scale
720 725
726 offsets[0x230] = 16; // traced_edges
721 727
722 // TODO: Try using is_cylinder to swap into tutorial pillar. If it fails, discard. 728 // TODO: Try using is_cylinder to swap into tutorial pillar. If it fails, discard.
723 // Probably not: Extra back distance 729 // Probably not: Extra back distance
724 // SwapPanelData(panels[i], panels[target], 0x2FC, 125); // is_cylinder through max_connections 730 // SwapPanelData(panels[i], panels[target], 0x2FC, 125); // is_cylinder through max_connections
725 } 731 }
732 /*
726 if (flags & SWAP_STYLE) { 733 if (flags & SWAP_STYLE) {
727 // 340 - pattern_scale 734 // 340 - pattern_scale
728 // 288 - flash_mode 735 // 288 - flash_mode
729 } 736 }
737 */
730 if (flags & SWAP_COLORS) { 738 if (flags & SWAP_COLORS) {
731 offsets[0xC8] = 16; // path_color 739 offsets[0xC8] = 16; // path_color
732 offsets[0xD8] = 16; // reflection_path_color 740 offsets[0xD8] = 16; // reflection_path_color
@@ -751,12 +759,11 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) {
751 offsets[0x208] = sizeof(int); // push_symbol_colors 759 offsets[0x208] = sizeof(int); // push_symbol_colors
752 offsets[0x20C] = 16; // outer_background 760 offsets[0x20C] = 16; // outer_background
753 offsets[0x21C] = sizeof(int); // outer_background_mode 761 offsets[0x21C] = sizeof(int); // outer_background_mode
762 offsets[0x430] = sizeof(void*); // *decoration_colors
763 offsets[0x4A0] = sizeof(int); // num_colored_regions
754 offsets[0x4A8] = sizeof(void*); // *colored_regions 764 offsets[0x4A8] = sizeof(void*); // *colored_regions
765// offsets[0x4B8] = sizeof(void*); // *backing_texture
755 } 766 }
756 if (flags & SWAP_TRACED) {
757 offsets[0x230] = 16; // traced_edges
758 }
759
760 767
761 for (auto const& [offset, size] : offsets) { 768 for (auto const& [offset, size] : offsets) {
762 SwapPanelData(panel1, panel2, offset, size); 769 SwapPanelData(panel1, panel2, offset, size);
diff --git a/WitnessRandomizer/WitnessRandomizer.h b/WitnessRandomizer/WitnessRandomizer.h index 182c88e..9e84a46 100644 --- a/WitnessRandomizer/WitnessRandomizer.h +++ b/WitnessRandomizer/WitnessRandomizer.h
@@ -1,14 +1,8 @@
1#pragma once 1#pragma once
2 2
3int SWAP_TARGETS = 0x1; 3int SWAP_TARGETS = 0x1;
4int SWAP_PATHWAYS = 0x2; 4int SWAP_LINES = 0x2;
5int SWAP_STYLE = 0x4; 5int SWAP_COLORS = 0x4;
6int SWAP_COLORS = 0x8;
7int SWAP_TRACED = 0x10;
8
9
10int SWAP_SIZE = 0x20;
11
12 6
13class WitnessRandomizer { 7class WitnessRandomizer {
14public: 8public: