From 4edd6ab796f26563368e5b8487df1f1f9bb0684c Mon Sep 17 00:00:00 2001 From: jbzdarkid Date: Thu, 25 Oct 2018 21:57:21 -0700 Subject: Some sequence randomization, and swapping some control panels. --- WitnessRandomizer/Memory.cpp | 2 +- WitnessRandomizer/Memory.h | 1 + WitnessRandomizer/Panels.h | 371 +++++++++++++++++--------------- WitnessRandomizer/WitnessRandomizer.cpp | 175 ++++++++++----- WitnessRandomizer/WitnessRandomizer.h | 9 +- 5 files changed, 334 insertions(+), 224 deletions(-) (limited to 'WitnessRandomizer') diff --git a/WitnessRandomizer/Memory.cpp b/WitnessRandomizer/Memory.cpp index 304b7b4..8ad5452 100644 --- a/WitnessRandomizer/Memory.cpp +++ b/WitnessRandomizer/Memory.cpp @@ -51,7 +51,7 @@ Memory::~Memory() { void Memory::ThrowError() { std::string message(256, '\0'); - FormatMessageA(4096, NULL, GetLastError(), 1024, &message[0], message.length(), NULL); + FormatMessageA(4096, NULL, GetLastError(), 1024, &message[0], static_cast(message.length()), NULL); OutputDebugStringA(message.c_str()); exit(EXIT_FAILURE); } diff --git a/WitnessRandomizer/Memory.h b/WitnessRandomizer/Memory.h index adc1287..390269c 100644 --- a/WitnessRandomizer/Memory.h +++ b/WitnessRandomizer/Memory.h @@ -28,6 +28,7 @@ public: // std::this_thread::sleep_for(10ms); } ThrowError(); + return {}; } template diff --git a/WitnessRandomizer/Panels.h b/WitnessRandomizer/Panels.h index fff7053..3120357 100644 --- a/WitnessRandomizer/Panels.h +++ b/WitnessRandomizer/Panels.h @@ -60,22 +60,55 @@ std::vector burnablePanels = { 0x012D7, // Desert Final Far }; -// Note: Some of these (non-switches) are duplicated elsewhere +// Note: Some of these (non-controls) are duplicated elsewhere +// TODO: Gave up std::vector leftRightPanels = { + 0x01A54, // Glass Factory Entry + 0x00086, // Glass Factory Vertical Symmetry 1 + 0x00087, // Glass Factory Vertical Symmetry 2 + 0x00059, // Glass Factory Vertical Symmetry 3 + 0x00062, // Glass Factory Vertical Symmetry 4 + 0x00025, // Symmetry Island Black Dots 4 + 0x00026, // Symmetry Island Black Dots 5 + 0x00072, // Symmetry Island Fading Lines 3 + 0x17D02, // Town Windmill Control }; -// Note: Some of these (non-switches) are duplicated elsewhere +// Note: Some of these (non-controls) are duplicated elsewhere std::vector upDownPanels = { + 0x0008D, // Glass Factory Rotational Symmetry 1 + 0x00081, // Glass Factory Rotational Symmetry 2 + 0x00083, // Glass Factory Rotational Symmetry 3 + 0x00084, // Glass Factory Melting 1 + 0x00070, // Symmetry Island Fading Lines 5 + 0x01E5A, // Mill Entry Door Left + 0x28AC7, // Town Blue 1 + 0x28AC8, // Town Blue 2 + 0x28ACA, // Town Blue 3 + 0x28ACB, // Town Blue 4 + 0x28ACC, // Town Blue 5 + 0x00029, // UTM Invisible Dots Symmetry 3 + 0x0A3B5, // Tutorial Back Left 0x17CC4, // Mill Elevator Control + 0x335AB, // UTM In Elevator Control + 0x3369D, // UTM Lower Elevator Control + 0x335AC, // UTM Upper Elevator Control + 0x09EEB, // Mountain 2 Elevator }; +// Note: Some of these (non-controls) are duplicated elsewhere std::vector leftForwardRightPanels = { - 0x17DD1, // Treehouse Left Orange 9 has to pivot - 0x17CE3, // Treehouse Right Orange 4 has to pivot - 0x17DB7, // Treehouse Right Orange 10 has to pivot - 0x17E52, // Treehouse Green 4 has to pivot +// 0x00075, // Symmetry Island Colored Dots 3 +// 0x288EA, // UTM Perspective 1 +// 0x288FC, // UTM Perspective 2 +// 0x289E7, // UTM Perspective 3 + + 0x17DD1, // Treehouse Left Orange 9 + 0x17CE3, // Treehouse Right Orange 4 + 0x17DB7, // Treehouse Right Orange 10 + 0x17E52, // Treehouse Green 4 }; std::vector pillars = { @@ -101,159 +134,6 @@ std::vector mountainMultipanel = { 0x09FD2, // Mountain 2 Multipanel 6 }; -// There might be something to do with these, I haven't decided yet. -std::vector nothingPanels = { -// Doors & Shortcuts & Shortcut doors & Door controls - 0x0C339, // Desert Surface Door - 0x0A249, // Desert Pond Exit Door - 0x275ED, // Mill EP Door - 0x17CAC, // Mill Stairs Shortcut Door - 0x38663, // Boathouse Shortcut - 0x09E49, // Keep Shadows Shortcut - 0x0361B, // Keep Tower Shortcut - 0x334DC, // Shadows Inner Door Control - 0x334DB, // Shadows Outer Door Control - 0x2700B, // Treehouse Exterior Door Control - 0x17CBC, // Treehouse Interior Door Control -// 0x337FA, // Jungle Shortcut - -// Controls (?) - 0x09FA0, // Desert Surface 3 Control - 0x09F86, // Desert Surface 8 Control - 0x1C2DF, // Desert Flood Control Lower Far Left - 0x1831E, // Desert Flood Control Lower Far Right - 0x1C260, // Desert Flood Control Lower Near Left - 0x1831C, // Desert Flood Control Lower Near Right - 0x1C2F3, // Desert Flood Control Raise Far Left - 0x1831D, // Desert Flood Control Raise Far Right - 0x1C2B1, // Desert Flood Control Raise Near Left - 0x1831B, // Desert Flood Control Raise Near Right - 0x0A015, // Desert Final Far Control - 0x03678, // Mill Lower Ramp Contol - 0x03679, // Mill Lower Lift Control - 0x03675, // Mill Upper Lift Control - 0x03676, // Mill Upper Ramp Control - 0x03852, // Boathouse Ramp Angle Control - 0x03858, // Boathouse Ramp Position Control - 0x275FA, // Boathouse Hook Control - 0x037FF, // Treehouse Drawbridge Control - 0x09F98, // Town Laser Redirect Control - 0x334D8, // Town RGB Light Control - 0x17E2B, // Swamp Flood Gate Control - 0x00609, // Swamp Surface Sliding Bridge Control - 0x18488, // Swamp Underwater Sliding Bridge Control - 0x17C0A, // Swamp Island Control 1 - 0x17E07, // Swamp Island Control 2 - 0x181F5, // Swamp Rotating Bridge Control - -// Vault Boxes - 0x03481, // Outside Tutorial Vault Box - 0x0339E, // Desert Vault Box - 0x03535, // Shipwreck Vault Box - 0x03702, // Jungle Vault Box - 0x03542, // Mountainside Vault Box - -// Boat Summons - 0x17CC8, // Glass Factory Summon Boat - 0x17CA6, // Boathouse Summon Boat - 0x17C95, // Treehouse Summon Boat - 0x0A054, // Town Summon Boat - 0x09DB8, // Swamp Summon Boat - 0x17CDF, // Jungle Summon Boat - -// Identical sets - 0x00143, // Orchard Apple Tree 1 - 0x0003B, // Orchard Apple Tree 2 - 0x00055, // Orchard Apple Tree 3 - 0x032F7, // Orchard Apple Tree 4 - 0x032FF, // Orchard Apple Tree 5 - 0x009B8, // Symmetry Island Transparent 1 - 0x003E8, // Symmetry Island Transparent 2 - 0x00A15, // Symmetry Island Transparent 3 - 0x00B53, // Symmetry Island Transparent 4 - 0x00B8D, // Symmetry Island Transparent 5 - -// Misc - 0x03629, // Tutorial Gate Open - 0x09FAA, // Desert Lightswitch - 0x0C335, // Tutorial Pillar - 0x0C373, // Tutorial Patio floor - 0x1C349, // Symmetry Island Door 2 - Collision fails here, sadly - 0x18076, // Desert Flood Exit - I am doing something with this -- but it's a very unique panel. - 0x0A15C, // Desert Final Left Convex - 0x09FFF, // Desert Final Left Concave - 0x0A15F, // Desert Final Near - 0x033EA, // Keep Yellow Pressure Plates - 0x0A3A8, // Keep Yellow Reset - 0x01BE9, // Keep Purple Pressure Plates - 0x0A3B9, // Keep Purple Reset - 0x01CD3, // Keep Green Pressure Plates - 0x0A3BB, // Keep Green Reset - 0x01D3F, // Keep Blue Pressure Plates - 0x0A3AD, // Keep Blue Reset - 0x2896A, // Town Bridge - 0x28A69, // Town Lattice - 0x28A79, // Town Maze - 0x28B39, // Town Red Hexagonal - 0x034E3, // Town Soundproof Dots - 0x034E4, // Town Soundproof Waves - 0x079DF, // Town Triple - 0x00815, // Theater Video Input - 0x03553, // Theater Tutorial Video - 0x03552, // Theater Desert Video - 0x0354E, // Theater Jungle Video - 0x03549, // Theater Challenge Video - 0x0354F, // Theater Shipwreck Video - 0x03545, // Theater Mountain Video - 0x18590, // Town Transparent - 0x28AE3, // Town Wire - - -// 0x09E39, // Mountain 1 Purple Pathway -// 0x33AF5, // Mountain 1 Blue 1 -// 0x33AF7, // Mountain 1 Blue 2 -// 0x09F6E, // Mountain 1 Blue 3 -// 0x09FD8, // Mountain 2 Rainbow 5 -// 0x09E86, // Mountain 2 Blue Pathway -// 0x09ED8, // Mountain 2 Orange Pathway -// 0x09EEB, // Mountain 2 Elevator - 0x09F8E, // Mountain 3 Near Right Floor - 0x09FC1, // Mountain 3 Near Left Floor - 0x09F01, // Mountain 3 Far Right Floor - 0x09EFF, // Mountain 3 Far Left Floor - 0x09FDA, // Mountain 3 Giant Floor -// 0x01983, // Mountain 3 Left Peekaboo -// 0x01987, // Mountain 3 Right Peekaboo -// 0x3D9A6, // Mountain 3 Left Close Door -// 0x3D9A7, // Mountain 3 Right Close Door -// 0x3D9AA, // Mountain 3 Left Activate Elevator -// 0x3D9A8, // Mountain 3 Right Activate Elevator -// 0x3D9A9, // Mountain 3 Launch Elevator -// 0x3C113, // Mountain 3 Left Open Door -// 0x3C114, // Mountain 3 Right Open Door -// 0x09F7F, // Mountaintop Laser Box -// 0x17C34, // Mountaintop Perspective -// 0x0A16E, // UTM Challenge Entrance -// 0x335AB, // UTM In Elevator Control -// 0x3369D, // UTM Lower Elevator Control -// 0x288EA, // UTM Perspective 1 -// 0x288FC, // UTM Perspective 2 -// 0x289E7, // UTM Perspective 3 -// 0x288AA, // UTM Perspective 4 -// 0x334E1, // UTM Secret Door Control -// 0x335AC, // UTM Upper Elevator Control -// 0x2773D, // Tunnels Desert Shortcut -// 0x27732, // Tunnels Theater Shortcut -// 0x2FAF6, // Tunnels Vault Box -// 0x0A099, // Bunker Glass Door -// 0x34BC5, // Bunker Open Ultraviolet -// 0x34BC6, // Bunker Close Ultraviolet -// 0x15ADD, // Jungle Vault -// 0x17CAA, // Jungle Courtyard Gate -// 0x17CAB, // Jungle Pop-up Wall - 0x0005C, // Glass Factory Vertical Symmetry 5 -}; - std::vector squarePanels = { 0x00064, // Tutorial Straight 0x00182, // Tutorial Bend @@ -453,6 +333,7 @@ std::vector squarePanels = { 0x0A168, // Theater Sun Exit 0x00B10, // Monastery Left Door 0x00C92, // Monastery Right Door + 0x17C2E, // Bunker Entry Door 0x0056E, // Swamp Entry 0x00469, // Swamp Tutorial 1 0x00472, // Swamp Tutorial 2 @@ -573,7 +454,15 @@ std::vector squarePanels = { 0x09E85, // Tunnels Town Shortcut }; -std::vector shadowsPanels = { // works beautifully, can solve based on panel color and where start/end points are if your memory is good +std::vector shadowsPanels = { + 0x198B5, // Shadows Tutorial 1 + 0x198BD, // Shadows Tutorial 2 + 0x198BF, // Shadows Tutorial 3 + 0x19771, // Shadows Tutorial 4 + 0x0A8DC, // Shadows Tutorial 5 + 0x0AC74, // Shadows Tutorial 6 + 0x0AC7A, // Shadows Tutorial 7 + 0x0A8E0, // Shadows Tutorial 8 0x386FA, // Shadows Avoid 1 0x1C33F, // Shadows Avoid 2 0x196E2, // Shadows Avoid 3 @@ -587,17 +476,12 @@ std::vector shadowsPanels = { // works beautifully, can solve based on pane 0x197E0, // Shadows Follow 3 0x197E8, // Shadows Follow 4 0x197E5, // Shadows Follow 5 - 0x198B5, // Shadows Tutorial 1 - 0x198BD, // Shadows Tutorial 2 - 0x198BF, // Shadows Tutorial 3 - 0x19771, // Shadows Tutorial 4 - 0x0A8DC, // Shadows Tutorial 5 - 0x0AC74, // Shadows Tutorial 6 - 0x0AC7A, // Shadows Tutorial 7 - 0x0A8E0, // Shadows Tutorial 8 + 0x19650, // Shadows Laser }; std::vector monasteryPanels = { + 0x00B10, // Monastery Left Door + 0x00C92, // Monastery Right Door 0x00290, // Monastery Exterior 1 0x00038, // Monastery Exterior 2 0x00037, // Monastery Exterior 3 @@ -607,10 +491,10 @@ std::vector monasteryPanels = { 0x193AB, // Monastery Interior 3 0x193A6, // Monastery Interior 4 // 0x03713, // Monastery Shortcut + 0x17CA4, // Monastery Laser }; -std::vector bunkerPanels = { // this doesn't want to behave, I have no idea - 0x17C2E, // Bunker Entry Door +std::vector bunkerPanels = { 0x09F7D, // Bunker Tutorial 1 0x09FDC, // Bunker Tutorial 2 0x09FF7, // Bunker Tutorial 3 @@ -620,11 +504,14 @@ std::vector bunkerPanels = { // this doesn't want to behave, I have no idea 0x09DA1, // Bunker Advanced 2 0x09DA2, // Bunker Advanced 3 0x09DAF, // Bunker Advanced 4 +// 0x0A099, // Bunker Glass Door 0x0A010, // Bunker Glass 1 0x0A01B, // Bunker Glass 2 0x0A01F, // Bunker Glass 3 0x17E63, // Bunker Ultraviolet 1 0x17E67, // Bunker Ultraviolet 2 + 0x34BC5, // Bunker Open Ultraviolet + 0x34BC6, // Bunker Close Ultraviolet 0x0A079, // Bunker Elevator }; @@ -636,10 +523,154 @@ std::vector junglePanels = { 0x0070F, // Jungle Waves 5 0x0087D, // Jungle Waves 6 0x002C7, // Jungle Waves 7 +// 0x17CAB, // Jungle Pop-up Wall 0x0026D, // Jungle Dots 1 0x0026E, // Jungle Dots 2 0x0026F, // Jungle Dots 3 0x00C3F, // Jungle Dots 4 0x00C41, // Jungle Dots 5 0x014B2, // Jungle Dots 6 + 0x03616, // Jungle Laser +}; + +// There might be something to do with these, I haven't decided yet. +std::vector nothingPanels = { +// Doors & Shortcuts & Shortcut doors & Door controls + 0x0C339, // Desert Surface Door + 0x0A249, // Desert Pond Exit Door + 0x275ED, // Mill EP Door + 0x17CAC, // Mill Stairs Shortcut Door + 0x38663, // Boathouse Shortcut + 0x09E49, // Keep Shadows Shortcut + 0x0361B, // Keep Tower Shortcut + 0x334DC, // Shadows Inner Door Control + 0x334DB, // Shadows Outer Door Control + 0x2700B, // Treehouse Exterior Door Control + 0x17CBC, // Treehouse Interior Door Control + 0x337FA, // Jungle Shortcut + +// Controls (?) + 0x09FA0, // Desert Surface 3 Control + 0x09F86, // Desert Surface 8 Control + 0x1C2DF, // Desert Flood Control Lower Far Left + 0x1831E, // Desert Flood Control Lower Far Right + 0x1C260, // Desert Flood Control Lower Near Left + 0x1831C, // Desert Flood Control Lower Near Right + 0x1C2F3, // Desert Flood Control Raise Far Left + 0x1831D, // Desert Flood Control Raise Far Right + 0x1C2B1, // Desert Flood Control Raise Near Left + 0x1831B, // Desert Flood Control Raise Near Right + 0x0A015, // Desert Final Far Control + 0x03678, // Mill Lower Ramp Contol + 0x03679, // Mill Lower Lift Control + 0x03675, // Mill Upper Lift Control + 0x03676, // Mill Upper Ramp Control + 0x03852, // Boathouse Ramp Angle Control + 0x03858, // Boathouse Ramp Position Control + 0x275FA, // Boathouse Hook Control + 0x037FF, // Treehouse Drawbridge Control + 0x09F98, // Town Laser Redirect Control + 0x334D8, // Town RGB Light Control + 0x17E2B, // Swamp Flood Gate Control + 0x00609, // Swamp Surface Sliding Bridge Control + 0x18488, // Swamp Underwater Sliding Bridge Control + 0x17C0A, // Swamp Island Control 1 + 0x17E07, // Swamp Island Control 2 + 0x181F5, // Swamp Rotating Bridge Control + +// Vault Boxes + 0x03481, // Outside Tutorial Vault Box + 0x0339E, // Desert Vault Box + 0x03535, // Shipwreck Vault Box + 0x03702, // Jungle Vault Box + 0x03542, // Mountainside Vault Box + 0x2FAF6, // Tunnels Vault Box + +// Boat Summons + 0x17CC8, // Glass Factory Summon Boat + 0x17CA6, // Boathouse Summon Boat + 0x17C95, // Treehouse Summon Boat + 0x0A054, // Town Summon Boat + 0x09DB8, // Swamp Summon Boat + 0x17CDF, // Jungle Summon Boat + +// Identical sets + 0x00143, // Orchard Apple Tree 1 + 0x0003B, // Orchard Apple Tree 2 + 0x00055, // Orchard Apple Tree 3 + 0x032F7, // Orchard Apple Tree 4 + 0x032FF, // Orchard Apple Tree 5 + 0x009B8, // Symmetry Island Transparent 1 + 0x003E8, // Symmetry Island Transparent 2 + 0x00A15, // Symmetry Island Transparent 3 + 0x00B53, // Symmetry Island Transparent 4 + 0x00B8D, // Symmetry Island Transparent 5 + +// Misc + 0x03629, // Tutorial Gate Open + 0x09FAA, // Desert Lightswitch + 0x0C335, // Tutorial Pillar + 0x0C373, // Tutorial Patio floor + 0x1C349, // Symmetry Island Door 2 - Collision fails here, sadly + 0x18076, // Desert Flood Exit - I am doing something with this -- but it's a very unique panel. + 0x0A15C, // Desert Final Left Convex + 0x09FFF, // Desert Final Left Concave + 0x0A15F, // Desert Final Near + 0x033EA, // Keep Yellow Pressure Plates + 0x0A3A8, // Keep Yellow Reset + 0x01BE9, // Keep Purple Pressure Plates + 0x0A3B9, // Keep Purple Reset + 0x01CD3, // Keep Green Pressure Plates + 0x0A3BB, // Keep Green Reset + 0x01D3F, // Keep Blue Pressure Plates + 0x0A3AD, // Keep Blue Reset + 0x2896A, // Town Bridge + 0x28A69, // Town Lattice + 0x28A79, // Town Maze + 0x28B39, // Town Red Hexagonal + 0x034E3, // Town Soundproof Dots + 0x034E4, // Town Soundproof Waves + 0x079DF, // Town Triple + 0x00815, // Theater Video Input + 0x03553, // Theater Tutorial Video + 0x03552, // Theater Desert Video + 0x0354E, // Theater Jungle Video + 0x03549, // Theater Challenge Video + 0x0354F, // Theater Shipwreck Video + 0x03545, // Theater Mountain Video + 0x18590, // Town Transparent + 0x28AE3, // Town Wire + + + 0x09E39, // Mountain 1 Purple Pathway +// 0x33AF5, // Mountain 1 Blue 1 +// 0x33AF7, // Mountain 1 Blue 2 +// 0x09F6E, // Mountain 1 Blue 3 +// 0x09FD8, // Mountain 2 Rainbow 5 + 0x09E86, // Mountain 2 Blue Pathway + 0x09ED8, // Mountain 2 Orange Pathway + 0x09F8E, // Mountain 3 Near Right Floor + 0x09FC1, // Mountain 3 Near Left Floor + 0x09F01, // Mountain 3 Far Right Floor + 0x09EFF, // Mountain 3 Far Left Floor + 0x09FDA, // Mountain 3 Giant Floor +// 0x01983, // Mountain 3 Left Peekaboo +// 0x01987, // Mountain 3 Right Peekaboo +// 0x3D9A6, // Mountain 3 Left Close Door +// 0x3D9A7, // Mountain 3 Right Close Door +// 0x3D9AA, // Mountain 3 Left Activate Elevator +// 0x3D9A8, // Mountain 3 Right Activate Elevator +// 0x3D9A9, // Mountain 3 Launch Elevator +// 0x3C113, // Mountain 3 Left Open Door +// 0x3C114, // Mountain 3 Right Open Door + 0x09F7F, // Mountaintop Laser Box + 0x17C34, // Mountaintop Perspective + 0x0A16E, // UTM Challenge Entrance +// 0x334E1, // UTM Secret Door Control +// 0x2773D, // Tunnels Desert Shortcut +// 0x27732, // Tunnels Theater Shortcut +// 0x0A099, // Bunker Glass Door +// 0x15ADD, // Jungle Vault +// 0x17CAA, // Jungle Courtyard Gate + 0x0005C, // Glass Factory Vertical Symmetry 5 }; diff --git a/WitnessRandomizer/WitnessRandomizer.cpp b/WitnessRandomizer/WitnessRandomizer.cpp index 2a06ee2..70e4fb2 100644 --- a/WitnessRandomizer/WitnessRandomizer.cpp +++ b/WitnessRandomizer/WitnessRandomizer.cpp @@ -1,22 +1,33 @@ /* + * BUGS: + * 3-way in treehouse not working :( + * Mountain orange is copying movement data :( + * Treehouse panels are not copying color? * FEATURES: * SWAP_TARGETS should still require the full panel sequence (and have ways to prevent softlocks?) - ** Jungle(?), Bunker, Monastery, Challenge(!), Shadows + ** Think about: Jungle + ** Hard: Monastery + ** Do: Challenge * Randomize audio logs - * List of panels which split left/right (for left/right controls) - * List of panels which split up/down (for up/down controls) * Swap sounds in jungle (along with panels) -- maybe impossible * Make orange 7 (all of oranges?) hard. Like big = hard. * Kill panel slowdown in tutorial * Fix desert elevator (laser rando) / Add keep? - * TRY: - * Swap treehouse pivots */ #include "Memory.h" #include "WitnessRandomizer.h" #include "Panels.h" #include #include +#include + +template +int find(const std::vector &data, T search, int startIndex = 0) { + for (int i=startIndex ; i({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); - //*/ + + // Content swaps -- must happen before squarePanels + randomizer.Randomize(upDownPanels, SWAP_LINES | SWAP_STYLE); + randomizer.Randomize(leftForwardRightPanels, SWAP_LINES | SWAP_STYLE); + + randomizer.Randomize(squarePanels, SWAP_LINES | SWAP_STYLE); + + // Frame swaps -- must happen after squarePanels + randomizer.Randomize(burnablePanels, SWAP_LINES | SWAP_STYLE); + + + // Target swaps, can happen whenever + randomizer.Randomize(lasers, SWAP_TARGETS); + + std::vector randomOrder = std::vector(junglePanels.size(), 0); + std::iota(randomOrder.begin(), randomOrder.end(), 0); + // Randomize Waves 2-7 + // Waves 1 cannot be randomized, since no other panel can start on + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 7); + // Randomize Pitches 1-6 onto themselves + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 7, 13); + randomizer.ReassignTargets(junglePanels, randomOrder); + + randomOrder = std::vector(bunkerPanels.size(), 0); + std::iota(randomOrder.begin(), randomOrder.end(), 0); + // Randomize Tutorial 2-Advanced Tutorial 4 + Glass 1 + // Tutorial 1 cannot be randomized, since no other panel can start on + // Glass 1 will become door + glass 1, due to the targetting system + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 1, 10); + // Randomize Glass 1-3 into everything after the door + int glassDoorIndex = find(randomOrder, 9) + 1; + randomizer.RandomizeRange(randomOrder, SWAP_NONE, glassDoorIndex, 12); + randomizer.ReassignTargets(bunkerPanels, randomOrder); + + randomOrder = std::vector(shadowsPanels.size(), 0); + std::iota(randomOrder.begin(), randomOrder.end(), 0); + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 0, 8); // Tutorial + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 8, 16); // Avoid + randomizer.RandomizeRange(randomOrder, SWAP_NONE, 16, 21); // Follow + randomizer.ReassignTargets(shadowsPanels, randomOrder); + randomizer.TurnOff(shadowsPanels[0]); + randomizer.TurnOn(shadowsPanels[randomOrder[0]]); } WitnessRandomizer::WitnessRandomizer() : _memory("witness64_d3d11.exe") { // Turn off desert flood final - _memory.WriteData({0x5B28C0, 0x18, 0x18076*8, 0x2A8}, {0.0f, 0.0f}); + TurnOff(0x18076); // Change desert floating target to desert flood final _memory.WriteData({0x5B28C0, 0x18, 0x17ECA*8, 0x2BC}, {0x18077}); // Distance-gate shadows laser to prevent sniping through the bars - _memory.WriteData({0x5B28C0, 0x18, 0x19650*8, 0x3C0}, {2.0f}); + _memory.WriteData({0x5B28C0, 0x18, 0x19650*8, 0x3C0}, {2.5f}); + // Change the shadows tutorial cable to only activate avoid + _memory.WriteData({0x5B28C0, 0x18, 0x319A8*8, 0xD8}, {0}); + // Change shadows avoid 8 to power shadows follow + _memory.WriteData({0x5B28C0, 0x18, 0x1972F*8, 0x2BC}, {0x1C34C}); + // Disable tutorial cursor speed modifications + _memory.WriteData({0x5B28C0, 0x18, 0x00295*8, 0x358}, {1.0}); + _memory.WriteData({0x5B28C0, 0x18, 0x0C373*8, 0x358}, {1.0}); + _memory.WriteData({0x5B28C0, 0x18, 0x00293*8, 0x358}, {1.0}); + _memory.WriteData({0x5B28C0, 0x18, 0x002C2*8, 0x358}, {1.0}); + + // Explicitly set back-off distance for the challenge entry & final 2 pillars // _memory.WriteData({0x5B28C0, 0x18, 0x9DD5*8, 0x22C}, {2.5f}); @@ -85,10 +111,17 @@ WitnessRandomizer::WitnessRandomizer() : _memory("witness64_d3d11.exe") // _memory.WriteData({0x5B28C0, 0x18, 0x1C319*8, 0x22C}, {3.0f}); } -void WitnessRandomizer::Randomize(std::vector panels, int flags) { +void WitnessRandomizer::Randomize(std::vector &panels, int flags) { + return RandomizeRange(panels, flags, 0, panels.size()); +} + +// Range is [start, end) +void WitnessRandomizer::RandomizeRange(std::vector &panels, int flags, size_t startIndex, size_t endIndex) { if (panels.size() == 0) return; - for (size_t i=panels.size() - 1; i > 1; i--) { - int target = rand() % i; + if (startIndex >= endIndex) return; + if (endIndex >= panels.size()) endIndex = panels.size(); + for (size_t i = endIndex-1; i > startIndex+1; i--) { + size_t target = rand() % (i - startIndex) + startIndex; if (i != target) { // std::cout << "Swapping panels " << std::hex << panels[i] << " and " << std::hex << panels[target] << std::endl; SwapPanels(panels[i], panels[target], flags); @@ -180,6 +213,36 @@ void WitnessRandomizer::SwapPanels(int panel1, int panel2, int flags) { } } +/* +void WitnessRandomizer::SwapTargetList(const std::vector& initialOrder, const std::vector& randomizedOrder) { + std::vector> randomizedTargets; + for (int panel : randomizedOrder) { + randomizedTargets.push_back(_memory.ReadData({0x5B28C0, 0x18, panel*8, 0x2BC}, 1)); + } + for (int i=0; i target = randomizedTargets[i]; + _memory.WriteData({0x5B28C0, 0x18, panel*8, 0x2BC}, target); + } +} +*/ + +void WitnessRandomizer::ReassignTargets(const std::vector& panels, const std::vector& order) { + std::vector targetToActivatePanel = {panels[0] + 1}; + for (int panel : panels) { + int target = _memory.ReadData({0x5B28C0, 0x18, panel*8, 0x2BC}, 1)[0]; + targetToActivatePanel.push_back(target); + } + + for (int i=0; i({0x5B28C0, 0x18, panels[order[i]]*8, 0x2BC}, {panelTarget}); + } +} + void WitnessRandomizer::SwapPanelData(int panel1, int panel2, int finalOffset, int dataSize) { // Currently wired for old version std::vector panel1Offset = {0x5B28C0, 0x18, panel1*8, finalOffset}; @@ -191,3 +254,11 @@ void WitnessRandomizer::SwapPanelData(int panel1, int panel2, int finalOffset, i _memory.WriteData(panel2Offset, panel1Data); _memory.WriteData(panel1Offset, panel2Data); } + +void WitnessRandomizer::TurnOn(int panel) { + _memory.WriteData({0x5B28C0, 0x18, panel*8, 0x2A8}, {1.0f, 1.0f}); +} + +void WitnessRandomizer::TurnOff(int panel) { + _memory.WriteData({0x5B28C0, 0x18, panel*8, 0x2A8}, {0.0f, 0.0f}); +} diff --git a/WitnessRandomizer/WitnessRandomizer.h b/WitnessRandomizer/WitnessRandomizer.h index 7618e91..f9a66c4 100644 --- a/WitnessRandomizer/WitnessRandomizer.h +++ b/WitnessRandomizer/WitnessRandomizer.h @@ -1,5 +1,6 @@ #pragma once +int SWAP_NONE = 0x0; int SWAP_TARGETS = 0x1; int SWAP_LINES = 0x2; int SWAP_STYLE = 0x4; @@ -10,10 +11,16 @@ public: WitnessRandomizer(); - void Randomize(std::vector panels, int flags); + void Randomize(std::vector &panels, int flags); + void RandomizeRange(std::vector &panels, int flags, size_t startIndex, size_t endIndex); void SwapPanels(int panel1, int panel2, int flags); + void ReassignTargets(const std::vector& panels, const std::vector& order); + //private: + void TurnOn(int panel); + void TurnOff(int panel); + void SwapPanelData(int panel1, int panel2, int finalOffset, int dataSize); Memory _memory; -- cgit 1.4.1