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


C++ UTIL_MakeVectors函数代码示例

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


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

示例1: Move

//=========================================================
// roach's move function
//=========================================================
void CRoach :: Move ( float flInterval ) 
{
	float		flWaypointDist;
	Vector		vecApex;

	// local move to waypoint.
	flWaypointDist = ( m_Route[ m_iRouteIndex ].vecLocation - pev->origin ).Length2D();
	MakeIdealYaw ( m_Route[ m_iRouteIndex ].vecLocation );

	ChangeYaw ( pev->yaw_speed );
	UTIL_MakeVectors( pev->angles );

	if ( RANDOM_LONG(0,7) == 1 )
	{
		// randomly check for blocked path.(more random load balancing)
		if ( !WALK_MOVE( ENT(pev), pev->ideal_yaw, 4, WALKMOVE_NORMAL ) )
		{
			// stuck, so just pick a new spot to run off to
			PickNewDest( m_iMode );
		}
	}
	
	WALK_MOVE( ENT(pev), pev->ideal_yaw, m_flGroundSpeed * flInterval, WALKMOVE_NORMAL );

	// if the waypoint is closer than step size, then stop after next step (ok for roach to overshoot)
	if ( flWaypointDist <= m_flGroundSpeed * flInterval )
	{
		// take truncated step and stop

		SetActivity ( ACT_IDLE );
		m_flLastLightLevel = GETENTITYILLUM( ENT ( pev ) );// this is roach's new comfortable light level

		if ( m_iMode == ROACH_SMELL_FOOD )
		{
			m_iMode = ROACH_EAT;
		}
		else
		{
			m_iMode = ROACH_IDLE;
		}
	}

	if ( RANDOM_LONG(0,149) == 1 && m_iMode != ROACH_SCARED_BY_LIGHT && m_iMode != ROACH_SMELL_FOOD )
	{
		// random skitter while moving as long as not on a b-line to get out of light or going to food
		PickNewDest( FALSE );
	}
}
开发者ID:tschumann,项目名称:naturalselection,代码行数:51,代码来源:roach.cpp

示例2: GetSchedule

//=========================================================
// GetSchedule 
//=========================================================
Schedule_t *CHoundeye :: GetSchedule( void )
{
	switch	( m_MonsterState )
	{
	case MONSTERSTATE_COMBAT:
		{
// dead enemy
			if ( HasConditions( bits_COND_ENEMY_DEAD ) )
			{
				// call base class, all code to handle dead enemies is centralized there.
				return CBaseMonster :: GetSchedule();
			}

			if ( HasConditions( bits_COND_LIGHT_DAMAGE | bits_COND_HEAVY_DAMAGE ) )
			{
				if ( RANDOM_FLOAT( 0 , 1 ) <= 0.4 )
				{
					TraceResult tr;
					UTIL_MakeVectors( pev->angles );
					UTIL_TraceHull( pev->origin, pev->origin + gpGlobals->v_forward * -128, dont_ignore_monsters, head_hull, ENT( pev ), &tr );

					if ( tr.flFraction == 1.0 )
					{
						// it's clear behind, so the hound will jump
						return GetScheduleOfType ( SCHED_HOUND_HOP_RETREAT );
					}
				}

				return GetScheduleOfType ( SCHED_TAKE_COVER_FROM_ENEMY );
			}

			if ( HasConditions( bits_COND_CAN_RANGE_ATTACK1 ) )
			{
				if ( OccupySlot ( bits_SLOTS_HOUND_ATTACK ) )
				{
					return GetScheduleOfType ( SCHED_RANGE_ATTACK1 );
				}

				return GetScheduleOfType ( SCHED_HOUND_AGITATED );
			}
			break;
		}
	default:
		break;
	}

	return CSquadMonster :: GetSchedule();
}
开发者ID:Skumek,项目名称:hlsdk,代码行数:51,代码来源:houndeye.cpp

示例3: GetMovedir

Vector GetMovedir( Vector vecAngles )
	{
	if (vecAngles == Vector(0, -1, 0))
	{
		return Vector(0, 0, 1);
	}
	else if (vecAngles == Vector(0, -2, 0))
	{
		return Vector(0, 0, -1);
	}
	else
	{
		UTIL_MakeVectors(vecAngles);
		return gpGlobals->v_forward;
	}
}
开发者ID:Hammermaps-DEV,项目名称:Spirit-of-Half-Life-1.8--VC2010,代码行数:16,代码来源:subs.cpp

示例4: ShootSpike

void CHellKnight :: ShootSpike( float flOffset )
{
	Vector ang = UTIL_VecToAngles( m_hEnemy->pev->origin - pev->origin );
	ang.y += flOffset * 6;
	
	UTIL_MakeVectors( ang );

	Vector org = pev->origin + pev->mins + pev->size * 0.5f + gpGlobals->v_forward * 20;

	// set missile speed
	Vector vec = gpGlobals->v_forward.Normalize();
	vec.z = -vec.z + RANDOM_FLOAT( -0.05f, 0.05f );

	EMIT_SOUND( edict(), CHAN_WEAPON, "hknight/attack1.wav", 1.0, ATTN_NORM );
	CNail::CreateKnightSpike( org, vec, this );
}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:16,代码来源:hellknight.cpp

示例5: Reload

void CHgun::PrimaryAttack()
{
    Reload( );

    if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
    {
        return;
    }

#ifndef CLIENT_DLL
    UTIL_MakeVectors( m_pPlayer->pev->v_angle );

    CBaseEntity *pHornet = CBaseEntity::Create( "hornet", m_pPlayer->GetGunPosition( ) + gpGlobals->v_forward * 16 + gpGlobals->v_right * 8 + gpGlobals->v_up * -12, m_pPlayer->pev->v_angle, m_pPlayer->edict() );
    pHornet->pev->velocity = gpGlobals->v_forward * 300;

    m_flRechargeTime = gpGlobals->time + 0.5;
#endif

    m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;


    m_pPlayer->m_iWeaponVolume = QUIET_GUN_VOLUME;
    m_pPlayer->m_iWeaponFlash = DIM_GUN_FLASH;

    int flags;
#if defined( CLIENT_WEAPONS )
    flags = FEV_NOTHOST;
#else
    flags = 0;
#endif

    PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usHornetFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, FIREMODE_TRACK, 0, 0, 0 );



    // player "shoot" animation
    m_pPlayer->SetAnimation( PLAYER_ATTACK1 );

    m_flNextPrimaryAttack = m_flNextPrimaryAttack + 0.25;

    if (m_flNextPrimaryAttack < UTIL_WeaponTimeBase() )
    {
        m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.25;
    }

    m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:47,代码来源:hornetgun.cpp

示例6: GetSmallFlinchActivity

//=========================================================
// GetSmallFlinchActivity - determines the best type of flinch
// anim to play.
//=========================================================
Activity CBaseMonster :: GetSmallFlinchActivity ( void )
{
	Activity	flinchActivity;
	BOOL		fTriedDirection;
	float		flDot;

	fTriedDirection = FALSE;
	UTIL_MakeVectors ( pev->angles );
	flDot = DotProduct ( gpGlobals->v_forward, g_vecAttackDir * -1 );
	
	switch ( m_LastHitGroup )
	{
		// pick a region-specific flinch
	case HITGROUP_HEAD:
		flinchActivity = ACT_FLINCH_HEAD;
		break;
	case HITGROUP_STOMACH:
		flinchActivity = ACT_FLINCH_STOMACH;
		break;
	case HITGROUP_LEFTARM:
		flinchActivity = ACT_FLINCH_LEFTARM;
		break;
	case HITGROUP_RIGHTARM:
		flinchActivity = ACT_FLINCH_RIGHTARM;
		break;
	case HITGROUP_LEFTLEG:
		flinchActivity = ACT_FLINCH_LEFTLEG;
		break;
	case HITGROUP_RIGHTLEG:
		flinchActivity = ACT_FLINCH_RIGHTLEG;
		break;
	case HITGROUP_GENERIC:
	default:
		// just get a generic flinch.
		flinchActivity = ACT_SMALL_FLINCH;
		break;
	}


	// do we have a sequence for the ideal activity?
	if ( LookupActivity ( flinchActivity ) == ACTIVITY_NOT_AVAILABLE )
	{
		flinchActivity = ACT_SMALL_FLINCH;
	}

	return flinchActivity;
}
开发者ID:Chuvi-w,项目名称:CSSDK,代码行数:51,代码来源:combat.cpp

示例7: FInViewCone

bool FInViewCone(Vector *pOrigin, edict_t *pEdict)
{
   Vector2D vec2LOS;
   float    flDot;

   UTIL_MakeVectors ( pEdict->v.angles );

   vec2LOS = ( *pOrigin - pEdict->v.origin ).Make2D();
   vec2LOS = vec2LOS.Normalize();

   flDot = DotProduct (vec2LOS , gpGlobals->v_forward.Make2D() );

   if ( flDot > 0.50 )  // 60 degree field of view 
      return TRUE;
   else
      return FALSE;
}
开发者ID:APGRoboCop,项目名称:RicoBot,代码行数:17,代码来源:util.cpp

示例8: UTIL_Bubbles

void CGrenade::SG_Smoke( void )
{
    if( UTIL_PointContents( pev->origin ) == CONTENTS_WATER )
    {
        UTIL_Bubbles( pev->origin - Vector( 64, 64, 64 ), pev->origin + Vector( 64, 64, 64 ), 100 );
    }
    else
    {
        UTIL_MakeVectors( pev->angles );

        Vector randomDir = gpGlobals->v_forward * RANDOM_FLOAT( 3, 8 );

        m_fLightSmoke = (int)(( ( m_fLightSmoke * 180 / M_PI ) + 30 )) % 360;

        // TODO: Check me.
        PLAYBACK_EVENT_FULL( 0,
                             NULL,
                             m_usEvent,
                             0.0,
                             pev->origin,
                             m_SGExplosionPos,
                             randomDir.x * cos( 180 / M_PI ) - randomDir.y * cos( 180 / M_PI ),
                             randomDir.x * sin( 180 / M_PI ) + randomDir.y * sin( 180 / M_PI ),
                             cos( 180 / M_PI ) * 100.0,
                             4,
                             m_bSGMulti,
                             6 );
    }

    if( m_SGSmoke <= 20 )
    {
        pev->nextthink = gpGlobals->time + 1.0;
        SetThink( &CGrenade::SG_Smoke );

        ++m_SGSmoke;
    }
    else
    {
        pev->effects |= EF_NODRAW;

        // TODO: Implements this.
        //TheBots->RemoveGrenade( this );

        UTIL_Remove( this );
    }
}
开发者ID:johndrinkwater,项目名称:CSSDK,代码行数:46,代码来源:ggrenade.cpp

示例9: GetEyes

void CHostageImprov::ClearPath()
{
	Vector start;
	Vector end;
	TraceResult result;

	if (!m_clearPathTimer.IsElapsed())
		return;

	m_clearPathTimer.Start(RANDOM_FLOAT(0.3f, 0.5f));

	const Vector eye = GetEyes();
	start = eye;

	UTIL_MakeVectors(m_hostage->pev->angles);
	end = gpGlobals->v_forward * 64 + start;

	UTIL_TraceLine(start, end, ignore_monsters, dont_ignore_glass, m_hostage->edict(), &result);

	if (result.flFraction == 1.0f)
		return;

	if (result.pHit != NULL)
	{
		entvars_t *entity = VARS(result.pHit);

		if (FClassnameIs(entity, "func_door") || FClassnameIs(entity, "func_door_rotating"))
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->Touch(m_hostage);
			}
		}
		else if (FClassnameIs(entity, "func_breakable") && entity->takedamage == DAMAGE_YES)
		{
			CBaseEntity *pObject = CBaseEntity::Instance(entity);

			if (pObject != NULL)
			{
				pObject->TakeDamage(m_hostage->pev, m_hostage->pev, 9999.9, DMG_BULLET);
			}
		}
	}
}
开发者ID:Solexid,项目名称:ReGameDLL_CS,代码行数:46,代码来源:hostage_improv.cpp

示例10: ALERT

