UTIL_ScreenShake Broken in OB HL2MP Mod

Grab your favourite IDE and tinker with the innards of game engines

UTIL_ScreenShake Broken in OB HL2MP Mod

Postby Jman on Fri Dec 09, 2011 12:12 am

I was trying to add a bit of rumble to my weapons when firing, when I noticed no matter what I did the screen would not rumble using UTIL_ScreenShake. To check if I was just using the function wrong, I tested it out on a map with an env_shake and a trigger as well as trying the console command "shake". None of these methods gave me any shaking whatsoever, firing explosives near me and setting off grenades also had no effect.

I'm wondering why this has happened as I have not edited this function whatsoever and there's no other reports of such behaviour. Functions such as viewpunch still work properly however.

My current UTIL_ScreenShake function:
Code: Select all
const float MAX_SHAKE_AMPLITUDE = 16.0f;
void UTIL_ScreenShake( const Vector &center, float amplitude, float frequency, float duration, float radius, ShakeCommand_t eCommand, bool bAirShake )
{
   int         i;
   float      localAmplitude;

   if ( amplitude > MAX_SHAKE_AMPLITUDE )
   {
      amplitude = MAX_SHAKE_AMPLITUDE;
   }
   for ( i = 1; i <= gpGlobals->maxClients; i++ )
   {
      CBaseEntity *pPlayer = UTIL_PlayerByIndex( i );

      //
      // Only start shakes for players that are on the ground unless doing an air shake.
      //
      if ( !pPlayer || (!bAirShake && (eCommand == SHAKE_START) && !(pPlayer->GetFlags() & FL_ONGROUND)) )
      {
         continue;
      }

      localAmplitude = ComputeShakeAmplitude( center, pPlayer->WorldSpaceCenter(), amplitude, radius );

      // This happens if the player is outside the radius, in which case we should ignore
      // all commands
      if (localAmplitude < 0)
         continue;

      TransmitShakeEvent( (CBasePlayer *)pPlayer, localAmplitude, frequency, duration, eCommand );
   }
}
User avatar
Jman
Veteran
Veteran
 
Joined: Wed Mar 30, 2005 11:01 pm

Return to Programming

Who is online

Users browsing this forum: Google Adsense [Bot]