B1KMusic

RE3 (PSX) Water Control Room Puzzle crack tool

May 26th, 2020
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2.  * One of the final puzzles in Resident Evil 3 (PSX). This puzzle is obnoxious.
  3.  * Use this tool to crack the puzzle if you've been beating your
  4.  * head against a wall and lost track of what the initial puzzle state was
  5.  *
  6.  * To use: (rudimentary javascript knowledge recommended)
  7.  * 1. paste this script into a javascript console but don't hit enter
  8.  * 2. go to the top of the pasted script and make sure the four arrays match the game
  9.  * 3. hit enter
  10.  *
  11.  * The gauges are in 8 groups of 2, and shift 2 units, as such there are 8^3=512
  12.  * combinations possible printarray() prints the array as it appears in-game,
  13.  * i.e. in 8 groups of 2
  14.  *
  15.  * When bruteforce() is run, it will tell you how many times you need to shift each
  16.  * channel left to solve the puzzle.
  17.  * Shifts in this crack are always left because why over-complicate things.
  18.  * And since this is mod 8, you can subtract from 8 to get the equivalent right
  19.  * shift count.
  20.  * In the state shown below, the output is 0, 6, 2, which also means 0 2R 2L
  21.  *
  22.  * -Braden
  23.  */
  24.  
  25. let want = [2,1,1,1,3,0,2,0,2,1,3,1,1,0,2,1];
  26. let A    = [1,0,1,1,1,0,0,0,1,1,1,0,0,0,1,1];
  27. let B    = [1,0,1,0,1,0,1,1,0,0,1,0,0,0,0,0];
  28. let C    = [1,0,0,0,1,1,0,0,1,0,1,0,0,0,1,0];
  29.  
  30. function shift(array){
  31.     return array.slice(2).concat(array.slice(0,2));
  32. }
  33.  
  34. function printarray(arr){
  35.     let outbuf = "";
  36.  
  37.     for(let i = 0; i < arr.length; i += 2)
  38.         outbuf += arr[i] + "" + arr[i+1] + " ";
  39.  
  40.     console.log(outbuf);
  41. }
  42.  
  43. function test(a,b,c){
  44.     let result = a.map((x, i) => x + b[i] + c[i]);
  45.  
  46.     printarray(want);
  47.     printarray(result);
  48.  
  49.     for(let i = 0; i < result.length; ++i)
  50.         if(result[i] != want[i])
  51.             return false;
  52.  
  53.     return true;
  54. }
  55.  
  56. function nshift(arr, n){
  57.     let out = arr;
  58.  
  59.     for(let i = 0; i < n; ++i)
  60.         out = shift(out);
  61.  
  62.     return out;
  63. }
  64.  
  65. function ntest(a,b,c){
  66.     return test(nshift(A, a), nshift(B, b), nshift(C, c));
  67. }
  68.  
  69. function bruteforce(){
  70.     /* cubic loop, 512 iterations max */
  71.     for(let a = 0; a < 8; ++a)
  72.     for(let b = 0; b < 8; ++b)
  73.     for(let c = 0; c < 8; ++c)
  74.         if(ntest(a,b,c))
  75.             return console.log(`${a} left, ${b} left, ${c} left`);
  76. }
  77.  
  78. bruteforce();
Add Comment
Please, Sign In to add comment