void CFuncVehicle::Blocked(CBaseEntity *pOther)
{
	entvars_t *pevOther = pOther->pev;

	if ((pevOther->flags & FL_ONGROUND) && VARS(pevOther->groundentity) == pev)
	{
		pevOther->velocity = pev->velocity;
		return;
	}

	pevOther->velocity = (pevOther->origin - pev->origin).Normalize() * pev->dmg;
	pevOther->velocity.z += 300;
	pev->velocity = pev->velocity * 0.85;

	ALERT(at_aiconsole, "TRAIN(%s): Blocked by %s (dmg:%.2f)\n", STRING(pev->targetname), STRING(pOther->pev->classname), pev->dmg);
	UTIL_MakeVectors(pev->angles);

	Vector forward, right, vOrigin;
	Vector vFrontLeft = (gpGlobals->v_forward * -1) * (m_length * 0.5);
	Vector vFrontRight = (gpGlobals->v_right * -1) * (m_width * 0.5);

	Vector vBackLeft = pev->origin + vFrontLeft - vFrontRight;
	Vector vBackRight = pev->origin - vFrontLeft + vFrontRight;

	float minx = Q_min(vBackLeft.x, vBackRight.x);
	float miny = Q_min(vBackLeft.y, vBackRight.y);
	float maxx = Q_max(vBackLeft.x, vBackRight.x);
	float maxy = Q_max(vBackLeft.y, vBackRight.y);

	float minz = pev->origin.z;
#ifdef REGAMEDLL_FIXES
	float maxz = pev->origin.z + (2 * Q_abs(pev->mins.z - pev->maxs.z));	
#else
	float maxz = pev->origin.z + (2 * Q_abs(int(pev->mins.z - pev->maxs.z)));
#endif

	if (pOther->pev->origin.x < minx
		|| pOther->pev->origin.x > maxx
		|| pOther->pev->origin.y < miny
		|| pOther->pev->origin.y > maxy
		|| pOther->pev->origin.z < pev->origin.z
		|| pOther->pev->origin.z > maxz)
	{
		pOther->TakeDamage(pev, pev, 150, DMG_CRUSH);
	}
}
开发者ID:s1lentq,项目名称:ReGameDLL_CS,代码行数:46,代码来源:vehicle.cpp

示例11: UTIL_MakeVectors

BOOL CFuncVehicle::OnControls(entvars_t *pevTest)
{
	Vector offset = pevTest->origin - pev->origin;

	if (pev->spawnflags & SF_TRACKTRAIN_NOCONTROL)
		return FALSE;

	UTIL_MakeVectors(pev->angles);

	Vector local;
	local.x = DotProduct(offset, gpGlobals->v_forward);
	local.y = -DotProduct(offset, gpGlobals->v_right);
	local.z = DotProduct(offset, gpGlobals->v_up);

	return (local.x >= m_controlMins.x && local.y >= m_controlMins.y && local.z >= m_controlMins.z
		&& local.x <= m_controlMaxs.x && local.y <= m_controlMaxs.y && local.z <= m_controlMaxs.z);
}
开发者ID:s1lentq,项目名称:ReGameDLL_CS,代码行数:17,代码来源:vehicle.cpp

示例12: Shoot

//=========================================================
// Shoot
//=========================================================
void CHAssassin :: Shoot ( void )
{
	if (m_hEnemy == NULL)
	{
		return;
	}

	Vector vecShootOrigin = GetGunPosition();
	Vector vecShootDir = ShootAtEnemy( vecShootOrigin );

	if (m_flLastShot + 2 < gpGlobals->time)
	{
		m_flDiviation = 0.10;
	}
	else
	{
		m_flDiviation -= 0.01;
		if (m_flDiviation < 0.02)
			m_flDiviation = 0.02;
	}
	m_flLastShot = gpGlobals->time;

	UTIL_MakeVectors ( pev->angles );

	Vector	vecShellVelocity = gpGlobals->v_right * RANDOM_FLOAT(40,90) + gpGlobals->v_up * RANDOM_FLOAT(75,200) + gpGlobals->v_forward * RANDOM_FLOAT(-40, 40);
	EjectBrass ( pev->origin + gpGlobals->v_up * 32 + gpGlobals->v_forward * 12, vecShellVelocity, pev->angles.y, m_iShell, TE_BOUNCE_SHELL); 
	FireBullets(1, vecShootOrigin, vecShootDir, Vector( m_flDiviation, m_flDiviation, m_flDiviation ), 2048, BULLET_MONSTER_9MM ); // shoot +-8 degrees

	switch(RANDOM_LONG(0,1))
	{
	case 0:
		EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun1.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM);
		break;
	case 1:
		EMIT_SOUND(ENT(pev), CHAN_WEAPON, "weapons/pl_gun2.wav", RANDOM_FLOAT(0.6, 0.8), ATTN_NORM);
		break;
	}

	pev->effects |= EF_MUZZLEFLASH;

	Vector angDir = UTIL_VecToAngles( vecShootDir );
	SetBlending( 0, angDir.x );

	m_cAmmoLoaded--;
}
开发者ID:6779660,项目名称:halflife,代码行数:48,代码来源:hassassin.cpp

