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


C++ RANDOM_FLOAT函数代码示例

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


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

示例1: MakeGrunt

CBaseMonster *COsprey :: MakeGrunt( Vector vecSrc )
{
	CBaseEntity *pEntity;
	CBaseMonster *pGrunt;

	TraceResult tr;
	UTIL_TraceLine( vecSrc, vecSrc + Vector( 0, 0, -4096.0), dont_ignore_monsters, ENT(pev), &tr);
	if ( tr.pHit && Instance( tr.pHit )->pev->solid != SOLID_BSP) 
		return NULL;

	for (int i = 0; i < m_iUnits; i++)
	{
		if (m_hGrunt[i] == NULL || !m_hGrunt[i]->IsAlive())
		{
			if (m_hGrunt[i] != NULL && m_hGrunt[i]->pev->rendermode == kRenderNormal)
			{
				m_hGrunt[i]->SUB_StartFadeOut( );
			}
			pEntity = Create( "monster_human_grunt", vecSrc, pev->angles );
			pGrunt = pEntity->MyMonsterPointer( );
			pGrunt->pev->movetype = MOVETYPE_FLY;
			pGrunt->pev->velocity = Vector( 0, 0, RANDOM_FLOAT( -196, -128 ) );
			pGrunt->SetActivity( ACT_GLIDE );

			CBeam *pBeam = CBeam::BeamCreate( "sprites/rope.spr", 10 );
			pBeam->PointEntInit( vecSrc + Vector(0,0,112), pGrunt->entindex() );
			pBeam->SetFlags( BEAM_FSOLID );
			pBeam->SetColor( 255, 255, 255 );
			pBeam->SetThink( SUB_Remove );
			pBeam->pev->nextthink = gpGlobals->time + -4096.0 * tr.flFraction / pGrunt->pev->velocity.z + 0.5;

			// ALERT( at_console, "%d at %.0f %.0f %.0f\n", i, m_vecOrigin[i].x, m_vecOrigin[i].y, m_vecOrigin[i].z );  
			pGrunt->m_vecLastPosition = m_vecOrigin[i];
			m_hGrunt[i] = pGrunt;
			return pGrunt;
		}
	}
	// ALERT( at_console, "none dead\n");
	return NULL;
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:40,代码来源:osprey.cpp

示例2: UTIL_Ricochet

void CBigMomma::TraceAttack(entvars_t *pevAttacker, float flDamage, Vector vecDir, TraceResult *ptr, int bitsDamageType)
{
	if(ptr->iHitgroup != 1)
	{
		// didn't hit the sack?

		if(pev->dmgtime != gpGlobals->time || (RANDOM_LONG(0, 10) < 1))
		{
			UTIL_Ricochet(ptr->vecEndPos, RANDOM_FLOAT(1, 2));
			pev->dmgtime = gpGlobals->time;
		}

		flDamage = 0.1; // don't hurt the monster much, but allow bits_COND_LIGHT_DAMAGE to be generated
	}
	else if(gpGlobals->time > m_painSoundTime)
	{
		m_painSoundTime = gpGlobals->time + RANDOM_LONG(1, 3);
		EMIT_SOUND_ARRAY_DYN(CHAN_VOICE, pPainSounds);
	}

	CBaseMonster::TraceAttack(pevAttacker, flDamage, vecDir, ptr, bitsDamageType);
}
开发者ID:Sh1ft0x0EF,项目名称:HLSDKRevamp,代码行数:22,代码来源:bigmomma.cpp

示例3: Think

void CXenTree :: Think( void )
{
	float flInterval = StudioFrameAdvance();
	pev->nextthink = gpGlobals->time + 0.1;
	DispatchAnimEvents( flInterval );

	switch( GetActivity() )
	{
	case ACT_MELEE_ATTACK1:
		if ( m_fSequenceFinished )
		{
			SetActivity( ACT_IDLE );
			pev->framerate = RANDOM_FLOAT( 0.6, 1.4 );
		}
		break;

	default:
	case ACT_IDLE:
		break;

	}
}
开发者ID:Arkshine,项目名称:NS,代码行数:22,代码来源:xen.cpp

示例4: switch

void CBiorifle::WeaponIdle( void )
{
	if ( m_flTimeWeaponIdle > gpGlobals->time )
		return;

	int iAnim;
	switch ( RANDOM_LONG( 0, 2 ))
	{
	case 0:	
		iAnim = BIORIFLE_IDLE2;	
		break;
	case 1:	
		iAnim = BIORIFLE_IDLE3;	
		break;
	case 2:
		iAnim = BIORIFLE_IDLE;
		break;
	}

	SendWeaponAnim( iAnim );
	m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT (10, 15);
}
开发者ID:mittorn,项目名称:hlwe_src,代码行数:22,代码来源:wpn_biorifle.cpp

示例5: HandleAnimEvent

//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CHellKnight :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	switch( pEvent->event )
	{
	case HKNIGHT_IDLE_SOUND:
		if( m_Activity == ACT_RUN )
			CheckForCharge ();

		if( RANDOM_FLOAT( 0.0f, 1.0f ) < 0.1f )
			EMIT_SOUND( edict(), CHAN_VOICE, "hknight/idle.wav", 1.0, ATTN_IDLE );
		break;
	case HKNIGHT_SHOT_SPIKES:
		ShootSpike( atof( pEvent->options ));
		break;
	case HKNIGHT_MELEE_ATTACK:
		AI_Melee ();
		break;
	default:
		CQuakeMonster::HandleAnimEvent( pEvent );
		break;
	}
}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:26,代码来源:hellknight.cpp

示例6: Use

void CTriggerHurt :: Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value )
{
	if (useType == USE_TOGGLE)
	{
		if(m_iState) useType = USE_OFF;
		else useType = USE_ON;
	}
	if (useType == USE_ON)
	{
		pev->solid = SOLID_TRIGGER;
		gpGlobals->force_retouch++;
		UTIL_SetOrigin( this, pev->origin );
		if (pev->button & DMG_RADIATION) SetNextThink( RANDOM_FLOAT(0.0, 0.5) );
		m_iState = STATE_ON;
	}
	else if (useType == USE_OFF)
	{
		pev->solid = SOLID_NOT;
		UTIL_SetOrigin( this, pev->origin );
		if (pev->button & DMG_RADIATION) DontThink();
		m_iState = STATE_OFF;
	}
	else if (useType == USE_SET)
	{
		pev->dmg = value;//set dmg level
	}	
	else if (useType == USE_RESET)
	{
		pev->dmg = 0;//reset dmg level
	}
	else if (useType == USE_SHOWINFO)
	{
		DEBUGHEAD;
		ALERT( at_console, "State: %s, Dmg value %g\n", GetStringForState( GetState()), pev->dmg );
		PrintStringForDamage( pev->button );
	}
	
}
开发者ID:a1batross,项目名称:Xash3D_ancient,代码行数:38,代码来源:basetrigger.cpp

示例7: UpdateSpot

void CRpg::WeaponIdle(void)
{
	UpdateSpot();

	if (m_flTimeWeaponIdle > UTIL_GlobalTimeBase()) return;

	if (m_iClip && !m_iOverloadLevel)
	{
		int iAnim;
		float flRand = RANDOM_FLOAT(0, 1);
		if (flRand <= 0.75)
		{
			iAnim = RPG_IDLE;
			m_flTimeWeaponIdle = UTIL_GlobalTimeBase() + 6.3;
		}
		else
		{
			iAnim = RPG_IDLE2;
			m_flTimeWeaponIdle = UTIL_GlobalTimeBase() + 6.3;
		}
		SendWeaponAnim(iAnim);
	}
}
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.9--VC2010,代码行数:23,代码来源:rpg.cpp

示例8: PlayEmptySound

void Cawp::PrimaryAttack()
{
	if (m_pPlayer->pev->waterlevel == 3 || m_iClip <= 0)
 	{
		PlayEmptySound( );
		m_flNextPrimaryAttack = gpGlobals->time + 0.5;
		return;
	}

	m_iClip--;
	m_iFiredAmmo++;
	m_pPlayer->SetAnimation( PLAYER_ATTACK1 );

	UTIL_MakeVectors(m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle);
	m_pPlayer->FireMagnumBullets(m_pPlayer->GetGunPosition(), gpGlobals->v_forward, VECTOR_CONE_0DEGREES, 16384, BULLET_338Magnum, m_pPlayer->pev);
	FX_FireGun(m_pPlayer->pev->v_angle, m_pPlayer->entindex(), (m_pPlayer->m_fHeavyArmor)?AWP_FIRE_SOLID:AWP_FIRE, m_pPlayer->m_fHeavyArmor?1:0, FIREGUN_AWP );

	SetThink( shellcasing ); 
		(m_pPlayer->m_fHeavyArmor)?pev->nextthink = gpGlobals->time + 0.6:pev->nextthink = gpGlobals->time + 1.15;

	(m_pPlayer->m_fHeavyArmor)?m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.2:m_pPlayer->m_flNextAttack = UTIL_WeaponTimeBase() + 1.8;
	m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT (8, 12);
}
开发者ID:mittorn,项目名称:hlwe_src,代码行数:23,代码来源:wpn_awp.cpp

示例9: tag

/*
=========================
HUD_StudioEvent

The entity's studio model description indicated an event was
fired during this frame, handle the event by it's tag ( e.g., muzzleflash, sound )
=========================
*/
void HUD_StudioEvent( const struct mstudioevent_s *event, const struct cl_entity_s *entity )
{
	switch( event->event )
	{
	case 5001:
		gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[0], Q_atoi( event->options ));
		break;
	case 5011:
		gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[1], Q_atoi( event->options ));
		break;
	case 5021:
		gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[2], Q_atoi( event->options ));
		break;
	case 5031:
		gEngfuncs.pEfxAPI->R_MuzzleFlash( (float *)&entity->attachment[3], Q_atoi( event->options ));
		break;
	case 5002:
		gEngfuncs.pEfxAPI->R_SparkEffect( (float *)&entity->attachment[0], Q_atoi( event->options ), -100, 100 );
		break;
	case 5004: // client side sound		
		gEngfuncs.pfnPlaySoundByNameAtLocation( (char *)event->options, 1.0, (float *)&entity->attachment[0] );
		break;
	case 5005: // client side sound with random pitch		
		gEngfuncs.pEventAPI->EV_PlaySound( entity->index, (float *)&entity->attachment[0], CHAN_WEAPON, (char *)event->options,
		RANDOM_FLOAT( 0.7f, 0.9f ), ATTN_NORM, 0, 85 + RANDOM_LONG( 0, 0x1f ));
		break;
	case 5050: // Special event for displacer
		HUD_DrawBeam();
		break;
	case 5060:
	          HUD_EjectShell( event, entity );
		break;
	default:
		ALERT( at_error, "Unknown event %i with options %i\n", event->event, event->options );
		break;
	}
}
开发者ID:XashDev,项目名称:XashXT,代码行数:45,代码来源:r_misc.cpp

示例10: EMIT_SOUND_DYN

BOOL CMP5::Deploy( )
{
//	m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 1.3; //delay before fire
	EMIT_SOUND_DYN(ENT(m_pPlayer->pev), CHAN_ITEM, "weapons/weapon_deploy.wav", RANDOM_FLOAT(0.95, 1.0), ATTN_NORM, 0, 93 + RANDOM_LONG(0,0xF));
    
	if ( m_fDefaultAnim == SILENCER_OFF_FULLAUTO || m_fDefaultAnim == SILENCER_OFF_SEMI )
	{
		if (!FStringNull (v_model) )
		{
			m_pPlayer->pev->viewmodel = v_model;
//			m_pPlayer->pev->weaponmodel = p_model;
		
			SendWeaponAnim( A2_DEPLOY, 1, 0 );	
			return TRUE;
		}
		else
		return DefaultDeploy("models/weapons/MP5/v_MP5.mdl", "models/weapons/MP5/p_MP5.mdl", A2_DEPLOY, "mp5", 3.50f ); //"mp5a4", 3.50f );

	}
    else
	{
		if (!FStringNull (v_model) )
		{
			m_pPlayer->pev->viewmodel = v_model;
//			m_pPlayer->pev->weaponmodel = p_model;
		
			SendWeaponAnim( SD2_DEPLOY, 1, 0 );	
			return TRUE;
		}
		else
		return DefaultDeploy("models/weapons/MP5/v_MP5.mdl", "models/weapons/MP5/p_MP5_2.mdl", SD2_DEPLOY, "mp5", 3.50f );
	}

	 m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );

//	return DefaultDeploy("models/weapons/MP5/v_MP5.mdl", "models/weapons/MP5/p_MP5.mdl", A2_DEPLOY, "mp5a4" );
}
开发者ID:JoelTroch,项目名称:am_src_30jan2011,代码行数:37,代码来源:wep_mp5.cpp

示例11: StartFire

void CGauss::WeaponIdle( void )
{
	if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
		return;

	if (m_fInAttack != 0)
	{
		StartFire();
		m_fInAttack = 0;
		m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 2.0;
	}
	else
	{
	int iAnim;
	switch ( RANDOM_LONG( 0, 2 ) )
	{
	case 0:	
		iAnim = GAUSS_IDLE;	
		break;
	
	case 1:	
		iAnim = GAUSS_IDLE2;	
		break;
	
	default:
	case 2:	
		iAnim = GAUSS_FIDGET;	
		break;
	}

	SendWeaponAnim( iAnim );

	m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
		
	}
}
开发者ID:mittorn,项目名称:hlwe_src,代码行数:36,代码来源:wpn_gauss.cpp

