当前位置: 首页>>代码示例>>C++>>正文


C++ UTIL_SharedRandomFloat函数代码示例

本文整理汇总了C++中UTIL_SharedRandomFloat函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_SharedRandomFloat函数的具体用法?C++ UTIL_SharedRandomFloat怎么用?C++ UTIL_SharedRandomFloat使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了UTIL_SharedRandomFloat函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: RANDOM_FLOAT

/*
=====================
CBaseEntity::FireBulletsPlayer

Only produces random numbers to match the server ones.
=====================
*/
Vector CBaseEntity::FireBulletsPlayer ( ULONG cShots, Vector vecSrc, Vector vecDirShooting, Vector vecSpread, float flDistance, int iBulletType, int iTracerFreq, int iDamage, entvars_t *pevAttacker, int shared_rand )
{
	float x = 0.0, y = 0.0, z;

	for ( ULONG iShot = 1; iShot <= cShots; iShot++ )
	{
		if ( pevAttacker == NULL )
		{
			// get circular gaussian spread
			do {
					x = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);
					y = RANDOM_FLOAT(-0.5, 0.5) + RANDOM_FLOAT(-0.5, 0.5);
					z = x*x+y*y;
			} while (z > 1);
		}
		else
		{
			//Use player's random seed.
			// get circular gaussian spread
			x = UTIL_SharedRandomFloat( shared_rand + iShot, -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 1 + iShot ) , -0.5, 0.5 );
			y = UTIL_SharedRandomFloat( shared_rand + ( 2 + iShot ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( shared_rand + ( 3 + iShot ), -0.5, 0.5 );
			z = x * x + y * y;
		}
			
	}

    return Vector ( x * vecSpread.x, y * vecSpread.y, 0.0 );
}
开发者ID:Skumek,项目名称:hlsdk,代码行数:35,代码来源:hl_weapons.cpp

示例2: PlayEmptySound

void CG3SG1::G3SG1Fire(float flSpread, float flCycleTime, BOOL fUseAutoAim)
{
	if (m_pPlayer->pev->fov == 90)
		flCycleTime += 0.025;

	if (m_flLastFire)
	{
		m_flAccuracy = (gpGlobals->time - m_flLastFire) * 0.3 + 0.55;

		if (m_flAccuracy > 0.98)
			m_flAccuracy = 0.98;
	}
	else
		m_flAccuracy = 0.98;

	m_flLastFire = gpGlobals->time;

	if (m_iClip <= 0)
	{
		if (m_fFireOnEmpty)
		{
			PlayEmptySound();
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.2;
		}

		return;
	}

	m_iClip--;
	m_pPlayer->pev->effects |= EF_MUZZLEFLASH;
	m_pPlayer->SetAnimation(PLAYER_ATTACK1);

	UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);

	m_pPlayer->m_iWeaponVolume = BIG_EXPLOSION_VOLUME;
	m_pPlayer->m_iWeaponFlash = NORMAL_GUN_FLASH;

	Vector vecDir = FireBullets3(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, flSpread, 8192, 3, BULLET_PLAYER_762MM, 80, 0.98, m_pPlayer->pev, TRUE, m_pPlayer->random_seed);

	int flags;
#ifdef CLIENT_WEAPONS
	flags = FEV_NOTHOST;
#else
	flags = 0;
#endif

	PLAYBACK_EVENT_FULL(flags, ENT(m_pPlayer->pev), m_usFireG3SG1, 0, (float *)&g_vecZero, (float *)&g_vecZero, vecDir.x, vecDir.y, (int)(m_pPlayer->pev->punchangle.x * 100), (int)(m_pPlayer->pev->punchangle.y * 100), TRUE, FALSE);
	m_flNextPrimaryAttack = m_flNextSecondaryAttack = UTIL_WeaponTimeBase() + flCycleTime;

	if (!m_iClip && m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
		m_pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);

	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.8;

	m_pPlayer->pev->punchangle.x -= UTIL_SharedRandomFloat(m_pPlayer->random_seed + 4, 2.75, 3.25) + m_pPlayer->pev->punchangle.x * 0.25;
	m_pPlayer->pev->punchangle.y += UTIL_SharedRandomFloat(m_pPlayer->random_seed + 5, -1.25, 1.5);
}
开发者ID:AlexCSilva,项目名称:cs16-client,代码行数:57,代码来源:wpn_g3sg1.cpp