示例13: VecCheckToss

Vector VecCheckToss(entvars_t *pev, const Vector &vecSpot1, Vector vecSpot2, float flGravityAdj)
{
	float flGravity = CVAR_GET_FLOAT("sv_gravity") * flGravityAdj;

	if (vecSpot2.z - vecSpot1.z > 500)
		return g_vecZero;

	UTIL_MakeVectors(pev->angles);
	vecSpot2 = vecSpot2 + gpGlobals->v_right * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16));
	vecSpot2 = vecSpot2 + gpGlobals->v_forward * (RANDOM_FLOAT(-8, 8) + RANDOM_FLOAT(-16, 16));

	TraceResult tr;
	Vector vecMidPoint = vecSpot1 + (vecSpot2 - vecSpot1) * 0.5;
	UTIL_TraceLine(vecMidPoint, vecMidPoint + Vector(0, 0, 500), ignore_monsters, ENT(pev), &tr);
	vecMidPoint = tr.vecEndPos;
	vecMidPoint.z -= 50;

	if (vecMidPoint.z < vecSpot1.z || vecMidPoint.z < vecSpot2.z)
		return g_vecZero;

	float distance1 = (vecMidPoint.z - vecSpot1.z);
	float distance2 = (vecMidPoint.z - vecSpot2.z);
	float time1 = sqrt(distance1 / (0.5 * flGravity));
	float time2 = sqrt(distance2 / (0.5 * flGravity));

	if (time1 < 0.1)
		return g_vecZero;

	Vector vecGrenadeVel = (vecSpot2 - vecSpot1) / (time1 + time2);
	vecGrenadeVel.z = flGravity * time1;
	Vector vecApex = vecSpot1 + vecGrenadeVel * time1;
	vecApex.z = vecMidPoint.z;

	UTIL_TraceLine(vecSpot1, vecApex, dont_ignore_monsters, ENT(pev), &tr);

	if (tr.flFraction != 1)
		return g_vecZero;

	UTIL_TraceLine(vecSpot2, vecApex, ignore_monsters, ENT(pev), &tr);

	if (tr.flFraction != 1)
		return g_vecZero;

	return vecGrenadeVel;
}
开发者ID:AlexCSilva,项目名称:cs16-client,代码行数:45,代码来源:h_ai.cpp

示例14: UTIL_MakeVectors

void CMGargantua::StompAttack( void )
{
	TraceResult trace;

	UTIL_MakeVectors( pev->angles );
	Vector vecStart = pev->origin + Vector(0,0,60) + 35 * gpGlobals->v_forward;
	Vector vecAim = ShootAtEnemy( vecStart );
	Vector vecEnd = (vecAim * 1024) + vecStart;

	UTIL_TraceLine( vecStart, vecEnd, ignore_monsters, edict(), &trace );
	CStomp::StompCreate( vecStart, trace.vecEndPos, 0 );
	UTIL_ScreenShake( pev->origin, 12.0, 100.0, 2.0, 1000 );
	EMIT_SOUND_DYN ( edict(), CHAN_WEAPON, pStompSounds[ RANDOM_LONG(0,ARRAYSIZE(pStompSounds)-1) ], 1.0, ATTN_GARG, 0, PITCH_NORM + RANDOM_LONG(-10,10) );

	UTIL_TraceLine( pev->origin, pev->origin - Vector(0,0,20), ignore_monsters, edict(), &trace );
	if ( trace.flFraction < 1.0 )
		UTIL_DecalTrace( &trace, DECAL_GARGSTOMP1 );
}
开发者ID:ET-NiK,项目名称:amxxgroup,代码行数:18,代码来源:gargantua.cpp

示例15: angles

/*
QuakeEd only writes a single float for angles (bad idea), so up and down are
just constant angles.
*/
void SetMovedir( entvars_t *pev )
{
	if (pev->angles == Vector(0, -1, 0))
	{
		pev->movedir = Vector(0, 0, 1);
	}
	else if (pev->angles == Vector(0, -2, 0))
	{
		pev->movedir = Vector(0, 0, -1);
	}
	else
	{
		UTIL_MakeVectors(pev->angles);
		pev->movedir = gpGlobals->v_forward;
	}
	
	pev->angles = g_vecZero;
}
开发者ID:nekonomicon,项目名称:QuakeRemakeDevkit,代码行数:22,代码来源:subs.cpp


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