#programming #gtav #gta5
05.07.2025 05:14 β π 0 π 0 π¬ 0 π 0@atmossig.bsky.social
#programming #gtav #gta5
05.07.2025 05:14 β π 0 π 0 π¬ 0 π 0P.S my bad if wording sucks or I got anything wrong lmao. I tried my best to explain it.
05.07.2025 05:13 β π 0 π 0 π¬ 0 π 0Thanks for reading! More to come soon. Gonna tackle fixing some other bugs e.g., cloth freaking out at high fps and general choppiness at high fps, incl a bug with Franklin using his special ability too fast and it pauses dialog for too long.
05.07.2025 05:13 β π 0 π 0 π¬ 1 π 0-and we got higher refresh rate monitors and we could run older titles at higher frame rates, it pushes beyond the 60FPS target, so it leads to the bug.
05.07.2025 05:13 β π 0 π 0 π¬ 1 π 0It was set as 60 since the game would never go above it, it couldn't even reach it, they probably had internal PC versions that would play it on a 60hz monitor (refresh rate lock) so this issue would've never happened to them.
When newer monitors came out and as hardware improved-
-which is the correct state. This remains true for any framerate.
== HOW IT MIGHT'VE SLIPPED THROUGH ==
Easy, fixed development hardware, this game was made originally for the PS3/XENON hardware (Xbox 360), which ran the game at around 30fps~, dipped lower but still, target fps was 30.
-there is a 42.8& chance that the number will be less than the fraction, causing iAmmoToDeplete to become 1.
Over the course of 140 frames in one second, this will approx happen 42.8% of the time (140 * 0.428 β 60).
The total ammo depleted in that second will be ~60 units-
The fix works by calculating the ideal depletion ratio as a float. For Example, at 140 FPS, the ratio is (1/140) / (1/60) which is approx 0.428
The integer part (0) is taken as the base amount to deplete.
The fractional part of (0.428) is used as the chance
A random number is generated-
Now testing again once we recompile it...
Yep, it's fixed! We can pour the gas can at 60FPS perfectly fine, and when we go-to 240FPS (way higher than 60FPS) we pour the same amount of fuel as before!
== CORRECTED CODE ==
To solve this, the logic had to be replaced entirely lmao, it has to handle fractional depletion values that occur at high frame rates. The final solution was to use a probably-based approach to ensure the avg. depletion rate is always consistent.
So when at any FPS above 60, e.g., 140, it is behaved as if it was at 60FPS, it calculated iAmmoToDeplete as 1, but since it is doing this for every single one of those 140 frames per second, the can drains at a rate of 140 units/sec, more than twice as fast it should normally.
05.07.2025 05:13 β π 0 π 0 π¬ 1 π 0At any FPS above 60, the fwTimer::GetTimeStep() becomes smaller than the 60FPS baseline. The MAX function then incorrectly discards the real (and smaller) delta time, and instead uses the larger fBaseTimeStepSeconds.
05.07.2025 05:13 β π 0 π 0 π¬ 1 π 0HOWEVER! The line
const float fCurrentTimeStep = MAX( fwTimer::GetTimeStep(), fBaseTimeStepSeconds );
Introduces a bug.
At 60FPS or below, it works correctly, fwTimer::GetTimeStep() will be 1.0/60.0 or greater, so the MAX function chooses the correct delta time.
So for example, draining the can in 10 seconds regardless of FPS.
== ORIGINAL FLAWED CODE ==
Formatted to fit, not what it looks like in og.
Whoever was developing this correctly identified the need for the baseline fBaseTimeStepSeconds and to use the actual time per frame fwTimer::GetTimeStep()
-to emit a continuous stream of "effect", which, the Petrol Can does.
The primary job of it is to handle this continuous action and most importantly deplete the weapon's ammo over time as the player holds the fire button.
The goal of the depletion is to happen at a constant rate of course.
In "Weapon.cpp" the code that controls the jerry can pouring logic is a method called CWeapon::FireVolumetric
This methods determines how a weapon behaves when used. Other weapons use FireDelayedHit or FireProjectile, for this, it uses FireVolumetric, it's a special case designed for weapons-
The code for the weapons is stored in "game\Weapons\Weapon.cpp" along with tons of other code for things like debugging, accuracy, bullet, explosion, etc.
== ABOUT THE CODE ==
As you can see in the 2nd clip, when I go to 240fps, it pours WAYY faster, like WAYY too fast. Let's fix it, since that should NOT be happening...
05.07.2025 05:13 β π 0 π 0 π¬ 1 π 0In Grand Theft Auto V, when your fps is anywhere above 60FPS the gas can will pour faster than if you were on 60FPS
Video of issue attached, 1st is at 60, 2nd is at 240 fps (my monitor refresh rate)
Fixing GTA 5 Gas Can pouring tied to FPS
A threadπ§΅
(more to come soon since it's interesting asf to me)
In Grand Theft Auto V that when your fps is anywhere above 60FPS the gas can will pour faster than if you were on 60FPS
Let's dive in!
hey!! iβd like to be friends!! :))
30.12.2024 00:00 β π 0 π 0 π¬ 0 π 0do you need somebody to talk to?
11.12.2024 13:24 β π 2 π 0 π¬ 1 π 0I JUST SPENT MY LIFE SAVINGS ON HAWK TUAH COIN.
05.12.2024 00:09 β π 49 π 5 π¬ 7 π 0game dev pro tip:
if you're struggling with motivation, try setting realistic goals
like "today i will open the project folder"
or maybe even "today i will look at one (1) line of code"
Pictures as of recent.
18.11.2024 22:07 β π 2 π 0 π¬ 0 π 0random
11.11.2024 23:40 β π 2 π 0 π¬ 0 π 0Photos from 2022 at the beach I edited in photoshop today
Camera | Canon EOS 30D
Tried making hyperpop art of Spamton Neo.
#deltarune #hyperpop #fanart
more :)
31.10.2024 15:11 β π 2 π 0 π¬ 0 π 04 of my favorite photos Iβve taken these past couple months.
31.10.2024 14:24 β π 8 π 0 π¬ 1 π 0