示例3: UTIL_GetRandomSpreadDir

Vector UTIL_GetRandomSpreadDir(unsigned int inSeed, int inShotNumber, const Vector& inBaseDirection, const Vector& inRight, const Vector& inUp, const Vector& inSpread)
{
	// Use player's random seed.
	// get circular gaussian spread
	float x = UTIL_SharedRandomFloat( inSeed + inShotNumber, -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 1 + inShotNumber ) , -0.5, 0.5 );
	float y = UTIL_SharedRandomFloat( inSeed + ( 2 + inShotNumber ), -0.5, 0.5 ) + UTIL_SharedRandomFloat( inSeed + ( 3 + inShotNumber ), -0.5, 0.5 );
	float z = x * x + y * y;
	
	Vector theRandomDir = inBaseDirection + x * inSpread.x * inRight + y * inSpread.y * inUp;
	
	return theRandomDir;
}
开发者ID:Arkshine,项目名称:NS,代码行数:12,代码来源:AvHBasePlayerWeapon.cpp

示例4: ResetEmptySound

void CGauss::WeaponIdle( void )
{
	ResetEmptySound( );

	// play aftershock static discharge
	if ( m_pPlayer->m_flPlayAftershock && m_pPlayer->m_flPlayAftershock < gpGlobals->time )
	{
		switch (RANDOM_LONG(0,3))
		{
		case 0:	EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro4.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
		case 1:	EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro5.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
		case 2:	EMIT_SOUND(ENT(m_pPlayer->pev), CHAN_WEAPON, "weapons/electro6.wav", RANDOM_FLOAT(0.7, 0.8), ATTN_NORM); break;
		case 3:	break; // no sound
		}
		m_pPlayer->m_flPlayAftershock = 0.0;
	}

	if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
		return;

	if (m_fInAttack != 0)
	{
		StartFire();
		m_fInAttack = 0;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
	}
	else
	{
		int iAnim;
		float flRand = RANDOM_FLOAT(0, 1);
		if (flRand <= 0.5)
		{
			iAnim = GAUSS_IDLE;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
		}
		else if (flRand <= 0.75)
		{
			iAnim = GAUSS_IDLE2;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
		}
		else
		{
			iAnim = GAUSS_FIDGET;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 3;
		}

		return;
		SendWeaponAnim( iAnim );
		
	}
}
开发者ID:Solexid,项目名称:halflife,代码行数:51,代码来源:gauss.cpp

示例5: UTIL_SharedRandomFloat

void cNoSpread::GetSpreadXY(unsigned int seed, int future, float *velocity, float *vec)
{
	float vecspread, speed; 

	vec[0] = UTIL_SharedRandomFloat(seed + future, -0.5, 0.5) + UTIL_SharedRandomFloat(seed + 1 + future, -0.5, 0.5); 

	vec[1] = UTIL_SharedRandomFloat(seed + 2 + future, -0.5, 0.5) + UTIL_SharedRandomFloat(seed + 3 + future, -0.5, 0.5); 


	vecspread = GetVecSpread(velocity); 

	vec[0] *= vecspread; 
	vec[1] *= vecspread; 

	return; 
}
开发者ID:Rople,项目名称:minihook-ng,代码行数:16,代码来源:NoSpread.cpp

示例6: DefaultDeploy

BOOL CBasePlayerWeapon :: DefaultDeploy( char *szViewModel, char *szWeaponModel, int iAnim, char *szAnimExt, int skiplocal /* = 0 */, int body )
{
	m_pPlayer->TabulateAmmo();
	m_pPlayer->pev->viewmodel = MAKE_STRING(szViewModel);
	m_pPlayer->pev->weaponmodel = MAKE_STRING(szWeaponModel);

	if( m_pPlayer->pev->team == 1 || m_pPlayer->pev->team == 2 )
		pev->body = m_pPlayer->pev->team - 1;

	strcpy( m_pPlayer->m_szAnimExtention, szAnimExt );
	
	SendWeaponAnim( iAnim, skiplocal, body );

	m_flTimeWeaponIdle = 1.0;

	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 0.5;

	MESSAGE_BEGIN( MSG_ONE, gmsgScopeToggle, NULL, m_pPlayer->pev );
		WRITE_BYTE( 0 );
	MESSAGE_END();

	m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 1.085,2.085);

	return TRUE;
}
开发者ID:mittorn,项目名称:csdm,代码行数:25,代码来源:weapons.cpp

