コード例 #1
0
bool CWeaponCSBaseGun::Reload()
{
	CCSPlayer *pPlayer = GetPlayerOwner();
	if ( !pPlayer )
		return false;

	if (pPlayer->GetAmmoCount( GetPrimaryAmmoType() ) <= 0)
		return false;

	int iResult = DefaultReload( GetMaxClip1(), GetMaxClip2(), ACT_VM_RELOAD );
	if ( !iResult )
		return false;

	pPlayer->SetAnimation( PLAYER_RELOAD );

#ifndef CLIENT_DLL
	if ((iResult) && (pPlayer->GetFOV() != pPlayer->GetDefaultFOV()))
	{
		pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV() );
	}
#endif

	m_flAccuracy = 0.2;
	pPlayer->m_iShotsFired = 0;
	m_bDelayFire = false;

	pPlayer->SetShieldDrawnState( false );
	return true;
}
コード例 #2
0
void CWeaponScout::SCOUTFire( float flSpread )
{
    CCSPlayer *pPlayer = GetPlayerOwner();
    if (pPlayer == NULL)
    {
        Assert(pPlayer != NULL);
        return;
    }

    // If we are not zoomed in, or we have very recently zoomed and are still transitioning, the bullet diverts more.
    if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV() || (gpGlobals->curtime < m_zoomFullyActiveTime))
    {
        flSpread += 0.025;
    }

    if (pPlayer->GetFOV() != pPlayer->GetDefaultFOV())
    {
        pPlayer->m_bResumeZoom = true;
        pPlayer->m_iLastZoom = pPlayer->GetFOV();

#ifndef CLIENT_DLL
        pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.05f );
#endif
    }

    if ( !CSBaseGunFire( flSpread, GetCSWpnData().m_flCycleTime, true ) )
        return;

    QAngle angle = pPlayer->GetPunchAngle();
    angle.x -= 2;
    pPlayer->SetPunchAngle( angle );
}
コード例 #3
0
void CWeaponScout::SecondaryAttack()
{
#ifndef CLIENT_DLL
    CCSPlayer *pPlayer = GetPlayerOwner();
    if (pPlayer == NULL)
    {
        Assert(pPlayer != NULL);
        return;
    }

    if (pPlayer->GetFOV() == pPlayer->GetDefaultFOV())
    {
        pPlayer->SetFOV( pPlayer, 40, 0.15f );
    }
    else if (pPlayer->GetFOV() == 40)
    {
        pPlayer->SetFOV( pPlayer, 15, 0.05 );
    }
    else if (pPlayer->GetFOV() == 15)
    {
        pPlayer->SetFOV( pPlayer, pPlayer->GetDefaultFOV(), 0.05f );
    }

    pPlayer->ResetMaxSpeed();
#endif

    m_flNextSecondaryAttack = gpGlobals->curtime + 0.3;
    m_zoomFullyActiveTime = gpGlobals->curtime + 0.15; // The worst zoom time from above.

#ifndef CLIENT_DLL
    // If this isn't guarded, the sound will be emitted twice, once by the server and once by the client.
    // Let the server play it since if only the client plays it, it's liable to get played twice cause of
    // a prediction error. joy.
    EmitSound( "Default.Zoom" ); // zoom sound

    // let the bots hear the rifle zoom
    IGameEvent * event = gameeventmanager->CreateEvent( "weapon_zoom" );
    if( event )
    {
        event->SetInt( "userid", pPlayer->GetUserID() );
        gameeventmanager->FireEvent( event );
    }
#endif
}
コード例 #4
0
float CWeaponScout::GetMaxSpeed() const
{
    CCSPlayer *pPlayer = GetPlayerOwner();
    if (pPlayer == NULL)
    {
        Assert(pPlayer != NULL);
        return BaseClass::GetMaxSpeed();
    }

    if ( pPlayer->GetFOV() == pPlayer->GetDefaultFOV() )
        return BaseClass::GetMaxSpeed();
    else
        return 220;	// zoomed in.
}