diff --git a/ChaosMod/Components/DebugSocket.cpp b/ChaosMod/Components/DebugSocket.cpp index 1cbc20063..96427047b 100644 --- a/ChaosMod/Components/DebugSocket.cpp +++ b/ChaosMod/Components/DebugSocket.cpp @@ -99,7 +99,7 @@ static void OnExecScript(DebugSocket *debugSocket, std::shared_ptr 1 ? cachedSoundFiles[g_Random.GetRandomInt(0, size - 1)] : cachedSoundFiles[0]; + auto chosenSound = size > 1 ? cachedSoundFiles[g_RandomNoDeterm.GetRandomInt(0, size - 1)] : cachedSoundFiles[0]; int error; { diff --git a/ChaosMod/Components/Voting.cpp b/ChaosMod/Components/Voting.cpp index 861287ed2..8d4aba2ed 100644 --- a/ChaosMod/Components/Voting.cpp +++ b/ChaosMod/Components/Voting.cpp @@ -227,7 +227,7 @@ void Voting::OnRun() totalWeight += effectData.GetEffectWeight(); } - float chosen = g_Random.GetRandomFloat(0.f, totalWeight); + float chosen = g_RandomNoDeterm.GetRandomFloat(0.f, totalWeight); totalWeight = 0.f; diff --git a/ChaosMod/Main.cpp b/ChaosMod/Main.cpp index 74f35ea65..b64eb44e9 100644 --- a/ChaosMod/Main.cpp +++ b/ChaosMod/Main.cpp @@ -145,6 +145,7 @@ static void Init() g_OptionsManager.GetConfigValue({ "EffectTimedTimerColor" }, OPTION_DEFAULT_TIMED_COLOR)); g_Random.SetSeed(g_OptionsManager.GetConfigValue({ "Seed" }, 0)); + g_RandomNoDeterm.SetSeed(GetTickCount64()); std::set blacklistedComponentNames; if (DoesFeatureFlagExist("blacklistedcomponents")) diff --git a/ChaosMod/Util/Color.h b/ChaosMod/Util/Color.h index 33796fe34..f5f62ff8b 100644 --- a/ChaosMod/Util/Color.h +++ b/ChaosMod/Util/Color.h @@ -16,10 +16,10 @@ struct Color inline Color GetRandomColorRGB(std::uint8_t min = 0, std::uint8_t max = 255) { return { - (std::uint8_t)g_Random.GetRandomInt(min, max), // R - (std::uint8_t)g_Random.GetRandomInt(min, max), // G - (std::uint8_t)g_Random.GetRandomInt(min, max), // B - 255 // A + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // R + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // G + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // B + 255 // A }; } @@ -27,9 +27,9 @@ inline Color GetRandomColorRGB(std::uint8_t min = 0, std::uint8_t max = 255) inline Color GetRandomColorRGBA(std::uint8_t min = 0, std::uint8_t max = 255) { return { - (std::uint8_t)g_Random.GetRandomInt(min, max), // R - (std::uint8_t)g_Random.GetRandomInt(min, max), // G - (std::uint8_t)g_Random.GetRandomInt(min, max), // B - (std::uint8_t)g_Random.GetRandomInt(min, max) // A + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // R + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // G + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max), // B + (std::uint8_t)g_RandomNoDeterm.GetRandomInt(min, max) // A }; } \ No newline at end of file diff --git a/ChaosMod/Util/PoolSpawner.cpp b/ChaosMod/Util/PoolSpawner.cpp index 000aa747c..0dcb7dd1c 100644 --- a/ChaosMod/Util/PoolSpawner.cpp +++ b/ChaosMod/Util/PoolSpawner.cpp @@ -140,7 +140,7 @@ Ped CreateRandomPoolPed(float x, float y, float z, float heading) Ped ped; if (!pedModels.empty()) { - Hash model = pedModels[g_Random.GetRandomInt(0, pedModels.size() - 1)]; + Hash model = pedModels[g_RandomNoDeterm.GetRandomInt(0, pedModels.size() - 1)]; ped = CreatePoolPed(4, model, x, y, z, heading); } @@ -154,20 +154,20 @@ Ped CreateRandomPoolPed(float x, float y, float z, float heading) for (int i = 0; i < 12; i++) { int drawableAmount = GET_NUMBER_OF_PED_DRAWABLE_VARIATIONS(ped, i); - int drawable = drawableAmount == 0 ? 0 : g_Random.GetRandomInt(0, drawableAmount - 1); + int drawable = drawableAmount == 0 ? 0 : g_RandomNoDeterm.GetRandomInt(0, drawableAmount - 1); int textureAmount = GET_NUMBER_OF_PED_TEXTURE_VARIATIONS(ped, i, drawable); - int texture = textureAmount == 0 ? 0 : g_Random.GetRandomInt(0, textureAmount - 1); + int texture = textureAmount == 0 ? 0 : g_RandomNoDeterm.GetRandomInt(0, textureAmount - 1); - SET_PED_COMPONENT_VARIATION(ped, i, drawable, texture, g_Random.GetRandomInt(0, 3)); + SET_PED_COMPONENT_VARIATION(ped, i, drawable, texture, g_RandomNoDeterm.GetRandomInt(0, 3)); if (i < 4) { int propDrawableAmount = GET_NUMBER_OF_PED_PROP_DRAWABLE_VARIATIONS(ped, i); - int propDrawable = propDrawableAmount == 0 ? 0 : g_Random.GetRandomInt(0, propDrawableAmount - 1); + int propDrawable = propDrawableAmount == 0 ? 0 : g_RandomNoDeterm.GetRandomInt(0, propDrawableAmount - 1); - int propTextureAmount = GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(ped, i, drawable); - int propTexture = propTextureAmount == 0 ? 0 : g_Random.GetRandomInt(0, propTextureAmount - 1); + int propTextureAmount = GET_NUMBER_OF_PED_PROP_TEXTURE_VARIATIONS(ped, i, drawable); + int propTexture = propTextureAmount == 0 ? 0 : g_RandomNoDeterm.GetRandomInt(0, propTextureAmount - 1); SET_PED_PROP_INDEX(ped, i, propDrawable, propTexture, true); } diff --git a/ChaosMod/Util/Random.h b/ChaosMod/Util/Random.h index 8743ee5fb..ac0c17c78 100644 --- a/ChaosMod/Util/Random.h +++ b/ChaosMod/Util/Random.h @@ -31,3 +31,4 @@ class Random }; inline Random g_Random; +inline Random g_RandomNoDeterm; \ No newline at end of file diff --git a/ChaosMod/Util/Vehicle.h b/ChaosMod/Util/Vehicle.h index 12fd46f14..93b76d928 100644 --- a/ChaosMod/Util/Vehicle.h +++ b/ChaosMod/Util/Vehicle.h @@ -98,7 +98,7 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< Hash newVehModel = 0; do { - newVehModel = vehicleModels[g_Random.GetRandomInt(0, vehicleModels.size() - 1)]; + newVehModel = vehicleModels[g_RandomNoDeterm.GetRandomInt(0, vehicleModels.size() - 1)]; } while (GET_VEHICLE_MODEL_NUMBER_OF_SEATS(newVehModel) < seatPeds.size() || IS_THIS_MODEL_A_TRAIN(newVehModel) || GET_VEHICLE_MODEL_ACCELERATION(newVehModel) <= 0); @@ -170,35 +170,36 @@ inline Vehicle CreateRandomVehicleWithPeds(Vehicle oldHandle, const std::vector< // Also apply random upgrades SET_VEHICLE_MOD_KIT(newVehicle, 0); - SET_VEHICLE_WHEEL_TYPE(newVehicle, g_Random.GetRandomInt(0, 12)); + SET_VEHICLE_WHEEL_TYPE(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 12)); for (int i = 0; i < 50; i++) { int max = GET_NUM_VEHICLE_MODS(newVehicle, i); if (max > 0) { - SET_VEHICLE_MOD(newVehicle, i, g_Random.GetRandomInt(0, max - 1), g_Random.GetRandomInt(0, 1)); + SET_VEHICLE_MOD(newVehicle, i, g_RandomNoDeterm.GetRandomInt(0, max - 1), + g_RandomNoDeterm.GetRandomInt(0, 1)); } - TOGGLE_VEHICLE_MOD(newVehicle, i, g_Random.GetRandomInt(0, 1)); + TOGGLE_VEHICLE_MOD(newVehicle, i, g_RandomNoDeterm.GetRandomInt(0, 1)); } - SET_VEHICLE_TYRES_CAN_BURST(newVehicle, g_Random.GetRandomInt(0, 1)); - SET_VEHICLE_WINDOW_TINT(newVehicle, g_Random.GetRandomInt(0, 6)); + SET_VEHICLE_TYRES_CAN_BURST(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 1)); + SET_VEHICLE_WINDOW_TINT(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 6)); - SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(newVehicle, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), - g_Random.GetRandomInt(0, 255)); - SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(newVehicle, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), - g_Random.GetRandomInt(0, 255)); + SET_VEHICLE_CUSTOM_PRIMARY_COLOUR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 255), + g_RandomNoDeterm.GetRandomInt(0, 255), g_RandomNoDeterm.GetRandomInt(0, 255)); + SET_VEHICLE_CUSTOM_SECONDARY_COLOUR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 255), + g_RandomNoDeterm.GetRandomInt(0, 255), g_RandomNoDeterm.GetRandomInt(0, 255)); - _SET_VEHICLE_NEON_LIGHTS_COLOUR(newVehicle, g_Random.GetRandomInt(0, 255), g_Random.GetRandomInt(0, 255), - g_Random.GetRandomInt(0, 255)); + _SET_VEHICLE_NEON_LIGHTS_COLOUR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 255), + g_RandomNoDeterm.GetRandomInt(0, 255), g_RandomNoDeterm.GetRandomInt(0, 255)); for (int i = 0; i < 4; i++) { _SET_VEHICLE_NEON_LIGHT_ENABLED(newVehicle, i, true); } - _SET_VEHICLE_XENON_LIGHTS_COLOR(newVehicle, g_Random.GetRandomInt(0, 12)); + _SET_VEHICLE_XENON_LIGHTS_COLOR(newVehicle, g_RandomNoDeterm.GetRandomInt(0, 12)); return newVehicle; }