Last server records
Pro Nub

Bhop sound

Posted by Kpoluk 13 May 2023 in 12:14
As we've seen in the article about bhop physics, successful bhop happens with a certain combination of speed and number of FOG, i.e. frames spent on the ground. You can learn both in realtime from jump statistics, but depending on the community rules it might be forbidden or penalized in demo recording. This brings us to the question of bhop estimation without the help of stats. While magnitude of the speed can be guessed, the number of FOG might be determined only by the sound. There are some misconceptions regarding this matter in kreedz community, so we'll try to clear things up.


Step sounds


During the regular running on the ground step sounds are played every 0.3 seconds, i.e. 300 milliseconds. Counter which is responsible for it called flTimeStepSound, it's set equal to 300 in function PM_UpdateStepSound:


This function is called every frame from PM_PlayerMove, just like already familiar to us PM_ReduceTimers, where all counters including flTimeStepSound are reduced by duration of frame in milliseconds (which is 10 for 100 fps). When we jump of lj block, flTimeStepSound is decaying to zero in flight and stays like that until landing. And as soon as we land the counter is equaled to 300 again, and we hear the sound of step.

Note that at speeds below 150 units/s we leave PM_UpdateStepSound, hence our movement becomes silent. For example, it'll happen with held Shift, because speed with usp in this case is 250 * 0.52 = 130 units/s, and even with a scout we have only 260 * 0.52 = 135.2 units/s. And if the speed is high enough, we also need to set volume coefficient fvol which is equal to 0.5 for a regular run. Depending on circumstances volume and periodicity may change, for example on ladder and in duck volume is lower and played less often.

Now let's look into PM_PlayStepSound, which takes volume fvol and texture type step under us as arguments:


Here we choose a specific sound to play with 4 variants for each texture type. At that one pair of sounds convetionally corresponds to the right leg and another pair to the left leg, while variable iStepLeft alternates right and left legs for every step. Selection of sound in each pair happens randomly, so player cannot say for sure how exactly his next step will sound.


Double Duck sounds


From the article about countjump physics we've learned that we spend 21 frame in air between double ducks on a plane surface. It might seem that counter flTimeStepSound won't be zeroed in time and some double ducks will be silent. However CS engine has something for this situation as well - inside of function PM_UnDuck in case of successful transition of player's model into the standing state counter flTimeStepSound is lowered by 100. It means that one scroll duck in enough for flTimeStepSound to be lowered by 110 instead of 10 at the first frame in air. And if you do more scroll ducks in air, flTimeStepSound will turn into zero even sooner. So if you don't hear some of your double ducks on a plane surface, the only possible reason is that your speed is below 150 units/s.


Bhop sounds


Unlike double duck case, 300 millisecons is enough for regular bhop on a plane surface to zero flTimeStepSound in the air. Therefore at the moment of landing we hear the step sound. But there is more. Function PM_PlayStepSound is also called from PM_Jump, i.e. at the moment of jump (again if the speed is more than 150 units/s), at that volume coefficient is 1.0. If we spent only one frame on the ground during bhop, PM_PlayStepSound will be called in this frame twice - first one cause of landing and second cause of jumping. However the first sound will be ignored and we'll hear only the second one just as it is:


If we spent two frames on the ground they both sounds will be played. But since the time gap between them is very small they'll merge into one although the second sound still will be dominating (its volume is 1.0 against 0.5 for the first sound). The final result will depend on each particular case:


Here we can clearly see that only half of the pairs is different from their FOG1 analogs. For example, step1+step4 for FOG2 is more pronounced than step1+step4 for FOG1, but step3+step4 for FOG2 and FOG1 are almost identical. During consecutive bhops (without stops and double ducks) we will always hear either right step and than left step or vice versa. Hence from 8 variants of FOG2 only 4 will sound. Nevertheless even this fact won't really help us cause 2 of 4 pairs still will be indistinguishable from their FOG1 analogs.

Thus in half of the cases sound of FOG2 bhop is the same as FOG1. Moreover sound of each pair can vary occasionally. Here is an example of pair step3+step2, recorded in different sessions:


And even diversity shown on diagrams above is not that easy to hear. You can assure yourself by downloading sound files used for this article. There you can also find all variants for FOG3:


Here differences are more apparent, but in half of the cases they are still very hard to distinguish by ear. In the end bhop sound can give you some hint, but you cannot always tell the exact number of FOG with it.