示例7: DefaultFire

void CAUG::PrimaryAttack()
{
	if( Scope )
	{
		DefaultFire( m_pPlayer, 1, wepspread_s, 32, AUG_SHOOT1, "weapons/aug-1.wav", m_event, 20 );
		m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.1825;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 1.085,2.085);
	}
	else
	{
		DefaultFire( m_pPlayer, 1, wepspread_s, 32, AUG_SHOOT1, "weapons/aug-1.wav", m_event, 20 );
		m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.0825;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat(m_pPlayer->random_seed, 1.085,2.085);
	}

}
开发者ID:mittorn,项目名称:csdm,代码行数:16,代码来源:wpn_aug.cpp

示例8: MAKE_STRING

void CPython::Holster( int skiplocal /* = 0 */ )
{
	if (m_fInZoom == TRUE) 
	{
		m_pPlayer->b_EstaEnZoom = FALSE;

		#ifndef CLIENT_DLL
				if (!FStringNull (v_model) )
				m_pPlayer->pev->viewmodel = v_model;
				else
				m_pPlayer->pev->viewmodel = MAKE_STRING("models/weapons/357/v_357.mdl");
		#else
				if (!FStringNull (v_model) )
				m_pPlayer->pev->viewmodel = v_model;
				else
				LoadVModel ( "models/weapons/357/v_357.mdl", m_pPlayer );
		#endif
		m_pPlayer->pev->fov = m_pPlayer->m_iFOV = 0; // 0 means reset to default fov
		m_fInZoom = FALSE;
	}

	m_fInReload = FALSE;// cancel any reload in progress.

//	if ( m_fInZoom )
//	{
//		SecondaryAttack();
//	}

	m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.0;
	m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
	SendWeaponAnim( PYTHON_IDLE1 );//PYTHON_HOLSTER
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:32,代码来源:wep_357.cpp

示例9: ResetEmptySound

void CGlock::WeaponIdle( void )
{
	ResetEmptySound( );

	m_pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );

	if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
		return;

	// only idle if the slid isn't back
	if (m_iClip != 0)
	{
		int iAnim;
		float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0.0, 1.0 );

		if (flRand <= 0.3 + 0 * 0.75)
		{
			iAnim = GLOCK_IDLE3;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 49.0 / 16;
		}
		else if (flRand <= 0.6 + 0 * 0.875)
		{
			iAnim = GLOCK_IDLE1;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 60.0 / 16.0;
		}
		else
		{
			iAnim = GLOCK_IDLE2;
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 40.0 / 16.0;
		}
		SendWeaponAnim( iAnim, 1 );
	}
}
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.8--VC2010,代码行数:33,代码来源:weapon_glock.cpp

示例10: ALERT

void CAK74::WeaponIdle( void )
{
/*
	if (!FStringNull (v_model) )
	{
		ALERT (at_console, "v_model is %s \n",STRING( v_model));
		ALERT (at_console, "p_model is %s \n",STRING( p_model));
		ALERT (at_console, "w_model is %s \n",STRING( w_model));
	}
*/
	ResetEmptySound( );

	m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );

	if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
		return;

	int iAnim;
	switch ( RANDOM_LONG( 0, 1 ) )
	{
	case 0:	
		iAnim = AK_NMC_IDLE1;	
		break;
	
	default:
	case 1:
		iAnim = AK_NMC_IDLE2;
		break;
	}

	SendWeaponAnim( iAnim );

	m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again.
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:34,代码来源:wep_ak47.cpp

示例11: DefaultReload

