/// <summary> /// Initializes the in-game objects so they can be managed using the API. /// </summary> protected void Initialize() { try { active = true; memoryManager = new MemoryManager(process); while (!initialized && active) { if (GetCurrentMenu() != 0 && GetCurrentMenu() != Menu.Loading && GetCurrentMenu() != Menu.Initializing) { initialized = true; // Core functionality is now initialized InitializedType = InitializedType.Core; Initialized(InitializedType.Core); while (active && !IsRaceRunning) { // Wait until a race has been started so the drivers can be initialized Thread.Sleep((int)Settings.RefreshRate); } if (!active) // When the client closes before a race has been started { return; // Stop initializing } do { // Reset the player to a null value to prevent a memory overflow Player = null; // There is a small time between the starting of a race and the actual start, // so the thread will continue to run for a small time until the local players X-coordinate // is actually filled with correct data, which is a good way to test if the race has actually been started. Player = new Player(memoryManager, DRIVER_BASE, PLAYER_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Thread.Sleep((int)Settings.RefreshRate); }while (active && (Player == null || Player.X == 0)); Opponents = new Opponent[5]; Opponents[0] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_1_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[1] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_2_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[2] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_3_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[3] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_4_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[4] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_5_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); InitializedType = InitializedType.Both; Initialized(InitializedType.Drivers); } Thread.Sleep((int)Settings.RefreshRate); } } catch (Exception exc) { Console.WriteLine(exc); } }
/// <summary> /// Initializes the in-game objects so they can be managed using the API. /// </summary> protected void Initialize() { try { active = true; memoryManager = new MemoryManager(process); while (!initialized && active) { if (GetCurrentMenu() != 0 && GetCurrentMenu() != Menu.Loading && GetCurrentMenu() != Menu.Initializing) { initialized = true; // Core functionality is now initialized InitializedType = InitializedType.Core; Initialized(InitializedType.Core); while (active && !IsRaceRunning) { // Wait until a race has been started so the drivers can be initialized Thread.Sleep((int)Settings.RefreshRate); } if (!active) // When the client closes before a race has been started return; // Stop initializing do { // Reset the player to a null value to prevent a memory overflow Player = null; // There is a small time between the starting of a race and the actual start, // so the thread will continue to run for a small time until the local players X-coordinate // is actually filled with correct data, which is a good way to test if the race has actually been started. Player = new Player(memoryManager, DRIVER_BASE, PLAYER_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Thread.Sleep((int)Settings.RefreshRate); } while (active && (Player == null || Player.X == 0)); Opponents = new Opponent[5]; Opponents[0] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_1_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[1] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_2_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[2] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_3_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[3] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_4_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); Opponents[4] = new Opponent(memoryManager, DRIVER_BASE, ENEMY_5_BASE_OFFSETS, DRIVER_OFFSET_COORDINATE_X, DRIVER_OFFSET_COORDINATE_Y, DRIVER_OFFSET_COORDINATE_Z, DRIVER_OFFSET_SPEED_X, DRIVER_OFFSET_SPEED_Y, DRIVER_OFFSET_SPEED_Z, DRIVER_OFFSET_VECTOR_X1, DRIVER_OFFSET_VECTOR_Y1, DRIVER_OFFSET_VECTOR_Z1, DRIVER_OFFSET_VECTOR_X2, DRIVER_OFFSET_VECTOR_Y2, DRIVER_OFFSET_VECTOR_Z2, DRIVER_OFFSET_BRICK, DRIVER_OFFSET_WHITEBRICKS, POWERUP_RED_ADDRESS, POWERUP_BLUE_ADDRESS, POWERUP_GREEN_ADDRESS, POWERUP_YELLOW_ADDRESS); InitializedType = InitializedType.Both; Initialized(InitializedType.Drivers); } Thread.Sleep((int)Settings.RefreshRate); } } catch (Exception exc) { Console.WriteLine(exc); } }