• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ RANDOM_FLOAT函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: RANDOM_FLOAT

bool CCSBot::Initialize(const BotProfile *profile)
{
	// extend
	CBot::Initialize(profile);

	// CS bot initialization
	m_diedLastRound = false;
	m_morale = POSITIVE;		// starting a new round makes everyone a little happy

	m_combatRange = RANDOM_FLOAT(325, 425);

	m_navNodeList = NULL;
	m_currentNode = NULL;

	// set initial safe time guess for this map
	m_safeTime = 15.0f + 5.0f * GetProfile()->GetAggression();

	m_name[0] = '\0';

	ResetValues();
	StartNormalProcess();

	return true;
}
开发者ID:CecilHarvey,项目名称:regamelite,代码行数:24,代码来源:cs_bot_init.cpp


示例17: UpdateVision

void CHostageImprov::UpdateVision()
{
	if (!m_visionTimer.IsElapsed())
		return;

	m_visiblePlayerCount = 0;

	for (int i = 1; i <= gpGlobals->maxClients; ++i)
	{
		CBasePlayer *player = static_cast<CBasePlayer *>(UTIL_PlayerByIndex(i));

		if (player == NULL)
			continue;

		if (FNullEnt(player->pev))
			continue;

		if (FStrEq(STRING(player->pev->netname), ""))
			continue;

		if (player->IsAlive() && IsVisible(player->pev->origin, true))
		{
			m_visiblePlayer[m_visiblePlayerCount] = player;

			if (player->m_iTeam == TERRORIST)
				m_lastSawT.Start();
			else
				m_lastSawCT.Start();

			if (++m_visiblePlayerCount == ARRAYSIZE(m_visiblePlayer))
				break;
		}
	}

	m_visionTimer.Start(RANDOM_FLOAT(0.4f, 0.6f));
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:36,代码来源:hostage_improv.cpp


示例18: Vector

void CLightning::RandomArea( void )
{
	int iLoops = 0;

	for (iLoops = 0; iLoops < 10; iLoops++)
	{
		Vector vecSrc = pev->origin;

		Vector vecDir1 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
		vecDir1 = vecDir1.Normalize();
		TraceResult		tr1;
		UTIL_TraceLine( vecSrc, vecSrc + vecDir1 * m_radius, ignore_monsters, ENT(pev), &tr1 );

		if (tr1.flFraction == 1.0)
			continue;

		Vector vecDir2;
		do {
			vecDir2 = Vector( RANDOM_FLOAT( -1.0, 1.0 ), RANDOM_FLOAT( -1.0, 1.0 ),RANDOM_FLOAT( -1.0, 1.0 ) );
		} while (DotProduct(vecDir1, vecDir2 ) > 0);
		vecDir2 = vecDir2.Normalize();
		TraceResult		tr2;
		UTIL_TraceLine( vecSrc, vecSrc + vecDir2 * m_radius, ignore_monsters, ENT(pev), &tr2 );

		if (tr2.flFraction == 1.0)
			continue;

		if ((tr1.vecEndPos - tr2.vecEndPos).Length() < m_radius * 0.1)
			continue;

		UTIL_TraceLine( tr1.vecEndPos, tr2.vecEndPos, ignore_monsters, ENT(pev), &tr2 );

		if (tr2.flFraction != 1.0)
			continue;

		Zap( tr1.vecEndPos, tr2.vecEndPos );

		break;
	}
}
开发者ID:NoFreeWill,项目名称:MultiplayerSource,代码行数:40,代码来源:effects.cpp


示例19: TurretDeath

void CBaseTurret ::	TurretDeath( void )
{
	BOOL iActive = FALSE;

	StudioFrameAdvance( );
	pev->nextthink = gpGlobals->time + 0.1;

	if (pev->deadflag != DEAD_DEAD)
	{
		pev->deadflag = DEAD_DEAD;

		float flRndSound = RANDOM_FLOAT ( 0 , 1 );

		if ( flRndSound <= 0.33 )
			EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die.wav", 1.0, ATTN_NORM);
		else if ( flRndSound <= 0.66 )
			EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die2.wav", 1.0, ATTN_NORM);
		else 
			EMIT_SOUND(ENT(pev), CHAN_BODY, "turret/tu_die3.wav", 1.0, ATTN_NORM);

		EMIT_SOUND_DYN(ENT(pev), CHAN_STATIC, "turret/tu_active2.wav", 0, 0, SND_STOP, 100);

		if (m_iOrientation == 0)
			m_vecGoalAngles.x = -15;
		else
			m_vecGoalAngles.x = -90;

		SetTurretAnim(TURRET_ANIM_DIE); 

		EyeOn( );	
	}

	EyeOff( );

	if (pev->dmgtime + RANDOM_FLOAT( 0, 2 ) > gpGlobals->time)
	{
		// lots of smoke
		MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
			WRITE_BYTE( TE_SMOKE );
			WRITE_COORD( RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ) );
			WRITE_COORD( RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ) );
			WRITE_COORD( pev->origin.z - m_iOrientation * 64 );
			WRITE_SHORT( g_sModelIndexSmoke );
			WRITE_BYTE( 25 ); // scale * 10
			WRITE_BYTE( 10 - m_iOrientation * 5); // framerate
		MESSAGE_END();
	}
	
	if (pev->dmgtime + RANDOM_FLOAT( 0, 5 ) > gpGlobals->time)
	{
		Vector vecSrc = Vector( RANDOM_FLOAT( pev->absmin.x, pev->absmax.x ), RANDOM_FLOAT( pev->absmin.y, pev->absmax.y ), 0 );
		if (m_iOrientation == 0)
			vecSrc = vecSrc + Vector( 0, 0, RANDOM_FLOAT( pev->origin.z, pev->absmax.z ) );
		else
			vecSrc = vecSrc + Vector( 0, 0, RANDOM_FLOAT( pev->absmin.z, pev->origin.z ) );

		UTIL_Sparks( vecSrc );
	}

	if (m_fSequenceFinished && !MoveTurret( ) && pev->dmgtime + 5 < gpGlobals->time)
	{
		pev->framerate = 0;
		SetThink( NULL );
	}
}
开发者ID:suXinjke,项目名称:HalfPayne,代码行数:65,代码来源:turret.cpp


