本文整理汇总了C++中QAngle::Init方法的典型用法代码示例。如果您正苦于以下问题:C++ QAngle::Init方法的具体用法?C++ QAngle::Init怎么用?C++ QAngle::Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QAngle
的用法示例。
在下文中一共展示了QAngle::Init方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ThrowGrenade
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponShieldGrenade::ThrowGrenade( void )
{
CBasePlayer *pPlayer = dynamic_cast<CBasePlayer*>( GetOwner() );
if ( !pPlayer )
return;
BaseClass::WeaponSound(WPN_DOUBLE);
// Calculate launch velocity (3 seconds for max distance)
float flThrowTime = min( (gpGlobals->curtime - m_flStartedThrowAt), 3.0 );
float flSpeed = 800 + (200 * flThrowTime);
// If the player's crouched, roll the grenade
if ( pPlayer->GetFlags() & FL_DUCKING )
{
// Launch the grenade
Vector vecForward;
QAngle vecAngles = pPlayer->EyeAngles();
// Throw it up just a tad
vecAngles.x = -1;
AngleVectors( vecAngles, &vecForward, NULL, NULL);
Vector vecOrigin;
VectorLerp( pPlayer->EyePosition(), pPlayer->GetAbsOrigin(), 0.25f, vecOrigin );
vecOrigin += (vecForward * 16);
vecForward = vecForward * flSpeed;
QAngle vecGrenAngles;
vecGrenAngles.Init( 0, vecAngles.y, 0 );
#if !defined( CLIENT_DLL )
CreateShieldGrenade( vecOrigin, vecGrenAngles, vecForward, vec3_angle, pPlayer, SHIELD_GRENADE_LIFETIME );
#endif
}
else
{
// Launch the grenade
Vector vecForward;
QAngle vecAngles = pPlayer->EyeAngles();
AngleVectors( vecAngles, &vecForward, NULL, NULL);
Vector vecOrigin = pPlayer->EyePosition();
vecOrigin += (vecForward * 16);
vecForward = vecForward * flSpeed;
QAngle vecGrenAngles;
vecGrenAngles.Init( 0, vecAngles.y, 0 );
#if !defined( CLIENT_DLL )
CreateShieldGrenade( vecOrigin, vecGrenAngles, vecForward, vec3_angle, pPlayer, SHIELD_GRENADE_LIFETIME );
#endif
}
pPlayer->RemoveAmmo( 1, m_iPrimaryAmmoType );
}
示例2: smn_TRTraceRay
static cell_t smn_TRTraceRay(IPluginContext *pContext, const cell_t *params)
{
cell_t *startaddr, *endaddr;
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
switch (params[4])
{
case RayType_EndPoint:
{
g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
break;
}
case RayType_Infinite:
{
g_DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
AngleVectors(g_DirAngles, &g_EndVec);
/* Make it unitary and get the ending point */
g_EndVec.NormalizeInPlace();
g_EndVec = g_StartVec + g_EndVec * MAX_TRACE_LENGTH;
break;
}
}
g_Ray.Init(g_StartVec, g_EndVec);
enginetrace->TraceRay(g_Ray, params[3], &g_HitAllFilter, &g_Trace);
g_Trace.UpdateEntRef();
return 1;
}
示例3: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponDoubleShotgun::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
if (m_iClip1 >= 2)
{
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(WPN_DOUBLE);
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_SECONDARYATTACK );
// Don't fire again until fire animation has completed
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_iClip1 -= 2;
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
FireBulletsInfo_t info( 40, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
info.m_pAttacker = pPlayer;
// Fire the bullets, and force the first shot to be perfectly accuracy
pPlayer->FireBullets( info );
QAngle punch;
punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
pPlayer->ViewPunch( punch );
if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
}
//m_bNeedPump = true;
}
else
{
if (m_bInReload)
{
Reload();
}
else
{
StartReload();
}
}
}
示例4: GetMovement
void StudioModel::GetMovement( float prevcycle[5], Vector &vecPos, QAngle &vecAngles )
{
vecPos.Init();
vecAngles.Init();
CStudioHdr *pStudioHdr = GetStudioHdr();
if ( !pStudioHdr )
return;
// assume that changes < -0.5 are loops....
if (m_cycle - prevcycle[0] < -0.5)
{
prevcycle[0] = prevcycle[0] - 1.0;
}
Studio_SeqMovement( pStudioHdr, m_sequence, prevcycle[0], m_cycle, m_poseparameter, vecPos, vecAngles );
prevcycle[0] = m_cycle;
int i;
for (i = 0; i < 4; i++)
{
Vector vecTmp;
QAngle angTmp;
if (m_Layer[i].m_cycle - prevcycle[i+1] < -0.5)
{
prevcycle[i+1] = prevcycle[i+1] - 1.0;
}
if (m_Layer[i].m_weight > 0.0)
{
vecTmp.Init();
angTmp.Init();
if (Studio_SeqMovement( pStudioHdr, m_Layer[i].m_sequence, prevcycle[i+1], m_Layer[i].m_cycle, m_poseparameter, vecTmp, angTmp ))
{
vecPos = vecPos * ( 1.0 - m_Layer[i].m_weight ) + vecTmp * m_Layer[i].m_weight;
}
}
prevcycle[i+1] = m_Layer[i].m_cycle;
}
return;
}
示例5: RegReadQAngle
bool RegReadQAngle( HKEY hKey, const char *szSubKey, QAngle& value )
{
Vector tmp;
if (RegReadVector( hKey, szSubKey, tmp ))
{
value.Init( tmp.x, tmp.y, tmp.z );
return true;
}
return false;
}
示例6: GetShootPosition
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles )
{
// Get the entity because the weapon doesn't have the right angles.
C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() );
if ( pEnt )
{
if ( pEnt == C_BasePlayer::GetLocalPlayer() )
{
vAngles = pEnt->EyeAngles();
}
else
{
vAngles = pEnt->GetRenderAngles();
}
}
else
{
vAngles.Init();
}
C_BasePlayer *player = ToBasePlayer( pEnt );
bool bUseViewModel = false;
if ( C_BasePlayer::IsLocalPlayer( pEnt ) )
{
ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pEnt );
bUseViewModel = !player->ShouldDrawLocalPlayer();
}
QAngle vDummy;
if ( IsActiveByLocalPlayer() && bUseViewModel )
{
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
if ( vm )
{
int iAttachment = vm->LookupAttachment( "muzzle" );
if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
}
else
{
// Thirdperson
int iAttachment = LookupAttachment( "muzzle" );
if ( GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
vOrigin = GetRenderOrigin();
return false;
}
示例7: smn_TRTraceRayFilter
static cell_t smn_TRTraceRayFilter(IPluginContext *pContext, const cell_t *params)
{
cell_t *startaddr, *endaddr;
IPluginFunction *pFunc;
cell_t data;
pFunc = pContext->GetFunctionById(params[5]);
if (!pFunc)
{
return pContext->ThrowNativeError("Invalid function id (%X)", params[5]);
}
if (params[0] >= 6)
{
data = params[6];
}
else
{
data = 0;
}
g_SMTraceFilter.SetFunctionPtr(pFunc, data);
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
g_StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
switch (params[4])
{
case RayType_EndPoint:
{
g_EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
break;
}
case RayType_Infinite:
{
g_DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
AngleVectors(g_DirAngles, &g_EndVec);
/* Make it unitary and get the ending point */
g_EndVec.NormalizeInPlace();
g_EndVec = g_StartVec + g_EndVec * MAX_TRACE_LENGTH;
break;
}
}
g_Ray.Init(g_StartVec, g_EndVec);
enginetrace->TraceRay(g_Ray, params[3], &g_SMTraceFilter, &g_Trace);
g_Trace.UpdateEntRef();
return 1;
}
示例8: PrimaryAttack
//-----------------------------------------------------------------------------
// Purpose:
//
//
//-----------------------------------------------------------------------------
void CWeaponShotgun::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound(SINGLE);
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
// Don't fire again until fire animation has completed
m_flNextPrimaryAttack = gpGlobals->curtime + SequenceDuration();
m_iClip1 -= 1;
// player "shoot" animation
pPlayer->SetAnimation( PLAYER_ATTACK1 );
Vector vecSrc = pPlayer->Weapon_ShootPosition( );
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_10DEGREES );
FireBulletsInfo_t info( 7, vecSrc, vecAiming, GetBulletSpread(), MAX_TRACE_LENGTH, m_iPrimaryAmmoType );
info.m_pAttacker = pPlayer;
// Fire the bullets, and force the first shot to be perfectly accuracy
pPlayer->FireBullets( info );
#ifdef SecobMod__Enable_Fixed_Multiplayer_AI
#ifndef CLIENT_DLL
// DM: Hellow? NPCs... look here! I'm shooting!
pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 1.0 );
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), SOUNDENT_VOLUME_SHOTGUN, 0.2 );
#endif
#endif //SecobMod__Enable_Fixed_Multiplayer_AI
QAngle punch;
punch.Init( SharedRandomFloat( "shotgunpax", -2, -1 ), SharedRandomFloat( "shotgunpay", -2, 2 ), 0 );
pPlayer->ViewPunch( punch );
if (!m_iClip1 && pPlayer->GetAmmoCount(m_iPrimaryAmmoType) <= 0)
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
}
m_bNeedPump = true;
}
示例9: OnPhysGunPickup
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::OnPhysGunPickup( CBasePlayer *pPhysGunUser, PhysGunPickup_t reason )
{
m_PickupTime = gpGlobals->curtime;
m_CarryAngles.Init( 45, 0, 0 );
if ( ( reason == PICKED_UP_BY_CANNON ) && ( !HasSpawnFlags( SF_DONT_WEAPON_MANAGE ) ) )
{
WeaponManager_RemoveManaged( this );
}
else if ( reason == PUNTED_BY_CANNON )
{
Launch( pPhysGunUser );
}
BaseClass::OnPhysGunPickup( pPhysGunUser, reason );
}
示例10: Init
void CTETFParticleEffect::Init( void )
{
m_vecOrigin.Init();
m_vecStart.Init();
m_vecAngles.Init();
m_iParticleSystemIndex = 0;
m_nEntIndex = -1;
m_iAttachType = PATTACH_ABSORIGIN;
m_iAttachmentPointIndex = 0;
m_bResetParticles = false;
}
示例11: FindNamedEntity
virtual bool LookupOrigin( char const *name, Vector& origin, QAngle& angles )
{
int idx = FindNamedEntity( name );
if ( idx == -1 )
{
origin.Init();
angles.Init();
return false;
}
CMapEntityData *e = &m_Entities[ idx ];
Assert( e );
origin = e->origin;
angles = e->angles;
return true;
}
示例12: GetShootPosition
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles )
{
// Get the entity because the weapon doesn't have the right angles.
C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() );
if ( pEnt )
{
if ( pEnt == C_BasePlayer::GetLocalPlayer() )
{
vAngles = pEnt->EyeAngles();
}
else
{
vAngles = pEnt->GetRenderAngles();
}
}
else
{
vAngles.Init();
}
QAngle vDummy;
if ( IsActiveByLocalPlayer() && !input->CAM_IsThirdPerson() )
{
C_BasePlayer *player = ToBasePlayer( pEnt );
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
if ( vm )
{
int iAttachment = vm->LookupAttachment( "muzzle" );
if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
}
else
{
// Thirdperson
int iAttachment = LookupAttachment( "muzzle" );
if ( GetAttachment( iAttachment, vOrigin, vDummy ) )
{
return true;
}
}
vOrigin = GetRenderOrigin();
return false;
}
示例13: smn_TRTraceRayEx
static cell_t smn_TRTraceRayEx(IPluginContext *pContext, const cell_t *params)
{
cell_t *startaddr, *endaddr;
pContext->LocalToPhysAddr(params[1], &startaddr);
pContext->LocalToPhysAddr(params[2], &endaddr);
Vector StartVec, EndVec;
Ray_t ray;
StartVec.Init(sp_ctof(startaddr[0]), sp_ctof(startaddr[1]), sp_ctof(startaddr[2]));
switch (params[4])
{
case RayType_EndPoint:
{
EndVec.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
break;
}
case RayType_Infinite:
{
QAngle DirAngles;
DirAngles.Init(sp_ctof(endaddr[0]), sp_ctof(endaddr[1]), sp_ctof(endaddr[2]));
AngleVectors(DirAngles, &EndVec);
/* Make it unitary and get the ending point */
EndVec.NormalizeInPlace();
EndVec = StartVec + EndVec * MAX_TRACE_LENGTH;
break;
}
}
sm_trace_t *tr = new sm_trace_t;
ray.Init(StartVec, EndVec);
enginetrace->TraceRay(ray, params[3], &g_HitAllFilter, tr);
tr->UpdateEntRef();
HandleError herr;
Handle_t hndl;
if (!(hndl=handlesys->CreateHandle(g_TraceHandle, tr, pContext->GetIdentity(), myself->GetIdentity(), &herr)))
{
delete tr;
return pContext->ThrowNativeError("Unable to create a new trace handle (error %d)", herr);
}
return hndl;
}
示例14: AimPrimaryWeapon
//-----------------------------------------------------------------------------
// Primary gun
//-----------------------------------------------------------------------------
void CPropAPC::AimPrimaryWeapon( const Vector &vecWorldTarget )
{
EntityMatrix parentMatrix;
parentMatrix.InitFromEntity( this, m_nMachineGunBaseAttachment );
Vector target = parentMatrix.WorldToLocal( vecWorldTarget );
float quadTarget = target.LengthSqr();
float quadTargetXY = target.x*target.x + target.y*target.y;
// Target is too close! Can't aim at it
if ( quadTarget > m_vecBarrelPos.LengthSqr() )
{
// We're trying to aim the offset barrel at an arbitrary point.
// To calculate this, I think of the target as being on a sphere with
// it's center at the origin of the gun.
// The rotation we need is the opposite of the rotation that moves the target
// along the surface of that sphere to intersect with the gun's shooting direction
// To calculate that rotation, we simply calculate the intersection of the ray
// coming out of the barrel with the target sphere (that's the new target position)
// and use atan2() to get angles
// angles from target pos to center
float targetToCenterYaw = atan2( target.y, target.x );
float centerToGunYaw = atan2( m_vecBarrelPos.y, sqrt( quadTarget - (m_vecBarrelPos.y*m_vecBarrelPos.y) ) );
float targetToCenterPitch = atan2( target.z, sqrt( quadTargetXY ) );
float centerToGunPitch = atan2( -m_vecBarrelPos.z, sqrt( quadTarget - (m_vecBarrelPos.z*m_vecBarrelPos.z) ) );
QAngle angles;
angles.Init( -RAD2DEG(targetToCenterPitch+centerToGunPitch), RAD2DEG( targetToCenterYaw + centerToGunYaw ), 0 );
SetPoseParameter( "vehicle_weapon_yaw", angles.y );
SetPoseParameter( "vehicle_weapon_pitch", angles.x );
StudioFrameAdvance();
float curPitch = GetPoseParameter( "vehicle_weapon_pitch" );
float curYaw = GetPoseParameter( "vehicle_weapon_yaw" );
m_bInFiringCone = (fabs(curPitch - angles.x) < 1e-3) && (fabs(curYaw - angles.y) < 1e-3);
}
else
{
m_bInFiringCone = false;
}
}
示例15: KeyValue
bool CGlobalLight::KeyValue( const char *szKeyName, const char *szValue )
{
if ( FStrEq( szKeyName, "color" ) )
{
float tmp[4];
UTIL_StringToFloatArray( tmp, 4, szValue );
m_LightColor.SetR( tmp[0] );
m_LightColor.SetG( tmp[1] );
m_LightColor.SetB( tmp[2] );
m_LightColor.SetA( tmp[3] );
}
else if ( FStrEq( szKeyName, "angles" ) )
{
QAngle angles;
UTIL_StringToVector( angles.Base(), szValue );
if (angles == vec3_angle)
{
angles.Init( 80, 30, 0 );
}
Vector vForward;
AngleVectors( angles, &vForward );
m_shadowDirection = vForward;
return true;
}
else if ( FStrEq( szKeyName, "texturename" ) )
{
#if defined( _X360 )
if ( Q_strcmp( szValue, "effects/flashlight001" ) == 0 )
{
// Use this as the default for Xbox
Q_strcpy( m_TextureName.GetForModify(), "effects/flashlight_border" );
}
else
{
Q_strcpy( m_TextureName.GetForModify(), szValue );
}
#else
Q_strcpy( m_TextureName.GetForModify(), szValue );
#endif
}
return BaseClass::KeyValue( szKeyName, szValue );
}