List bachhex = new List(); List bach = new List(); int[,] chrompoint = new int[5, 2] { { 1888, 1889 }, { 1920, 1921 }, { 1928, 1929 }, { 1936, 1937 }, { 1944, 1945 } }; int[,] womenpointer = new int[10, 4] { { 368, 369, 2456, 2457 }, { 376, 377, 4160, 4161 }, { 384, 385, 5864, 5865 }, { 392, 393, 7000, 7001 }, { 400, 401, 8704, 8705 }, { 408, 409, 9272, 9273 }, { 416, 417, 10408, 10409 }, { 424, 425, 11544, 11545 }, { 432, 433, 12680, 12681 }, { 440, 441, 13248, 13249 } }; int[,] finalpos = new int[5, 4]; byte[,] finalwomen = new byte[5, 4] { { 0x00, 0x00, 0xF9, 0xB7 }, { 0x00, 0x00, 0xF9, 0xB7 }, { 0x00, 0x00, 0xF9, 0xB7 }, { 0x00, 0x00, 0xF9, 0xB7 }, { 0x00, 0x00, 0xF9, 0xB7 } }; byte[,] originchrom = new byte[5, 2] { { 0xD5, 0xB7 }, { 0x66, 0xB8 }, { 0x2B, 0xB8 }, { 0x89, 0xB8 }, { 0xEB, 0xB8 } }; private void button1_Click(object sender, EventArgs e) { string direc = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); string ultipath = new Uri(direc).LocalPath; File.WriteAllText(ultipath + @"\pairing.txt", string.Empty); File.WriteAllText(ultipath + @"\finalpairing.txt", string.Empty); List chrom = new List(); List waifu = new List(); List finale = new List(); List fifinale = new List(); Random rnd = new Random(); int waifuelem = 0; int chromelem = 0; using (StreamReader strt = new StreamReader(ultipath + @"\bachelorette.txt")) { string line; while ((line = strt.ReadLine()) != null) { waifu.Add(line); } } using (StreamReader strm = new StreamReader(ultipath + @"\chrom.txt")) { string line; while ((line = strm.ReadLine()) != null) { chrom.Add(line); } } var chromy = chrom.ToArray(); var wai = waifu.ToArray(); int cnt = 0; int[] norepeat = new int[waifu.Count]; do { norepeat[cnt] = 0; cnt = cnt + 1; } while (cnt < waifu.Count); chromelem = chrom.Count; waifuelem = waifu.Count; using (StreamWriter stwt = File.AppendText(ultipath + @"\pairing.txt")) { string pair = ""; int randy = 0; foreach (string element in chromy) { line1: randy = rnd.Next(0, waifuelem); if (norepeat[randy] > 0) { goto line1; } norepeat[randy] = randy; pair = "chrom" + "X" + wai[randy]; stwt.WriteLine(pair); } } using (StreamReader strv = new StreamReader(ultipath + @"\pairing.txt")) { string line; while ((line = strv.ReadLine()) != null) { finale.Add(line); } } using (StreamWriter stwd = File.AppendText(ultipath + @"\finalpairing.txt")) { foreach (string element in finale) { string[] pairing = element.Split(new string[] { "chromX" }, StringSplitOptions.RemoveEmptyEntries); foreach (string women in pairing) { fifinale.Add(women); stwd.WriteLine(women); } } } var verif = bach.ToArray(); int[,] women2 = new int[5,4]; int a = 0; int b = 0; int cnt3 = 0; // Assigning the first two byte of each empty byte in finalwomen array. foreach (string element in fifinale) { do { if (bach[a].Equals(element)) { do { finalwomen[cnt3, b] = originchrom[cnt3, b]; b = b + 1; } while (b < 2); b = 0; // Assigning the pointer for the position of the byte to change. do { finalpos[cnt3, b] = womenpointer[a, b]; b = b + 1; } while (b < 4); cnt3 = cnt3 + 1; } b = 0; a = a + 1; } while (a < 10); a = 0; } // Randomizing the potential wife of Chrom. var hexa = bachhex.ToArray(); int y = 0; int x = 0; int cnt2 = 0; foreach (string element in fifinale) { do { if (bach[x].Equals(element)) { do { chromwaifu[cnt2, y] = Convert.ToByte(hexa[y + (2 * x)], 16); y = y + 1; } while (y < 2); cnt2 = cnt2 + 1; } x = x + 1; y = 0; } while (x < 10); x = 0; } // Changing the bytes of the new wives to prevent the game crashes. y = 0; x = 0; cnt2 = 0; using (var strd = new FileStream(textBox1.Text + @"\static.bin", FileMode.Open, FileAccess.ReadWrite)) { do { do { strd.Position = finalpos[cnt2, y]; strd.WriteByte(finalwomen[cnt2, y]); y = y + 1; } while (y < 4); y = 0; cnt2 = cnt2 + 1; } while (cnt2 < 5); } y = 0; x = 0; cnt2 = 0; using (var str = new FileStream(textBox1.Text + @"\static.bin", FileMode.Open, FileAccess.ReadWrite)) { do { do { str.Position = chrompoint[cnt2,y]; str.WriteByte(chromwaifu[cnt2, y]); y = y + 1; } while (y < 2); y = 0; cnt2 = cnt2 + 1; } while (cnt2 < 5); } // Making the correct changes in the support. int[,] splv = new int[5, 4] { { 1892, 1893, 1894, 1895 }, { 1924, 1925, 1926, 1927 }, { 1932, 1933, 1934, 1935 }, { 1940, 1941, 1942, 1943 }, { 1948, 1949, 1950, 1951 } }; byte[] superpair = new byte[4] { 0x05, 0x0A, 0x10, 0x16 }; y = 0; x = 0; using (var str = new FileStream(textBox1.Text + @"\static.bin", FileMode.Open, FileAccess.ReadWrite)) { do { do { str.Position = splv[x, y]; str.WriteByte(superpair[y]); y = y + 1; } while (y < 4); y = 0; x = x + 1; } while (x < 5); } } byte[,] chromwaifu = new byte[5, 2] { { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 }, { 0x00, 0x00 } }; private void Form1_Load(object sender, EventArgs e) { string direc = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase); string ultipath = new Uri(direc).LocalPath; bach.Clear(); bachhex.Clear(); using (StreamReader strm = new StreamReader(ultipath + @"\waifu.txt")) { string line; while ((line = strm.ReadLine()) != null) { bach.Add(line); } } using (StreamReader strv = new StreamReader(ultipath + @"\chrombach.txt")) { string line; while ((line = strv.ReadLine()) != null) { bachhex.Add(line); } } } private void button2_Click(object sender, EventArgs e) { Form2 form = new Form2(); form.Show(); } }