Skip to content

kusabana/vsp-grenade-render-fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

~kusabana/vsp-grenade-render-fix

Fix for grenades not rendering at the start of their lifetime

The problem

CBaseCSGrenadeProjectile::DrawModel1

int CBaseCSGrenadeProjectile::DrawModel( int flags )
{
    // During the first half-second of our life, don't draw ourselves if he's
    // still playing his throw animation.
    // (better yet, we could draw ourselves in his hand).
    if ( GetThrower() != C_BasePlayer::GetLocalPlayer() )
    {
        if ( gpGlobals->curtime - m_flSpawnTime < 0.5 )
        {
            C_CSPlayer *pPlayer = dynamic_cast<C_CSPlayer*>( GetThrower() );
            if ( pPlayer && pPlayer->m_PlayerAnimState->IsThrowingGrenade() )
            {
                return 0;
            }
        }
    }

    return BaseClass::DrawModel( flags );
}

This is however not desireable for some community servers running custom gamemodes that make use of the grenade projectiles, like Trikz.2

The solution

There are three variables that control whether or not the game will wait before rendering the grenade projectile:

  • m_flSpawnTime
  • m_hThrower
  • m_PlayerAnimState

The m_flSpawnTime variable is set by the client. Since the goal is to resolve the issue without any client-side modifications, this option isn't viable.

While m_PlayerAnimState might technically be usable, it would require interfering with the animation playback.

This leaves m_hThrower, which we can just set to be an invalid handle in order to get past the innermost if statement.

Footnotes

  1. game/shared/cstrike/basecsgrenade_projectile.cpp Line 73

  2. A cooporative movement gamemode. Although there doesn't exist any good resources describing Trikz as a whole, there are a lot of videos online showcasing it like this

About

Fix for grenades not rendering at the start of their lifetime

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published