示例20: StudioFrameAdvance


//.........这里部分代码省略.........
			if (gpGlobals->time > m_flLastSight)
			{
				m_hEnemy = NULL;
				m_flLastSight = gpGlobals->time + m_flMaxWait;
				SetThink(&CBaseTurret::SearchThink);
				return;
			}
		}
		fEnemyVisible = 0;
	}
	else
	{
		m_vecLastSight = vecMidEnemy;
	}

	UTIL_MakeAimVectors(m_vecCurAngles);	

	/*
	ALERT( at_console, "%.0f %.0f : %.2f %.2f %.2f\n", 
		m_vecCurAngles.x, m_vecCurAngles.y,
		gpGlobals->v_forward.x, gpGlobals->v_forward.y, gpGlobals->v_forward.z );
	*/
	
	Vector vecLOS = vecDirToEnemy; //vecMid - m_vecLastSight;
	vecLOS = vecLOS.Normalize();

	// Is the Gun looking at the target
	if (DotProduct(vecLOS, gpGlobals->v_forward) <= 0.866) // 30 degree slop
		fAttack = FALSE;
	else
		fAttack = TRUE;

	// fire the gun
	if (m_iSpin && ((fAttack) || (m_fBeserk)))
	{
		Vector vecSrc, vecAng;
		GetAttachment( 0, vecSrc, vecAng );
		SetTurretAnim(TURRET_ANIM_FIRE);
		Shoot(vecSrc, gpGlobals->v_forward );
	} 
	else
	{
		SetTurretAnim(TURRET_ANIM_SPIN);
	}

	//move the gun
	if (m_fBeserk)
	{
		if (RANDOM_LONG(0,9) == 0)
		{
			m_vecGoalAngles.y = RANDOM_FLOAT(0,360);
			m_vecGoalAngles.x = RANDOM_FLOAT(0,90) - 90 * m_iOrientation;
			TakeDamage(pev,pev,1, DMG_GENERIC); // don't beserk forever
			return;
		}
	} 
	else if (fEnemyVisible)
	{
		if (vec.y > 360)
			vec.y -= 360;

		if (vec.y < 0)
			vec.y += 360;

		//ALERT(at_console, "[%.2f]", vec.x);
		
		if (vec.x < -180)
			vec.x += 360;

		if (vec.x > 180)
			vec.x -= 360;

		// now all numbers should be in [1...360]
		// pin to turret limitations to [-90...15]

		if (m_iOrientation == 0)
		{
			if (vec.x > 90)
				vec.x = 90;
			else if (vec.x < m_iMinPitch)
				vec.x = m_iMinPitch;
		}
		else
		{
			if (vec.x < -90)
				vec.x = -90;
			else if (vec.x > -m_iMinPitch)
				vec.x = -m_iMinPitch;
		}

		// ALERT(at_console, "->[%.2f]\n", vec.x);

		m_vecGoalAngles.y = vec.y;
		m_vecGoalAngles.x = vec.x;

	}

	SpinUpCall();
	MoveTurret();
}
开发者ID:suXinjke,项目名称:HalfPayne,代码行数:101,代码来源:turret.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ RANDOM_LONG函数代码示例发布时间:2022-05-30
下一篇:
C++ RANDOM函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap