本文整理汇总了C++中QAngle::Random方法的典型用法代码示例。如果您正苦于以下问题:C++ QAngle::Random方法的具体用法?C++ QAngle::Random怎么用?C++ QAngle::Random使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAngle
的用法示例。
在下文中一共展示了QAngle::Random方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ApplyErrorToAngle
static void ApplyErrorToAngle(QAngle* angles, float margin)
{
QAngle error;
error.Random(-1.0f, 1.0f);
error *= margin;
angles->operator+=(error);
}
示例2: GetAbsVelocity
//------------------------------------------------------------------------------
// Pow!
//------------------------------------------------------------------------------
void CPropAPC2::ExplodeAndThrowChunk( const Vector &vecExplosionPos )
{
ExplosionCreate( vecExplosionPos, vec3_angle, this, 1000, 500.0f,
SF_ENVEXPLOSION_NODAMAGE | SF_ENVEXPLOSION_NOSPARKS | SF_ENVEXPLOSION_NODLIGHTS |
SF_ENVEXPLOSION_NOSMOKE | SF_ENVEXPLOSION_NOFIREBALLSMOKE, 0 );
UTIL_ScreenShake( vecExplosionPos, 25.0, 150.0, 1.0, 750.0f, SHAKE_START );
// Drop a flaming, smoking chunk.
CGib *pChunk = CREATE_ENTITY( CGib, "gib" );
pChunk->Spawn( "models/gibs/hgibs.mdl" );
pChunk->SetBloodColor( DONT_BLEED );
QAngle vecSpawnAngles;
vecSpawnAngles.Random( -90, 90 );
pChunk->SetAbsOrigin( vecExplosionPos );
pChunk->SetAbsAngles( vecSpawnAngles );
int nGib = random->RandomInt( 0, APC_MAX_CHUNKS - 1 );
pChunk->Spawn( s_pChunkModelName[nGib] );
pChunk->SetOwnerEntity( this );
pChunk->m_lifeTime = random->RandomFloat( 6.0f, 8.0f );
pChunk->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
IPhysicsObject *pPhysicsObject = pChunk->VPhysicsInitNormal( SOLID_VPHYSICS, pChunk->GetSolidFlags(), false );
// Set the velocity
if ( pPhysicsObject )
{
pPhysicsObject->EnableMotion( true );
Vector vecVelocity;
QAngle angles;
angles.x = random->RandomFloat( -40, 0 );
angles.y = random->RandomFloat( 0, 360 );
angles.z = 0.0f;
AngleVectors( angles, &vecVelocity );
vecVelocity *= random->RandomFloat( 300, 900 );
vecVelocity += GetAbsVelocity();
AngularImpulse angImpulse;
angImpulse = RandomAngularImpulse( -180, 180 );
pChunk->SetAbsVelocity( vecVelocity );
pPhysicsObject->SetVelocity(&vecVelocity, &angImpulse );
}
CEntityFlame *pFlame = CEntityFlame::Create( pChunk, false );
if ( pFlame != NULL )
{
pFlame->SetLifetime( pChunk->m_lifeTime );
}
pChunk->Dissolve( NULL, gpGlobals->curtime, false, ENTITY_DISSOLVE_NORMAL );
}
示例3: Event_Killed
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CPropAPC::Event_Killed( const CTakeDamageInfo &info )
{
m_OnDeath.FireOutput( info.GetAttacker(), this );
Vector vecAbsMins, vecAbsMaxs;
CollisionProp()->WorldSpaceAABB( &vecAbsMins, &vecAbsMaxs );
Vector vecNormalizedMins, vecNormalizedMaxs;
CollisionProp()->WorldToNormalizedSpace( vecAbsMins, &vecNormalizedMins );
CollisionProp()->WorldToNormalizedSpace( vecAbsMaxs, &vecNormalizedMaxs );
Vector vecAbsPoint;
CPASFilter filter( GetAbsOrigin() );
for (int i = 0; i < 5; i++)
{
CollisionProp()->RandomPointInBounds( vecNormalizedMins, vecNormalizedMaxs, &vecAbsPoint );
te->Explosion( filter, random->RandomFloat( 0.0, 1.0 ), &vecAbsPoint,
g_sModelIndexFireball, random->RandomInt( 4, 10 ),
random->RandomInt( 8, 15 ),
( i < 2 ) ? TE_EXPLFLAG_NODLIGHTS : TE_EXPLFLAG_NOPARTICLES | TE_EXPLFLAG_NOFIREBALLSMOKE | TE_EXPLFLAG_NODLIGHTS,
100, 0 );
}
// TODO: make the gibs spawn in sync with the delayed explosions
int nGibs = random->RandomInt( 1, 4 );
for ( int i = 0; i < nGibs; i++)
{
// Throw a flaming, smoking chunk.
CGib *pChunk = CREATE_ENTITY( CGib, "gib" );
pChunk->Spawn( "models/gibs/hgibs.mdl" );
pChunk->SetBloodColor( DONT_BLEED );
QAngle vecSpawnAngles;
vecSpawnAngles.Random( -90, 90 );
pChunk->SetAbsOrigin( vecAbsPoint );
pChunk->SetAbsAngles( vecSpawnAngles );
int nGib = random->RandomInt( 0, APC_MAX_CHUNKS - 1 );
pChunk->Spawn( s_pChunkModelName[nGib] );
pChunk->SetOwnerEntity( this );
pChunk->m_lifeTime = random->RandomFloat( 6.0f, 8.0f );
pChunk->SetCollisionGroup( COLLISION_GROUP_DEBRIS );
IPhysicsObject *pPhysicsObject = pChunk->VPhysicsInitNormal( SOLID_VPHYSICS, pChunk->GetSolidFlags(), false );
// Set the velocity
if ( pPhysicsObject )
{
pPhysicsObject->EnableMotion( true );
Vector vecVelocity;
QAngle angles;
angles.x = random->RandomFloat( -20, 20 );
angles.y = random->RandomFloat( 0, 360 );
angles.z = 0.0f;
AngleVectors( angles, &vecVelocity );
vecVelocity *= random->RandomFloat( 300, 900 );
vecVelocity += GetAbsVelocity();
AngularImpulse angImpulse;
angImpulse = RandomAngularImpulse( -180, 180 );
pChunk->SetAbsVelocity( vecVelocity );
pPhysicsObject->SetVelocity(&vecVelocity, &angImpulse );
}
CEntityFlame *pFlame = CEntityFlame::Create( pChunk, false );
if ( pFlame != NULL )
{
pFlame->SetLifetime( pChunk->m_lifeTime );
}
}
UTIL_ScreenShake( vecAbsPoint, 25.0, 150.0, 1.0, 750.0f, SHAKE_START );
if( hl2_episodic.GetBool() )
{
// EP1 perf hit
Ignite( 6, false );
}
else
{
Ignite( 60, false );
}
m_lifeState = LIFE_DYING;
// Spawn a lesser amount if the player is close
m_iRocketSalvoLeft = DEATH_VOLLEY_ROCKET_COUNT;
m_flRocketTime = gpGlobals->curtime;
}
示例4: Update
//-----------------------------------------------------------------------------
// Purpose:
// Input : fTimeDelta -
//-----------------------------------------------------------------------------
void C_ExtinguisherJet::Update( float fTimeDelta )
{
if ( m_bEmit == false )
return;
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
if ( m_bUseMuzzlePoint )
{
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
if ( vm )
{
int iAttachment = vm->LookupAttachment( "muzzle" );
Vector origin;
QAngle angles;
vm->GetAttachment( iAttachment, origin, angles );
Assert( !GetMoveParent() );
SetLocalOrigin( origin );
SetLocalAngles( angles );
}
}
trace_t tr;
Vector shotDir, vRight, vUp;
AngleVectors( GetAbsAngles(), &shotDir, &vRight, &vUp );
//FIXME: Muzzle point is incorrect on the model!
if ( m_bUseMuzzlePoint )
{
shotDir.Negate();
}
Vector endPoint = GetAbsOrigin() + ( shotDir * 150.0f );
UTIL_TraceLine( GetAbsOrigin(), endPoint, MASK_SHOT, NULL, COLLISION_GROUP_NONE, &tr );
bool hitWall = ( tr.fraction < 1.0f );
//Add normal jet
if ( m_pEmitter.IsValid() )
{
SimpleParticle *pParticle;
m_pEmitter->SetSortOrigin( GetAbsOrigin() );
float tempDelta = fTimeDelta;
//FIXME: All particles need to be within this loop
while( m_ParticleSpawn.NextEvent( tempDelta ) )
{
pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle, GetAbsOrigin() );
if ( pParticle )
{
pParticle->m_flDieTime = 0.2f;
pParticle->m_flLifetime = 0.0f;
pParticle->m_flRoll = random->RandomInt( 0, 360 );
pParticle->m_flRollDelta= random->RandomFloat( -4.0f, 4.0f );
pParticle->m_uchStartSize = 1;
pParticle->m_uchEndSize = random->RandomInt( 32, 48 );
pParticle->m_uchStartAlpha = random->RandomInt( 128, 164 );
pParticle->m_uchEndAlpha = 0;
int cScale = random->RandomInt( 192, 255 );
pParticle->m_uchColor[0] = cScale;
pParticle->m_uchColor[1] = cScale;
pParticle->m_uchColor[2] = cScale;
Vector dir;
QAngle ofsAngles;
ofsAngles.Random( -8.0f, 8.0f );
ofsAngles += GetAbsAngles();
AngleVectors( ofsAngles, &dir );
if ( m_bUseMuzzlePoint )
{
dir.Negate();
}
pParticle->m_vecVelocity = dir * random->RandomInt( 400, 800 );
}
//Add muzzle effect
pParticle = (SimpleParticle *) m_pEmitter->AddParticle( sizeof(SimpleParticle), m_MaterialHandle, GetAbsOrigin() );
if ( pParticle )
{
pParticle->m_flDieTime = 0.1f;
pParticle->m_flLifetime = 0.0f;
//.........这里部分代码省略.........