Ejemplo n.º 1
0
        /// <summary>
        /// Get All Entity
        /// </summary>
        /// <param name="substring"></param>
        /// <param name="level"></param>
        /// <param name="temp"></param>
        public static void FillLocationsList(string[] substring, PathCreatorOld level, out List <int[]> temp)
        {
            temp = new List <int[]>();
            int romIndex, count;

            // Foreach room subsection
            for (int j = 0; j < substring.Length; j++)
            {
                //Format for picking individual items (useful for preventing items from spawning in the wrong location, and keeping items located in the right subroom)
                if (substring[j].Contains("-"))
                {
                    bool foundEntity = false;
                    int  roomIndex   = int.Parse(substring[j].Split('-')[0]); // Get the room index
                    romIndex = level.rooms[roomIndex].EntityListIndex + 2;    // Entity list index

                    count = 0;
                    while (romBuffer[romIndex] != 0xFF)
                    {
                        if (romBuffer[romIndex] < 0x10)
                        {
                            if (!foundEntity && count++ == int.Parse(substring[j].Split('-')[1]))
                            {
                                foundEntity = true;
                                temp.Add(new int[] { romIndex, roomIndex, int.Parse(substring[j].Split('-')[2]) });
                            }
                        }
                        romIndex += 3;
                    }
                }
                else
                {
                    int levelIndex = int.Parse(substring[j]);                            // Get the room index
                    romIndex = level.rooms[int.Parse(substring[j])].EntityListIndex + 2; // Entity list index

                    while (romBuffer[romIndex] != 0xFF)                                  // foreach entity in the room
                    {
                        if (romBuffer[romIndex] < 0x10)                                  // Add entity if it's an essential item (chest, keyzer, etc.)
                        {
                            temp.Add(new int[] { romIndex, levelIndex, 0 });             // Add each entity to list, assuming all are contained in one sub room
                        }

                        romIndex += 3; // NEEEEEEEEEEXT!!
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public static void OldMain(string[] args)
        {
            if (args.Length == 0)
            {
                args = new string[] { directory + "\\wl4.gba" };
            }

            randomizedRomName = args[0];
            File.Copy(randomizedRomName, directory + "\\backup\\" + randomizedRomName.Substring(randomizedRomName.LastIndexOf('\\') + 1, randomizedRomName.LastIndexOf('.') - randomizedRomName.LastIndexOf('\\') - 1) + ".gba");

            string  patch        = directory + "\\flips\\patch.ips";
            Process patchProcess = Process.Start(LunarIPSPath, patch);

            Console.ReadLine();
            return;

            //Get the options and "Which rooms to randomize" documents
            string optionsPath       = directory + "\\options.txt";
            string roomInfoPath      = directory + "\\rooms.txt";
            string roomRandoInfoPath = directory + "\\path.txt";

            if (!File.Exists(optionsPath)) // Recreate options page if gone
            {
                File.Create(optionsPath).Close();
                options = new string[] { directory, "True" };
            }
            if (!File.Exists(roomInfoPath)) // If not able to find room info, return.  Unable to recreate room page.  Too much data to put into text
            {
                return;
            }

            // If rom isn't selected, quit
            if (args.Length == 0 || !File.Exists(args[0]))
            {
                return;
            }

            // Get old rom Path
            string oldPath = args[0];

            // Read rom
            romBuffer = File.ReadAllBytes(args[0]);

            // Get RNG

            // Set new rom path
            string newPath = args[0];

            newPath = newPath.Remove(newPath.LastIndexOf('\\') + 1) + "WL4-Randomizer_" + "Test" + ".gba";

            PathCreatorOld[] levels = new PathCreatorOld[18];
            int levelIndex          = 0;

            // Read path file, to get room randomizer info
            string[] rooms = File.ReadAllLines(roomRandoInfoPath);

            for (int i = 0; i < rooms.Length; i++)
            {
                if (rooms[i] == "") // Ignore all empty lines
                {
                    continue;
                }

                if (rooms[i][0] == 'L')
                {
                    if (rooms[i + 1] == "")
                    {
                        levelIndex++;
                        continue;
                    }
                    //levels[levelIndex] = new PathCreatorOld(ref romBuffer, byte.Parse(rooms[i][1].ToString()), byte.Parse(rooms[i][2].ToString()), ref rooms, i + 1);
                    levelIndex++;
                }
            }

            rooms = File.ReadAllLines(roomInfoPath);

            string[]        substring;
            List <RoomNode> indicies1;
            List <int[]>    frogIndexes, chestIndexes;
            int             romIndex;

            levelIndex = 0;
            for (int i = 0; i < rooms.Length; i++)
            {
                if (rooms[i].Length == 0)
                {
                    continue;
                }
                if (rooms[i][0] == 'M')
                {
                    if (rooms[i + 1] == "")                                         // If level isn't complete, give notes to help complete entity randomizer
                    {
                        for (int j = 0; j < rooms[i].Length / TXT_ROOM_LENGTH; j++) // Get all rooms
                        {
                            romIndex = int.Parse(rooms[i].Substring(j * TXT_ROOM_LENGTH + 8, 2));

                            int offset = Convert.ToInt32("0x" + rooms[i].Substring(j * TXT_ROOM_LENGTH + 1, 6), 16);
                            int start  = offset;
                            offset += 2;

                            while (romBuffer[offset] != 0xFF)
                            {
                                Console.Write(start.ToString("X6") + " - ");
                                WriteEntity(offset);

                                offset += 3;
                            }
                            Console.WriteLine();
                        }

                        Console.ReadKey();
                        return;
                    }

                    indicies1 = new List <RoomNode>();
                    for (int j = 0; j < rooms[i].Length / TXT_ROOM_LENGTH; j++) // Get all rooms
                    {
                        romIndex = int.Parse(rooms[i].Substring(j * TXT_ROOM_LENGTH + 8, 2));

                        indicies1.Add(levels[levelIndex].rooms[romIndex]);
                        levels[levelIndex].rooms[romIndex].EntityListIndex = Convert.ToInt32("0x" + rooms[i].Substring(j * TXT_ROOM_LENGTH + 1, 6), 16);
                    }

                    frogIndexes  = new List <int[]>();
                    chestIndexes = new List <int[]>();

                    // Get frog locations
                    i++;
                    substring = rooms[i].Split(',');

                    FillLocationsList(substring, levels[levelIndex], out frogIndexes);

                    // Get chest locations
                    i++;
                    substring = rooms[i].Split(',');

                    FillLocationsList(substring, levels[levelIndex], out chestIndexes);

                    //CDLess.ChangeNormal(indicies1.ToArray(), frogIndexes.ToArray(), chestIndexes.ToArray(), ref romBuffer, rngGen, levels[levelIndex]);

                    levelIndex++;
                }
            }

            // Shuffle Levels

            Console.ReadKey();

            File.WriteAllBytes(newPath, romBuffer);
        }