示例12: HandleAnimEvent

//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CSoldier :: HandleAnimEvent( MonsterEvent_t *pEvent )
{
	switch( pEvent->event )
	{
	case ARMY_SHOOT:
		MonsterFire();
		break;
	case ARMY_END_ATTACK:
		m_fInAttack = TRUE;
		m_fAttackFinished = TRUE;
		break;
	case ARMY_DROP_BACKPACK:
		ammo_shells = 5;
		CWeaponBox::DropBackpack( this, 0 );
		break;
	case ARMY_IDLE_SOUND:
		if( RANDOM_FLOAT( 0.0f, 1.0f ) < 0.2f )
			EMIT_SOUND( edict(), CHAN_VOICE, "soldier/idle.wav", 1.0, ATTN_IDLE );
		break;
	default:
		CQuakeMonster::HandleAnimEvent( pEvent );
		break;
	}
}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:28,代码来源:soldier.cpp

示例13: MonsterPain

void CHellKnight :: MonsterPain( CBaseEntity *pAttacker, float flDamage )
{
	if( pev->pain_finished > gpGlobals->time )
		return;

	EMIT_SOUND( edict(), CHAN_VOICE, "hknight/pain1.wav", 1.0, ATTN_NORM );

	if(( gpGlobals->time - pev->pain_finished ) > 5 )
	{	
		// allways go into pain frame if it has been a while
		m_iAIState = STATE_PAIN;
		SetActivity( ACT_BIG_FLINCH );
		pev->pain_finished = gpGlobals->time + 1;
		return;
	}
	
	if( RANDOM_FLOAT( 0.0f, 30.0f ) > flDamage )
		return; // didn't flinch

	m_iAIState = STATE_PAIN;
	SetActivity( ACT_BIG_FLINCH );
	pev->pain_finished = gpGlobals->time + 1;

}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:24,代码来源:hellknight.cpp

示例14: PLAYBACK_EVENT_FULL

// Grenade launcher
void CBasePlayer::W_FireGrenade(int iQuadSound)
{
	PLAYBACK_EVENT_FULL(FEV_NOTHOST, edict(), m_usGrenade, 0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, iQuadSound, 0, 0, 0);

	if(gpGlobals->deathmatch != 4)
		*m_pCurrentAmmo -= 1;

	// Get initial velocity
	UTIL_MakeVectors(pev->v_angle);
	Vector vecVelocity;
	if(pev->v_angle.x)
	{
		vecVelocity = gpGlobals->v_forward * 600 + gpGlobals->v_up * 200 + RANDOM_FLOAT(-1, 1) * gpGlobals->v_right * 10 + RANDOM_FLOAT(-1, 1) * gpGlobals->v_up * 10;
	}
	else
	{
		vecVelocity   = GetAutoaimVector(AUTOAIM_5DEGREES);
		vecVelocity   = vecVelocity * 600;
		vecVelocity.z = 200;
	}

	// Create the grenade
	CQuakeRocket *pRocket = CQuakeRocket::CreateGrenade(pev->origin, vecVelocity, this);
}
开发者ID:Sh1ft0x0EF,项目名称:HLSDKRevamp,代码行数:25,代码来源:quake_weapons_all.cpp

示例15: SendWeaponAnim

void CTripmine::WeaponIdle( void )
{
	if (m_flTimeWeaponIdle > gpGlobals->time)
		return;

	if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0)
	{
		SendWeaponAnim( TRIPMINE_DRAW );
	}
	else
	{
		RetireWeapon(); 
		return;
	}

	int iAnim;
	float flRand = RANDOM_FLOAT(0, 1);
	if (flRand <= 0.25)
	{
		iAnim = TRIPMINE_IDLE1;
		m_flTimeWeaponIdle = gpGlobals->time + 90.0 / 30.0;
	}
	else if (flRand <= 0.75)
	{
		iAnim = TRIPMINE_IDLE2;
		m_flTimeWeaponIdle = gpGlobals->time + 60.0 / 30.0;
	}
	else
	{
		iAnim = TRIPMINE_FIDGET;
		m_flTimeWeaponIdle = gpGlobals->time + 100.0 / 30.0;
	}

	SendWeaponAnim( iAnim );
	
}
开发者ID:jlecorre,项目名称:hlinvasion,代码行数:36,代码来源:tripmine.cpp


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