Esempio n. 1
0
//-----------------------------------------------------------------------------
// Purpose: Don't render the weapon if its supposed to be lowered and we have
// finished the lowering animation
//-----------------------------------------------------------------------------
int CTFViewModel::DrawModel( int flags )
{
    // Check for lowering the weapon
    C_TFPlayer *pPlayer = C_TFPlayer::GetLocalTFPlayer();

    Assert( pPlayer );

    bool bLowered = pPlayer->IsWeaponLowered();

    if ( bLowered && fabs( m_vLoweredWeaponOffset.x - cl_gunlowerangle.GetFloat() ) < 0.1 )
    {
        // fully lowered, stop drawing
        return 1;
    }

    C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer();
    if ( pLocalPlayer && pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE &&
            pLocalPlayer->GetObserverTarget() && pLocalPlayer->GetObserverTarget()->IsPlayer() )
    {
        pPlayer = ToTFPlayer( pLocalPlayer->GetObserverTarget() );

        if ( pPlayer != GetOwner() )
            return 0;
    }

    if ( pPlayer->IsAlive() == false )
    {
        return 0;
    }

    return BaseClass::DrawModel( flags );
}
Esempio n. 2
0
void CTFViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles )
{
#if defined( CLIENT_DLL )

    Vector vecNewOrigin = eyePosition;
    QAngle vecNewAngles = eyeAngles;

    // Check for lowering the weapon
    C_TFPlayer *pPlayer = ToTFPlayer( owner );

    Assert( pPlayer );

    bool bLowered = pPlayer->IsWeaponLowered();

    QAngle vecLoweredAngles(0,0,0);

    m_vLoweredWeaponOffset.x = Approach( bLowered ? cl_gunlowerangle.GetFloat() : 0, m_vLoweredWeaponOffset.x, cl_gunlowerspeed.GetFloat() );
    vecLoweredAngles.x += m_vLoweredWeaponOffset.x;

    vecNewAngles += vecLoweredAngles;


    // Viewmodel offset
    Vector	forward, right, up;
    AngleVectors(eyeAngles, &forward, &right, &up);
    vecNewOrigin += forward*v_viewmodel_offset_x.GetFloat() + right*v_viewmodel_offset_y.GetFloat() + up*v_viewmodel_offset_z.GetFloat();

    if (owner->GetActiveWeapon())
        ToTFPlayer(owner)->GetActiveTFWeapon()->UpdateViewModel();

    BaseClass::CalcViewModelView( owner, vecNewOrigin, vecNewAngles );

#endif
}