本文整理汇总了C++中UTIL_VecToAngles函数的典型用法代码示例。如果您正苦于以下问题:C++ UTIL_VecToAngles函数的具体用法?C++ UTIL_VecToAngles怎么用?C++ UTIL_VecToAngles使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了UTIL_VecToAngles函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BarneyFirePistol
//=========================================================
// BarneyFirePistol - shoots one round from the pistol at
// the enemy barney is facing.
//=========================================================
void CBarney :: BarneyFirePistol ( void )
{
Vector vecShootOrigin;
UTIL_MakeVectors(pev->angles);
vecShootOrigin = pev->origin + Vector( 0, 0, 55 );
Vector vecShootDir = ShootAtEnemy( vecShootOrigin );
Vector angDir = UTIL_VecToAngles( vecShootDir );
SetBlending( 0, angDir.x );
pev->effects = EF_MUZZLEFLASH;
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM );
int pitchShift = RANDOM_LONG( 0, 20 );
// Only shift about half the time
if ( pitchShift > 10 )
pitchShift = 0;
else
pitchShift -= 5;
EMIT_SOUND_DYN( ENT(pev), CHAN_WEAPON, "barney/ba_attack2.wav", 1, ATTN_NORM, 0, 100 + pitchShift );
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 );
// UNDONE: Reload?
m_cAmmoLoaded--;// take away a bullet!
}
示例2: SetThink
// Sticky gib puts blood on the wall and stays put.
void CGib::StickyGibTouch(CBaseEntity *pOther)
{
Vector vecSpot;
TraceResult tr;
SetThink(&CBaseEntity::SUB_Remove);
pev->nextthink = gpGlobals->time + 10;
if (!FClassnameIs(pOther->pev, "worldspawn"))
{
pev->nextthink = gpGlobals->time;
return;
}
vecSpot = pev->origin + pev->velocity * 32;
UTIL_TraceLine(pev->origin, vecSpot, ignore_monsters, ENT(pev), &tr);
UTIL_BloodDecalTrace(&tr, m_bloodColor);
pev->velocity = tr.vecPlaneNormal * -1;
pev->angles = UTIL_VecToAngles(pev->velocity);
pev->velocity = g_vecZero;
pev->avelocity = g_vecZero;
pev->movetype = MOVETYPE_NONE;
}
示例3: GetClassPtr
//=========================================================
CQuakeRocket *CQuakeRocket::CreateRocket( Vector vecOrigin, Vector vecAngles, CBaseEntity *pOwner )
{
CQuakeRocket *pRocket = GetClassPtr( (CQuakeRocket *)NULL );
UTIL_SetOrigin( pRocket->pev, vecOrigin );
SET_MODEL(ENT(pRocket->pev), "models/rocket.mdl");
pRocket->Spawn();
pRocket->pev->classname = MAKE_STRING("missile");
pRocket->pev->owner = pOwner->edict();
// Setup
pRocket->pev->movetype = MOVETYPE_FLYMISSILE;
pRocket->pev->solid = SOLID_BBOX;
// Velocity
pRocket->pev->velocity = vecAngles * 1000;
pRocket->pev->angles = UTIL_VecToAngles( vecAngles );
// Touch
pRocket->SetTouch( CQuakeRocket::RocketTouch );
// Safety Remove
pRocket->pev->nextthink = gpGlobals->time + 5;
pRocket->SetThink( SUB_Remove );
// Effects
// pRocket->pev->effects |= EF_LIGHT;
PLAYBACK_EVENT_FULL (FEV_GLOBAL, pRocket->edict(), g_sTrail, 0.0,
(float *)&pRocket->pev->origin, (float *)&pRocket->pev->angles, 0.7, 0.0, pRocket->entindex(), ROCKET_TRAIL, 0, 0);
return pRocket;
}
示例4: GetClassPtr
CGrenade *CGrenade::ShootContact( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
// contact grenades arc lower
pGrenade->pev->gravity = 0.5;// lower gravity since grenade is aerodynamic and engine doesn't know it.
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles (pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
// make monsters afaid of it while in the air
pGrenade->SetThink( &CGrenade::DangerSoundThink );
pGrenade->pev->nextthink = gpGlobals->time;
// Tumble in air
pGrenade->pev->avelocity.x = RANDOM_FLOAT ( -100, -500 );
// Explode on contact
pGrenade->SetTouch( &CGrenade::ExplodeTouch );
pGrenade->pev->dmg = gSkillData.plrDmgM203Grenade;
return pGrenade;
}
示例5: UTIL_MakeVectors
bool AvHMine::GetDropLocation(Vector& outLocation, Vector* outAngles) const
{
bool theSuccess = false;
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming = gpGlobals->v_forward;
TraceResult tr;
UTIL_TraceLine( vecSrc, vecSrc + vecAiming*this->mRange, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
if (tr.flFraction < 1.0)
{
CBaseEntity* theEntity = CBaseEntity::Instance( tr.pHit );
// puzl: 981
// Mines can't be planted on players or buildings
if (!dynamic_cast<AvHDeployedMine*>(theEntity) && !dynamic_cast<AvHPlayer *>(theEntity) && !dynamic_cast<AvHBaseBuildable *>(theEntity))
{
int kOffset = 8;
Vector thePotentialOrigin = tr.vecEndPos + tr.vecPlaneNormal * kOffset;
BaseEntityListType theEntityList;
theEntityList.push_back(theEntity);
// Make sure there isn't an entity nearby that this would block
theEntity = NULL;
const int kMineSearchRadius = 15;
while((theEntity = UTIL_FindEntityInSphere(theEntity, thePotentialOrigin, kMineSearchRadius)) != NULL)
{
theEntityList.push_back(theEntity);
}
// For the mine placement to be valid, the entity it hit, and all the entities nearby must be valid and non-blocking
theSuccess = true;
for(BaseEntityListType::iterator theIter = theEntityList.begin(); theIter != theEntityList.end(); theIter++)
{
// puzl: 225 make sure there are no mines within kMineSearchRadius of each other ( 15 units )
CBaseEntity* theCurrentEntity = *theIter;
if(!theCurrentEntity || (theCurrentEntity->pev->flags & FL_CONVEYOR) || AvHSUGetIsExternalClassName(STRING(theCurrentEntity->pev->classname)) || dynamic_cast<CBaseDoor*>(theCurrentEntity) || dynamic_cast<CRotDoor*>(theCurrentEntity)
|| dynamic_cast<AvHDeployedMine*>(theCurrentEntity) )
{
theSuccess = false;
break;
}
}
if(theSuccess)
{
VectorCopy(thePotentialOrigin, outLocation);
if(outAngles)
{
VectorCopy(UTIL_VecToAngles( tr.vecPlaneNormal ), *outAngles)
}
}
}
示例6: EyePosition
void CCSBot::UpdateLookAt()
{
Vector to = m_lookAtSpot - EyePosition();
Vector idealAngle = UTIL_VecToAngles(to);
idealAngle.x = 360.0f - idealAngle.x;
SetLookAngles(idealAngle.y, idealAngle.x);
}
示例7: BarneyFirePistol
//=========================================================
// BarneyFirePistol - shoots one round from the pistol at
// the enemy barney is facing.
//=========================================================
void CFriend :: BarneyFirePistol ( void )
{
Vector vecShootOrigin;
UTIL_MakeVectors(pev->angles);
vecShootOrigin = pev->origin + Vector( 0, 0, 55 );
Vector vecShootDir = ShootAtEnemy( vecShootOrigin );
Vector angDir = UTIL_VecToAngles( vecShootDir );
SetBlending( 0, angDir.x );
pev->effects = EF_MUZZLEFLASH;
if (pev->frags)
{
FireBullets(8, vecShootOrigin, vecShootDir, VECTOR_CONE_10DEGREES, 1024, BULLET_PLAYER_BUCKSHOT);//357
EMIT_SOUND( ENT(pev), CHAN_WEAPON, "weapons/shotgun/sbarrel1.wav", 1, ATTN_NORM );
}
else
{
FireBullets(1, vecShootOrigin, vecShootDir, VECTOR_CONE_2DEGREES, 1024, BULLET_MONSTER_9MM );
int pitchShift = RANDOM_LONG( 0, 20 );
// Only shift about half the time
if ( pitchShift > 10 )
pitchShift = 0;
else
pitchShift -= 5;
EMIT_SOUND( ENT(pev), CHAN_WEAPON, "weapons/m16/m16_fire-1.wav", 1, ATTN_NORM );
}
CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, 384, 0.3 );
// UNDONE: Reload?
m_cAmmoLoaded--;// take away a bullet!
// Teh_Freak: World Lighting!
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_DLIGHT );
WRITE_COORD( vecShootOrigin.x ); // origin
WRITE_COORD( vecShootOrigin.y );
WRITE_COORD( vecShootOrigin.z );
WRITE_BYTE( 16 ); // radius
WRITE_BYTE( 255 ); // R
WRITE_BYTE( 255 ); // G
WRITE_BYTE( 128 ); // B
WRITE_BYTE( 0 ); // life * 10
WRITE_BYTE( 0 ); // decay
MESSAGE_END();
// Teh_Freak: World Lighting!
CBaseEntity *pPlayer = UTIL_PlayerByIndex( 1 );
if (pPlayer->m_fSlowMotionOn)
CBullet::Shoot( pev, vecShootOrigin, vecShootDir * 500 );
}
示例8: UTIL_MakeVectors
void CTripmine::PrimaryAttack( void )
{
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return;
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming = gpGlobals->v_forward;
TraceResult tr;
UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
int flags;
#ifdef CLIENT_WEAPONS
flags = FEV_NOTHOST;
#else
flags = 0;
#endif
PLAYBACK_EVENT_FULL( flags, m_pPlayer->edict(), m_usTripFire, 0.0, (float *)&g_vecZero, (float *)&g_vecZero, 0.0, 0.0, 0, 0, 0, 0 );
if (tr.flFraction < 1.0)
{
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
if ( pEntity && !(pEntity->pev->flags & FL_CONVEYOR) )
{
Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );
CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() );
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
if ( m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0 )
{
// no more mines!
RetireWeapon();
return;
}
}
else
{
// ALERT( at_console, "no deploy\n" );
}
}
else
{
}
m_flNextPrimaryAttack = UTIL_WeaponTimeBase() + 0.3;
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + UTIL_SharedRandomFloat( m_pPlayer->random_seed, 10, 15 );
}
示例9: GetClassPtr
void CHostage::MoveToward(Vector &vecLoc)
{
int nFwdMove;
Vector vecFwd;
Vector vecbigDest;
Vector vecMove;
CBaseEntity *pFollowing;
Vector vecAng;
float flDist;
pFollowing = GetClassPtr((CBaseEntity *)m_hTargetEnt->pev);
vecMove = vecLoc - pev->origin;
vecAng = UTIL_VecToAngles(vecMove);
vecAng = Vector(0, vecAng.y, 0);
UTIL_MakeVectorsPrivate(vecAng, vecFwd, NULL, NULL);
if ((vecFwd * m_LocalNav->s_flStepSize).Length2D() <= (vecLoc - pev->origin).Length2D())
flDist = (vecFwd * m_LocalNav->s_flStepSize).Length2D();
else
flDist = (vecLoc - pev->origin).Length2D();
vecbigDest = pev->origin + (vecFwd * flDist);
nFwdMove = m_LocalNav->PathTraversable(pev->origin, vecbigDest, FALSE);
if (nFwdMove != TRAVERSABLE_NO)
{
vecbigDest = pFollowing->pev->origin;
vecbigDest.z += pFollowing->pev->mins.z;
if (FBitSet(pev->flags, FL_ONGROUND))
{
flDist = (vecbigDest - pev->origin).Length();
if (flDist >= 110)
{
if (flDist >= 250)
flDist = 400;
else
flDist = 300;
}
}
else
flDist = 250;
pev->velocity.x = vecFwd.x * flDist;
pev->velocity.y = vecFwd.y * flDist;
UTIL_DrawBeamPoints(pev->origin, pev->origin + (pev->velocity.Normalize() * 500), 10, 255, 0, 0);
if (nFwdMove != TRAVERSABLE_STEP && nFwdMove == TRAVERSABLE_STEPJUMPABLE)
{
if (FBitSet(pev->flags, FL_ONGROUND))
pev->velocity.z = 270;
}
}
}
示例10: UTIL_MakeVectors
void CTripmine::PrimaryAttack( void )
{
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] <= 0)
return;
UTIL_MakeVectors( m_pPlayer->pev->v_angle + m_pPlayer->pev->punchangle );
Vector vecSrc = m_pPlayer->GetGunPosition( );
Vector vecAiming = gpGlobals->v_forward;
TraceResult tr;
UTIL_TraceLine( vecSrc, vecSrc + vecAiming * 128, dont_ignore_monsters, ENT( m_pPlayer->pev ), &tr );
if (tr.flFraction < 1.0)
{
// ALERT( at_console, "hit %f\n", tr.flFraction );
CBaseEntity *pEntity = CBaseEntity::Instance( tr.pHit );
if (pEntity && !(pEntity->pev->flags & FL_CONVEYOR))
{
Vector angles = UTIL_VecToAngles( tr.vecPlaneNormal );
CBaseEntity *pEnt = CBaseEntity::Create( "monster_tripmine", tr.vecEndPos + tr.vecPlaneNormal * 8, angles, m_pPlayer->edict() );
CTripmineGrenade *pMine = (CTripmineGrenade *)pEnt;
m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType]--;
// player "shoot" animation
m_pPlayer->SetAnimation( PLAYER_ATTACK1 );
if (m_pPlayer->m_rgAmmo[m_iPrimaryAmmoType] > 0)
{
SendWeaponAnim( TRIPMINE_DRAW );
}
else
{
// no more mines!
RetireWeapon();
return;
}
}
else
{
// ALERT( at_console, "no deploy\n" );
}
}
else
{
}
m_flNextPrimaryAttack = gpGlobals->time + 0.3;
m_flTimeWeaponIdle = gpGlobals->time + RANDOM_FLOAT ( 10, 15 );
}
示例11: Torch
// =========================================================
// TORCH SUPPORT
// =========================================================
void CGenericMonster :: Torch ( void )
{
Vector vecGunPos;
Vector vecGunAngles;
Vector vecShootDir;
GetAttachment( 4, vecGunPos, vecGunAngles );
pev->effects |= EF_MUZZLEFLASH;
Vector angDir = UTIL_VecToAngles( vecShootDir );
SetBlending( 0, angDir.x );
}
示例12: ShootFrag
CGrenade * CGrenade :: ShootFrag( entvars_t *pevOwner, Vector vecStart, Vector vecVelocity, int mode )
{
CGrenade *pGrenade = GetClassPtr( (CGrenade *)NULL );
pGrenade->Spawn();
UTIL_SetOrigin( pGrenade->pev, vecStart );
pGrenade->pev->velocity = vecVelocity;
pGrenade->pev->angles = UTIL_VecToAngles(pGrenade->pev->velocity);
pGrenade->pev->owner = ENT(pevOwner);
pGrenade->pev->solid = SOLID_BBOX;
if ( mode == 1 )
{
SET_MODEL(ENT(pGrenade->pev), "models/w_fgrenade.mdl");
pGrenade->SetTouch( FragTouch );
pGrenade->SetThink( FragThink );
pGrenade->pev->nextthink = gpGlobals->time + 0.1;
}
else
{
SET_MODEL(ENT(pGrenade->pev), "models/w_frag.mdl");
pGrenade->SetThink( Detonate );
pGrenade->pev->nextthink = gpGlobals->time + RANDOM_FLOAT( 2,3 );
pGrenade->pev->solid = SOLID_NOT;
}
MESSAGE_BEGIN( MSG_BROADCAST, SVC_TEMPENTITY );
WRITE_BYTE( TE_BEAMFOLLOW );
WRITE_SHORT(pGrenade->entindex()); // entity
WRITE_SHORT(iFgTrail ); // model
WRITE_BYTE( 10 ); // life
WRITE_BYTE( 1.5 ); // width
WRITE_BYTE( 240 ); // r, g, b
WRITE_BYTE( 215 ); // r, g, b
WRITE_BYTE( 80 ); // r, g, b
WRITE_BYTE( 200 ); // brightness
MESSAGE_END();
pGrenade->pev->sequence = 4;
pGrenade->pev->framerate = 6;
pGrenade->pev->gravity = 0.35;
pGrenade->pev->friction = 0.9;
pGrenade->pev->dmg = 100;
return pGrenade;
}
示例13: GetClassPtr
CTankProj *CTankProj::ShootTankProj(entvars_t *pevOwner, Vector vecStart, Vector vecVelocity)
{
CTankProj *pTankProj = GetClassPtr( (CTankProj *)NULL );
pTankProj->Spawn();
UTIL_SetOrigin(pTankProj->pev, vecStart);
pTankProj->pev->velocity = vecVelocity;
pTankProj->pev->angles = UTIL_VecToAngles (pTankProj->pev->velocity);
pTankProj->pev->owner = ENT(pevOwner);
pTankProj->SetTouch( ExplodeTouch );
pTankProj->pev->dmg = dmg_tank_cannon.value * (mp_wpn_power.value/100);
return pTankProj;
}
示例14: switch
//=========================================================
// RunTask
//=========================================================
void CMGargantua::RunTask( Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_FLAME_SWEEP:
if ( gpGlobals->time > m_flWaitFinished )
{
FlameDestroy();
TaskComplete();
FlameControls( 0, 0 );
SetBoneController( 0, 0 );
SetBoneController( 1, 0 );
}
else
{
BOOL cancel = FALSE;
Vector angles = g_vecZero;
FlameUpdate();
edict_t *pEnemy = m_hEnemy;
if ( pEnemy )
{
Vector org = pev->origin;
org.z += 64;
Vector dir = UTIL_BodyTarget(pEnemy,org) - org;
angles = UTIL_VecToAngles( dir );
angles.x = -angles.x;
angles.y -= pev->angles.y;
if ( dir.Length() > 400 )
cancel = TRUE;
}
if ( fabs(angles.y) > 60 )
cancel = TRUE;
if ( cancel )
{
m_flWaitFinished -= 0.5;
m_flameTime -= 0.5;
}
// FlameControls( angles.x + 2 * sin(gpGlobals->time*8), angles.y + 28 * sin(gpGlobals->time*8.5) );
FlameControls( angles.x, angles.y );
}
break;
default:
CMBaseMonster::RunTask( pTask );
break;
}
}
示例15: UpdateCamAngle
void CTank :: UpdateCamAngle ( Vector vecNewPosition, float flTime )
{
Vector vecNewAngle;
GetAttachment( 2, vecCamTarget, Vector ( 0, 0, 0 ) );
vecNewAngle = UTIL_VecToAngles( vecCamTarget - vecNewPosition );
vecNewAngle.x = -vecNewAngle.x;
float distX = UTIL_AngleDistance( m_pCam->pev->angles.x, vecNewAngle.x );
m_pCam->pev->avelocity.x = -distX / flTime;
float distY = UTIL_AngleDistance( m_pCam->pev->angles.y, vecNewAngle.y );
m_pCam->pev->avelocity.y = -distY / flTime;
}