void CAK74::Reload( void )
{
	int iResult;

	if (m_iClip == 0)
		iResult = DefaultReload( 30, AK_NMC_RELOAD_B_VACIO, 2.40 );
	else
		iResult = DefaultReload( 30, AK_NMC_RELOAD_B_VACIO, 2.40 );
/*
	{

		switch (RANDOM_LONG(0,3))
		{
			case 0: iResult = DefaultReload( 28, AK_NMC_RELOAD_A, 2.06 ); break;
			case 1: iResult = DefaultReload( 19, AK_NMC_RELOAD_A, 2.06 ); break;
			case 2: iResult = DefaultReload( 30, AK_NMC_RELOAD_A, 2.06 ); break;
			case 3: iResult = DefaultReload( 30, AK_NMC_RELOAD_B, 2.06 ); break;
		}

	}
*/	

	if (iResult)
	{
		m_pPlayer->SetAnimation( PLAYER_RELOAD ); 
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
	/*		Vector vecSrc	 = m_pPlayer->GetGunPosition( );
		CBaseEntity *pEntity = Create( "item_clip_rifle", vecSrc, pev->angles );	*/	

	}
	//m_pPlayer->SetAnimation( PLAYER_RELOAD );
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:32,代码来源:wep_ak47.cpp

示例12: UTIL_SharedRandomFloat

void CMP5::Holster( int skiplocal /* = 0 */ )
{
    m_fInReload = FALSE;// cancel any reload in progress.
	m_pPlayer->m_bIron = FALSE;

    m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:7,代码来源:wep_mp5.cpp

示例13: ResetEmptySound

void CMP5::WeaponIdle( void )
{
	ResetEmptySound( );

	m_pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );

	if ( m_flTimeWeaponIdle > UTIL_WeaponTimeBase() )
		return;

	int iAnim;
	switch ( RANDOM_LONG( 0, 1 ) )
	{
	case 0:	
		iAnim = MP5_LONGIDLE;	
		break;
	
	default:
	case 1:
		iAnim = MP5_IDLE1;
		break;
	}

	SendWeaponAnim( iAnim );

	m_flTimeWeaponIdle = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 ); // how long till we do this again.
}
开发者ID:HoLyCoWzOrZ,项目名称:sing-engine,代码行数:26,代码来源:mp5.cpp

示例14: UpdateClip

void CM249::WeaponIdle( void )
{
	if (m_flTimeWeaponIdle <  UTIL_WeaponTimeBase() )
	{
		if ( m_fInSpecialReload )
		{
			UpdateClip();
			m_fInSpecialReload = 0;
			SendWeaponAnim( M249_RELOAD2 , UseDecrement() ? 1 : 0, pev->body );
			m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 111.0 / 45.0;
			m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 111.0 / 45.0;
		}
		else
		{
			ResetEmptySound( );
			UpdateClip();

			int iAnim;
			float flRand = UTIL_SharedRandomFloat( m_pPlayer->random_seed, 0, 1 );
			if (flRand <= 0.8)
			{
				iAnim = M249_SLOWIDLE;
				m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (45.0/9.0);
			}
			else
			{
				iAnim = M249_IDLE1;
				m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + (74.0/12.0);// * RANDOM_LONG(2, 5);
			}
			SendWeaponAnim( iAnim , UseDecrement() ? 1 : 0, pev->body );
		}
	}
}
开发者ID:Fograin,项目名称:hl-subsmod-ex,代码行数:33,代码来源:weapon_m249.cpp

示例15: DefaultReload

void CMP5::Reload( void )
{
//	if( (m_pPlayer->pev->weaponanim == SD2_UNSUPRESS) || (m_pPlayer->pev->weaponanim == A2_SUPRESS) )//can't reload right now
 //   return;

    if ( m_pPlayer->ammo_9mm <= 0 )
    return;

    int iResult;


	if ( m_fDefaultAnim == SILENCER_OFF_FULLAUTO || m_fDefaultAnim == SILENCER_OFF_SEMI )
		iResult = DefaultReload( 30, A2_RELOADLAST, 3.70 );
    else
		iResult = DefaultReload( 30, SD2_RELOADLAST, 3.70 );


	m_pPlayer->SetAnimation( PLAYER_RELOAD ); 

 	if (iResult)
	{
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
		
		Vector vecSrc	 = m_pPlayer->GetGunPosition( );
		CBaseEntity *pEntity = Create( "item_clip_rifle", vecSrc, pev->angles );
	}
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:27,代码来源:wep_mp5.cpp


注:本文中的UTIL_SharedRandomFloat函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。