本文整理汇总了C++中QAngle函数的典型用法代码示例。如果您正苦于以下问题:C++ QAngle函数的具体用法?C++ QAngle怎么用?C++ QAngle使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了QAngle函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetAbsOrigin
//---------------------------------------------------------
//---------------------------------------------------------
void C_ASW_TeslaTrap::UpdateEffects( void )
{
//m_iTrapState = iState;
if ( !m_hEffects && m_bAssembled )
{
Vector vecOrigin;
QAngle vecAngles;
// Get the muzzle origin
if ( !GetAttachment( "effects", vecOrigin, vecAngles ) )
{
vecOrigin = GetAbsOrigin();
vecAngles = QAngle( 0, 0, 0 );
}
m_hEffects = ParticleProp()->Create( "tesla_trap_fx", PATTACH_ABSORIGIN_FOLLOW, -1, vecOrigin - GetAbsOrigin() );
if ( m_hEffects )
{
//m_hEffects->SetSortOrigin( vecOrigin );
//m_hEffects->SetControlPoint( 0, vecOrigin );
Vector vecForward, vecRight, vecUp;
AngleVectors( vecAngles, &vecForward, &vecRight, &vecUp );
m_hEffects->SetControlPointOrientation( 0, vecForward, vecRight, vecUp );
}
}
if ( m_hEffects )
{
switch( m_iTrapState )
{
case TESLATRAP_STATE_DORMANT:
// off
m_hEffects->SetControlPoint( 1, Vector( 0, 0, 0 ) );
//UpdateLight( false, 0, 0, 0, 0 );
break;
case TESLATRAP_STATE_DEPLOY:
// setting up (blue, no ring)
m_hEffects->SetControlPoint( 1, Vector( 0, 0, 0 ) );
//UpdateLight( true, 0, 0, 255, 190 );
break;
case TESLATRAP_STATE_CHARGING:
{
// searching (green glow, red ring)
// TODO: fix this hardcoded recharge time limit
// 3 seconds hardcoded charge time, plus extra time so the scale pops to full from charging so the state is more obvious
float flAmount = 1.0f - ((m_flNextFullChargeTime - gpGlobals->curtime) / (3.0f * 1.5f) );
m_hEffects->SetControlPoint( 1, Vector( flAmount, flAmount, 0 ) );
//UpdateLight( false, 0, 255, 0, 255 );
break;
}
case TESLATRAP_STATE_CHARGED:
// found poetntial enemy (red glow, red ring)
m_hEffects->SetControlPoint( 1, Vector( 1, 1, 0 ) );
//UpdateLight( false, 255, 0, 0, 255 );
break;
default:
DevMsg("**Unknown Trap State: %d\n", m_iTrapState );
break;
}
}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:67,代码来源:c_asw_tesla_trap.cpp
示例2: UTIL_PlayerByIndex
bool CFlashlightEffect::ComputeLightPosAndOrientation( const Vector &vecPos, const Vector &vecForward, const Vector &vecRight, const Vector &vecUp,
Vector& vecFinalPos, Quaternion& quatOrientation, bool bTracePlayers )
{
const float flEpsilon = 0.1f; // Offset flashlight position along vecUp
float flDistCutoff = r_flashlighttracedistcutoff.GetFloat();
const float flDistDrag = 0.2;
bool bDebugVis = r_flashlightvisualizetrace.GetBool();
C_BasePlayer *pPlayer = UTIL_PlayerByIndex( m_nEntIndex );
if ( !pPlayer )
{
pPlayer = C_BasePlayer::GetLocalPlayer();
if ( !pPlayer )
{
Assert( false );
return false;
}
}
// We will lock some of the flashlight params if player is on a ladder, to prevent oscillations due to the trace-rays
bool bPlayerOnLadder = ( pPlayer->GetMoveType() == MOVETYPE_LADDER );
CTraceFilterSkipPlayerAndViewModel traceFilter( pPlayer, bTracePlayers );
// Vector vOrigin = vecPos + r_flashlightoffsety.GetFloat() * vecUp;
Vector vecOffset;
pPlayer->GetFlashlightOffset( vecForward, vecRight, vecUp, &vecOffset );
Vector vOrigin = vecPos + vecOffset;
// Not on ladder...trace a hull
if ( !bPlayerOnLadder )
{
Vector vecPlayerEyePos = pPlayer->GetRenderOrigin() + pPlayer->GetViewOffset();
trace_t pmOriginTrace;
UTIL_TraceHull( vecPlayerEyePos, vOrigin, Vector(-2, -2, -2), Vector(2, 2, 2), ( MASK_SOLID & ~(CONTENTS_HITBOX) ) | CONTENTS_WINDOW | CONTENTS_GRATE, &traceFilter, &pmOriginTrace );//1
if ( bDebugVis )
{
debugoverlay->AddBoxOverlay( pmOriginTrace.endpos, Vector( -2, -2, -2 ), Vector( 2, 2, 2 ), QAngle( 0, 0, 0 ), 0, 255, 0, 16, 0 );
if ( pmOriginTrace.DidHit() || pmOriginTrace.startsolid )
{
debugoverlay->AddLineOverlay( pmOriginTrace.startpos, pmOriginTrace.endpos, 255, 128, 128, true, 0 );
}
else
{
debugoverlay->AddLineOverlay( pmOriginTrace.startpos, pmOriginTrace.endpos, 255, 0, 0, true, 0 );
}
}
if ( pmOriginTrace.DidHit() || pmOriginTrace.startsolid )
{
vOrigin = pmOriginTrace.endpos;
}
else
{
if ( pPlayer->m_vecFlashlightOrigin != vecPlayerEyePos )
{
vOrigin = vecPos;
}
}
}
else // on ladder...skip the above hull trace
{
vOrigin = vecPos;
}
// Now do a trace along the flashlight direction to ensure there is nothing within range to pull back from
int iMask = MASK_OPAQUE_AND_NPCS;
iMask &= ~CONTENTS_HITBOX;
iMask |= CONTENTS_WINDOW | CONTENTS_GRATE | CONTENTS_IGNORE_NODRAW_OPAQUE;
Vector vTarget = vOrigin + vecForward * r_flashlightfar.GetFloat();
// Work with these local copies of the basis for the rest of the function
Vector vDir = vTarget - vOrigin;
Vector vRight = vecRight;
Vector vUp = vecUp;
VectorNormalize( vDir );
VectorNormalize( vRight );
VectorNormalize( vUp );
// Orthonormalize the basis, since the flashlight texture projection will require this later...
vUp -= DotProduct( vDir, vUp ) * vDir;
VectorNormalize( vUp );
vRight -= DotProduct( vDir, vRight ) * vDir;
VectorNormalize( vRight );
vRight -= DotProduct( vUp, vRight ) * vUp;
VectorNormalize( vRight );
AssertFloatEquals( DotProduct( vDir, vRight ), 0.0f, 1e-3 );
AssertFloatEquals( DotProduct( vDir, vUp ), 0.0f, 1e-3 );
AssertFloatEquals( DotProduct( vRight, vUp ), 0.0f, 1e-3 );
trace_t pmDirectionTrace;
UTIL_TraceHull( vOrigin, vTarget, Vector( -1.5, -1.5, -1.5 ), Vector( 1.5, 1.5, 1.5 ), iMask, &traceFilter, &pmDirectionTrace );//.5
if ( bDebugVis )
//.........这里部分代码省略.........
开发者ID:SCell555,项目名称:hl2-asw-port,代码行数:101,代码来源:flashlighteffect.cpp
示例3: C_RotatingPickup
C_RotatingPickup() {
ClientRotAng = QAngle(45,0,0);
m_bRespawning = m_bRespawning_Cache = false;
}
开发者ID:uunx,项目名称:quakelife2,代码行数:4,代码来源:rotating_health_kit.cpp
示例4: SetVisible
//.........这里部分代码省略.........
int nWeaponHash = nWeapon * ( m_nInventorySlot + 1 );
bool bWeaponChanged = false;
if ( nWeaponHash != m_nLastWeaponHash || m_nInventorySlot != m_nLastInventorySlot )
{
m_nLastWeaponHash = nWeaponHash;
m_nLastInventorySlot = m_nInventorySlot;
bWeaponChanged = true;
// debug
//Msg( "m_nInventorySlot = %d\nnWeapon = %d\nnWeaponHash = %d\nbShowDetails = %d\n", m_nInventorySlot, nWeapon, nWeaponHash, bShowDetails ? 1 : 0 );
}
if ( bShowDetails )
{
m_pWeaponDetail0->m_bHidden = false;
m_pWeaponDetail1->m_bHidden = false;
m_pWeaponDetail2->m_bHidden = false;
m_pWeaponDetail3->m_bHidden = false;
m_pWeaponDetail4->m_bHidden = false;
m_pWeaponDetail5->m_bHidden = false;
m_pItemModelPanel->m_bShouldPaint = false;
m_pItemModelPanel->SetVisible( false );
}
else
{
m_pWeaponDetail0->m_bHidden = true;
m_pWeaponDetail1->m_bHidden = true;
m_pWeaponDetail2->m_bHidden = true;
m_pWeaponDetail3->m_bHidden = true;
m_pWeaponDetail4->m_bHidden = true;
m_pWeaponDetail5->m_bHidden = false;
Vector vecPos = Vector( -275.0, 0.0, 190.0 );
QAngle angRot = QAngle( 32.0, 0.0, 0.0 );
vecPos.z += pWeaponInfo->m_flModelPanelZOffset;
Vector vecBoundsMins, vecBoundsMax;
m_pItemModelPanel->GetBoundingBox( vecBoundsMins, vecBoundsMax );
int iMaxBounds = -vecBoundsMins.x + vecBoundsMax.x;
iMaxBounds = MAX( iMaxBounds, -vecBoundsMins.y + vecBoundsMax.y );
iMaxBounds = MAX( iMaxBounds, -vecBoundsMins.z + vecBoundsMax.z );
vecPos *= (float)iMaxBounds/64.0f;
m_pItemModelPanel->SetCameraPositionAndAngles( vecPos, angRot );
m_pItemModelPanel->SetModelAnglesAndPosition( QAngle( 0.0f, gpGlobals->curtime * 45.0f , 0.0f ), vec3_origin );
if ( bWeaponChanged )
{
m_pItemModelPanel->ClearMergeMDLs();
if ( Q_stricmp( pWeaponInfo->szDisplayModel, "" ) )
{
m_pItemModelPanel->SetMDL( pWeaponInfo->szDisplayModel );
if ( Q_stricmp( pWeaponInfo->szDisplayModel2, "" ) )
m_pItemModelPanel->SetMergeMDL( pWeaponInfo->szDisplayModel2 );
}
else
{
m_pItemModelPanel->SetMDL( pWeaponInfo->szWorldModel );
}
int nSkin = 0;
if ( pWeaponInfo->m_iDisplayModelSkin > 0 )
nSkin = pWeaponInfo->m_iDisplayModelSkin;
else
nSkin = pWeaponInfo->m_iPlayerModelSkin;
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:67,代码来源:nb_lobby_tooltip.cpp
示例5: ToBasePlayer
void CWeapon357::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if ( !pPlayer )
{
return;
}
if ( m_iClip1 <= 0 )
{
if ( !m_bFireOnEmpty )
{
Reload();
}
else
{
WeaponSound( EMPTY );
m_flNextPrimaryAttack = 0.15;
}
return;
}
m_flNextPrimaryAttack = gpGlobals->curtime + 0.75;
m_flNextSecondaryAttack = gpGlobals->curtime + 0.75;
m_iPrimaryAttacks++;
gamestats->Event_WeaponFired( pPlayer, true, GetClassname() );
WeaponSound( SINGLE );
pPlayer->DoMuzzleFlash();
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
pPlayer->SetAnimation( PLAYER_ATTACK1 );
if (GetWpnData().m_bUseMuzzleSmoke)
{
DispatchParticleEffect("weapon_muzzle_smoke", PATTACH_POINT_FOLLOW, pPlayer->GetViewModel(), "muzzle", true);
}
m_flNextPrimaryAttack = gpGlobals->curtime + 0.75;
m_flNextSecondaryAttack = gpGlobals->curtime + 0.75;
m_iClip1--;
Vector vecSrc = pPlayer->Weapon_ShootPosition();
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );
pPlayer->FireBullets( 1, vecSrc, vecAiming, vec3_origin, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 0 );
pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 );
//Disorient the player
QAngle angles = pPlayer->GetLocalAngles();
angles.x += random->RandomInt( -1, 1 );
angles.y += random->RandomInt( -1, 1 );
angles.z = 0;
pPlayer->SnapEyeAngles( angles );
pPlayer->ViewPunch( QAngle( -8, random->RandomFloat( -2, 2 ), 0 ) );
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 600, 0.2, GetOwner() );
if ( !m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 )
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate( "!HEV_AMO0", FALSE, 0 );
}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:73,代码来源:weapon_357.cpp
示例6: SetContextThink
// this is the think that flips the weapon into the world when it is spawned
void CASW_Laser_Mine::SpawnFlipThink()
{
// we are still flagged as spawn flipping in the air
if ( m_bIsSpawnFlipping == false )
{
// we get here if we spawned, but haven't started spawn flipping yet, please try again!
SetContextThink( &CASW_Laser_Mine::SpawnFlipThink, gpGlobals->curtime, s_pLaserMineSpawnFlipThink );
return;
}
// when we should hit the ground
float flEndTime = m_flSpawnFlipEndTime;
// the total time it takes for us to flip
float flFlipTime = flEndTime - m_flSpawnFlipStartTime;
float flFlipProgress = ( gpGlobals->curtime - m_flSpawnFlipStartTime ) / flFlipTime;
flFlipProgress = clamp( flFlipProgress, 0.0f, 2.5f );
if ( !m_bIsSpawnLanded )
{
// high gravity, it looks more satisfying
float flGravity = 2200;
float flInitialZVelocity = (m_vecSpawnFlipEndPos.z - m_vecSpawnFlipStartPos.z)/flFlipTime + (flGravity/2) * flFlipTime;
float flZVelocity = flInitialZVelocity - flGravity * (gpGlobals->curtime - m_flSpawnFlipStartTime);
float flXDiff = (m_vecSpawnFlipEndPos.x - m_vecSpawnFlipStartPos.x) / flFlipTime;
float flYDiff = (m_vecSpawnFlipEndPos.y - m_vecSpawnFlipStartPos.y) / flFlipTime;
Vector vecVelocity( flXDiff, flYDiff, flZVelocity );
SetAbsVelocity( vecVelocity );
// angular velocity
QAngle angCurAngVel = GetLocalAngularVelocity();
float flXAngDiff = 360 / flFlipTime;
// keep the Y angular velocity that was given to it at the start (it's random)
SetLocalAngularVelocity( QAngle( flXAngDiff, angCurAngVel.y, 0 ) );
}
if ( flFlipProgress >= 1.0f )
{
if ( !m_bIsSpawnLanded )
{
Vector vecVelStop( 0,0,0 );
SetAbsVelocity( vecVelStop );
SetAbsOrigin( m_vecSpawnFlipEndPos );
QAngle angVel( 0, 0, 0 );
SetLocalAngularVelocity( angVel );
/*
// get the current angles of the item so we can use them to determine the final angles
QAngle angPrevAngles = GetAbsAngles();
float flYAngles = angPrevAngles.y;
QAngle angFlat( 0, flYAngles, 0 );
*/
SetAbsAngles( m_angSpawnFlipEndAngle );
EmitSound("ASW_Laser_Mine.Lay");
m_bIsSpawnLanded = true;
}
if ( flFlipProgress >= 2.5f )
{
SetContextThink( NULL, 0, s_pLaserMineSpawnFlipThink );
EmitSound("ASW_Mine.Lay");
m_bMineActive = true;
return;
}
}
SetContextThink( &CASW_Laser_Mine::SpawnFlipThink, gpGlobals->curtime, s_pLaserMineSpawnFlipThink );
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:79,代码来源:asw_laser_mine.cpp
示例7: UpdateCache
// apply custom pitch to bone merge
void CASW_Bone_Merge_Cache::MergeMatchingBones( int boneMask, CBoneBitList &boneComputed, bool bOverrideDirection, const Vector &vecDir )
{
UpdateCache();
// If this is set, then all the other cache data is set.
if ( !m_pOwnerHdr || m_MergedBones.Count() == 0 )
return;
// Have the entity we're following setup its bones.
m_pFollow->SetupBones( NULL, -1, m_nFollowBoneSetupMask, gpGlobals->curtime );
matrix3x4_t matPitchUp;
AngleMatrix( QAngle( asw_weapon_pitch.GetFloat(), 0, 0 ), matPitchUp );
// Now copy the bone matrices.
for ( int i=0; i < m_MergedBones.Count(); i++ )
{
int iOwnerBone = m_MergedBones[i].m_iMyBone;
int iParentBone = m_MergedBones[i].m_iParentBone;
// Only update bones reference by the bone mask.
if ( !( m_pOwnerHdr->boneFlags( iOwnerBone ) & boneMask ) )
continue;
if ( bOverrideDirection && m_nRightHandBoneID == -1 ) // only want to change direction of the right hand bone, cache its index here
{
mstudiobone_t *pOwnerBones = m_pOwnerHdr->pBone( 0 );
for ( int k = 0; k < m_pOwnerHdr->numbones(); k++ )
{
if ( !Q_stricmp( pOwnerBones[k].pszName(), "ValveBiped.Bip01_R_Hand" ) )
{
m_nRightHandBoneID = k;
break;
}
}
}
if ( bOverrideDirection && i == m_nRightHandBoneID )
{
matrix3x4_t matParentBoneToWorld;
m_pFollow->GetBoneTransform( iParentBone, matParentBoneToWorld );
MatrixSetColumn( vec3_origin, 3, matParentBoneToWorld ); // remove translation
matrix3x4_t matParentBoneToWorldInv;
MatrixInvert( matParentBoneToWorld, matParentBoneToWorldInv );
QAngle angAiming;
VectorAngles( vecDir, Vector( 0, 0, -1 ), angAiming );
matrix3x4_t matAimDirection;
AngleMatrix( angAiming, matAimDirection );
MatrixSetColumn( vec3_origin, 3, matAimDirection ); // remove translation
matrix3x4_t matCorrection;
ConcatTransforms( matParentBoneToWorldInv, matAimDirection, matCorrection );
ConcatTransforms( m_pFollow->GetBone( iParentBone ), matCorrection, m_pOwner->GetBoneForWrite( iOwnerBone ) );
}
else
{
ConcatTransforms( m_pFollow->GetBone( iParentBone ), matPitchUp, m_pOwner->GetBoneForWrite( iOwnerBone ) );
}
boneComputed.Set( i );
}
}
开发者ID:BenLubar,项目名称:SwarmDirector2,代码行数:66,代码来源:asw_bone_merge.cpp
示例8: Plat_FloatTime
//-----------------------------------------------------------------------------
// Purpose: Runs movement commands for the player
// Input : *player -
// *ucmd -
// *moveHelper -
// Output : void CPlayerMove::RunCommand
//-----------------------------------------------------------------------------
void CPlayerMove::RunCommand ( CBasePlayer *player, CUserCmd *ucmd, IMoveHelper *moveHelper )
{
const float playerCurTime = player->m_nTickBase * TICK_INTERVAL;
const float playerFrameTime = player->m_bGamePaused ? 0 : TICK_INTERVAL;
const float flTimeAllowedForProcessing = player->ConsumeMovementTimeForUserCmdProcessing( playerFrameTime );
if ( !player->IsBot() && ( flTimeAllowedForProcessing < playerFrameTime ) )
{
// Make sure that the activity in command is erased because player cheated or dropped too many packets
double dblWarningFrequencyThrottle = sv_maxusrcmdprocessticks_warning.GetFloat();
if ( dblWarningFrequencyThrottle >= 0 )
{
static double s_dblLastWarningTime = 0;
double dblTimeNow = Plat_FloatTime();
if ( !s_dblLastWarningTime || ( dblTimeNow - s_dblLastWarningTime >= dblWarningFrequencyThrottle ) )
{
s_dblLastWarningTime = dblTimeNow;
Warning( "sv_maxusrcmdprocessticks_warning at server tick %u: Ignored client %s usrcmd (%.6f < %.6f)!\n", gpGlobals->tickcount, player->GetPlayerName(), flTimeAllowedForProcessing, playerFrameTime );
}
}
return; // Don't process this command
}
StartCommand( player, ucmd );
// Set globals appropriately
gpGlobals->curtime = playerCurTime;
gpGlobals->frametime = playerFrameTime;
// Prevent hacked clients from sending us invalid view angles to try to get leaf server code to crash
if ( !ucmd->viewangles.IsValid() || !IsEntityQAngleReasonable(ucmd->viewangles) )
{
ucmd->viewangles = vec3_angle;
}
// Add and subtract buttons we're forcing on the player
ucmd->buttons |= player->m_afButtonForced;
ucmd->buttons &= ~player->m_afButtonDisabled;
if ( player->m_bGamePaused )
{
// If no clipping and cheats enabled and noclipduring game enabled, then leave
// forwardmove and angles stuff in usercmd
if ( player->GetMoveType() == MOVETYPE_NOCLIP &&
sv_cheats->GetBool() &&
sv_noclipduringpause.GetBool() )
{
gpGlobals->frametime = TICK_INTERVAL;
}
}
// Assign the tracked weapon offset
player->m_eyeToWeaponOffset = ucmd->viewToWeaponOffset;
player->m_eyeOffset = ucmd->eyeOffset;
player->m_torsoAngles = QAngle(0, ucmd->torsoYaw, 0);
/*
// TODO: We can check whether the player is sending more commands than elapsed real time
cmdtimeremaining -= ucmd->msec;
if ( cmdtimeremaining < 0 )
{
// return;
}
*/
g_pGameMovement->StartTrackPredictionErrors( player );
CommentarySystem_PePlayerRunCommand( player, ucmd );
// Do weapon selection
if ( ucmd->weaponselect != 0 )
{
CBaseCombatWeapon *weapon = dynamic_cast< CBaseCombatWeapon * >( CBaseEntity::Instance( ucmd->weaponselect ) );
if ( weapon )
{
VPROF( "player->SelectItem()" );
player->SelectItem( weapon->GetName(), ucmd->weaponsubtype );
}
}
IServerVehicle *pVehicle = player->GetVehicle();
// Latch in impulse.
if ( ucmd->impulse )
{
// Discard impulse commands unless the vehicle allows them.
// FIXME: UsingStandardWeapons seems like a bad filter for this. The flashlight is an impulse command, for example.
if ( !pVehicle || player->UsingStandardWeaponsInVehicle() )
{
player->m_nImpulse = ucmd->impulse;
}
}
//.........这里部分代码省略.........
开发者ID:Mixpicles,项目名称:halflife-vr,代码行数:101,代码来源:player_command.cpp
示例9: GetViewModel
void CHL2MP_Player::KickAttack(void)
{
if (!IsDead())
{
CBaseViewModel *vm = GetViewModel(1);
if (vm)
{
int idealSequence = vm->SelectWeightedSequence(ACT_VM_PRIMARYATTACK);
if (idealSequence >= 0)
{
vm->SendViewModelMatchingSequence(idealSequence);
m_flNextKickAttack = gpGlobals->curtime + vm->SequenceDuration(idealSequence) - 0.5f;
}
QAngle recoil = QAngle(random->RandomFloat(1.0f, 2.0f), random->RandomFloat(-1.0f, 1.0f), 0);
this->ViewPunch(recoil);
// Trace up or down based on where the enemy is...
// But only if we're basically facing that direction
Vector vecDirection;
int kick_maxrange = 120;
AngleVectors(QAngle(clamp(EyeAngles().x, 20, kick_maxrange), EyeAngles().y, EyeAngles().z), &vecDirection);
CBaseEntity *pEnemy = MyNPCPointer() ? MyNPCPointer()->GetEnemy() : NULL;
if (pEnemy)
{
Vector vecDelta;
VectorSubtract(pEnemy->WorldSpaceCenter(), Weapon_ShootPosition(), vecDelta);
VectorNormalize(vecDelta);
Vector2D vecDelta2D = vecDelta.AsVector2D();
Vector2DNormalize(vecDelta2D);
if (DotProduct2D(vecDelta2D, vecDirection.AsVector2D()) > 0.8f)
{
vecDirection = vecDelta;
}
}
Vector vecEnd;
VectorMA(Weapon_ShootPosition(), 50, vecDirection, vecEnd);
trace_t tr;
UTIL_TraceHull(Weapon_ShootPosition(), vecEnd, Vector(-16, -16, -16), Vector(16, 16, 16), MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &tr);
// did I hit someone?
float KickDamageMult = 50 + (1 * ((fabs(GetAbsVelocity().x) + fabs(GetAbsVelocity().y) + fabs(GetAbsVelocity().z)) / 48));
float KickThrowForceMult = 20 + (1 * ((fabs(GetAbsVelocity().x) + fabs(GetAbsVelocity().y) + fabs(GetAbsVelocity().z)) / 48));
DevMsg("Kicking at %.2f of damage!\n", KickDamageMult);
DevMsg("Kicking at %.2f of force!\n", KickThrowForceMult);
if (tr.m_pEnt)
{
if (!(tr.m_pEnt))
{
// return;
}
else
{
CBasePropDoor *pDoor = dynamic_cast<CBasePropDoor*>((CBaseEntity*)tr.m_pEnt);
if (pDoor)
{
if (pDoor->HasSpawnFlags(SF_BREAKABLE_BY_PLAYER))
{
AngularImpulse angVelocity(random->RandomFloat(0, 45), 18, random->RandomFloat(-45, 45));
pDoor->PlayBreakOpenSound();
pDoor->BreakDoor(Weapon_ShootPosition(), angVelocity);
return;
}
pDoor->PlayBreakFailSound();
pDoor->KickFail();
return;
}
CBaseEntity *Victim = this->CheckTraceHullAttack(Weapon_ShootPosition(), vecEnd, Vector(-16, -16, -16), Vector(16, 16, 16), KickDamageMult, DMG_CRUSH, KickThrowForceMult, true);
if (Victim)
{
EmitSound("HL2Player.kick_body");
return;
}
}
}
UTIL_TraceLine(Weapon_ShootPosition(), vecEnd, MASK_SHOT_HULL, this, COLLISION_GROUP_NONE, &tr);//IF we hit anything else
if (tr.DidHit())
{
EmitSound("HL2Player.kick_wall");
}
else
{
EmitSound("HL2Player.kick_fire");
}
}
}
}
开发者ID:RaraFolf,项目名称:FIREFIGHT-RELOADED-src-sdk-2013,代码行数:95,代码来源:hl2mp_player.cpp
示例10: SetSolid
void CASW_Parasite::InfestMarine(CASW_Marine* pMarine)
{
if ( !pMarine )
return;
pMarine->BecomeInfested(this);
// attach
int attachment = pMarine->LookupAttachment( "chest" );
if ( attachment )
{
SetSolid( SOLID_NONE );
SetMoveType( MOVETYPE_NONE );
QAngle current(0,0,0);
Vector diff = pMarine->GetAbsOrigin() - GetAbsOrigin();
float angle = UTIL_VecToYaw(diff);
angle -= pMarine->GetAbsAngles()[YAW]; // get the diff between our angle from the marine and the marine's facing;
current = GetAbsAngles();
Vector vAttachmentPos;
pMarine->GetAttachment( attachment, vAttachmentPos );
// Make sure it's near the chest attachement before parenting
Teleport( &vAttachmentPos, &vec3_angle, &vec3_origin );
SetParent( pMarine, attachment );
float flRaise = RandomFloat( 15.0f, 18.0f );
float flForward = RandomFloat( -3.0f, 0.0f );
float flSide = RandomFloat( 1.75f, 3.0f ) * ( RandomInt( 0, 1 ) == 0 ? 1.0f : -1.0f );
if ( asw_debug_alien_damage.GetBool() )
{
Msg( "INFEST: flRaise = %f flForward = %f flSide = %f yaw = %f\n", flRaise, flForward, flSide, angle + asw_infest_angle.GetFloat() );
}
SetLocalOrigin( Vector( flForward, flSide, flRaise ) );
SetLocalAngles( QAngle( asw_infest_pitch.GetFloat(), angle + asw_infest_angle.GetFloat(), 0 ) );
// play our infesting anim
if ( asw_parasite_inside.GetBool() )
{
SetActivity(ACT_RANGE_ATTACK2);
}
else
{
int iInfestAttack = LookupSequence("Infest_attack");
if (GetSequence() != iInfestAttack)
{
ResetSequence(iInfestAttack);
}
}
AddFlag( FL_NOTARGET );
SetThink( &CASW_Parasite::InfestThink );
SetTouch( NULL );
m_bInfesting = true;
}
else
{
FinishedInfesting();
}
}
开发者ID:detoxhby,项目名称:SwarmDirector2,代码行数:63,代码来源:asw_parasite.cpp
示例11: ToBasePlayer
void CWeaponShotgun::PrimaryAttack( void )
{
// Only the player fires this way so we can cast
CBasePlayer *pPlayer = ToBasePlayer( GetOwner() );
if (!pPlayer)
{
return;
}
if ( m_iClip1 <= 0 )
{
Reload();
if ( m_iClip1 <= 0 )
DryFire( );
return;
}
// MUST call sound before removing a round from the clip of a CMachineGun
WeaponSound( SINGLE );
pPlayer->m_fEffects |= EF_MUZZLEFLASH;
SendWeaponAnim( ACT_VM_PRIMARYATTACK );
pPlayer->SetAnimation( PLAYER_ATTACK1 );
// Don't fire again until fire animation has completed
m_flNextPrimaryAttack = gpGlobals->curtime + 0.75;
m_flNextSecondaryAttack = gpGlobals->curtime + 0.75;
m_iClip1 -= 1;
Vector vecSrc = pPlayer->Weapon_ShootPosition();
Vector vecAiming = pPlayer->GetAutoaimVector( AUTOAIM_5DEGREES );
if ( g_pGameRules->IsMultiplayer() )
{
pPlayer->FireBullets( 4, vecSrc, vecAiming, VECTOR_CONE_DM_SHOTGUN, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 0 );
}
else
{
pPlayer->FireBullets( 6, vecSrc, vecAiming, VECTOR_CONE_10DEGREES, MAX_TRACE_LENGTH, m_iPrimaryAmmoType, 0 );
}
pPlayer->SetMuzzleFlashTime( gpGlobals->curtime + 1.0 );
pPlayer->ViewPunch( QAngle( -5, 0, 0 ) );
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 400, 0.2 );
if ( !m_iClip1 && pPlayer->GetAmmoCount( m_iPrimaryAmmoType ) <= 0 )
{
// HEV suit - indicate out of ammo condition
pPlayer->SetSuitUpdate("!HEV_AMO0", FALSE, 0);
}
if ( m_iClip1 > 0 )
{
m_flPumpTime = gpGlobals->curtime + 0.5;
SetWeaponIdleTime( gpGlobals->curtime + 5.0 );
}
else
{
SetWeaponIdleTime( gpGlobals->curtime + 0.75 );
}
m_fInSpecialReload = 0;
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:69,代码来源:hl1_weapon_shotgun.cpp
示例12: AngleVectors
void CSDKPlayer::FireBullet(
Vector vecSrc, // shooting postion
const QAngle &shootAngles, //shooting angle
float vecSpread, // spread vector
int iDamage, // base damage
int iBulletType, // ammo type
CBaseEntity *pevAttacker, // shooter
bool bDoEffects, // create impact effect ?
float x, // spread x factor
float y // spread y factor
)
{
float fCurrentDamage = iDamage; // damage of the bullet at it's current trajectory
float flCurrentDistance = 0.0; //distance that the bullet has traveled so far
Vector vecDirShooting, vecRight, vecUp;
AngleVectors( shootAngles, &vecDirShooting, &vecRight, &vecUp );
if ( !pevAttacker )
pevAttacker = this; // the default attacker is ourselves
// add the spray
Vector vecDir = vecDirShooting +
x * vecSpread * vecRight +
y * vecSpread * vecUp;
VectorNormalize( vecDir );
float flMaxRange = 8000;
Vector vecEnd = vecSrc + vecDir * flMaxRange; // max bullet range is 10000 units
trace_t tr; // main enter bullet trace
UTIL_TraceLine( vecSrc, vecEnd, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, this, COLLISION_GROUP_NONE, &tr );
if ( tr.fraction == 1.0f )
return; // we didn't hit anything, stop tracing shoot
if ( sv_showimpacts.GetBool() )
{
#ifdef CLIENT_DLL
// draw red client impact markers
debugoverlay->AddBoxOverlay( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), QAngle( 0, 0, 0), 255,0,0,127, 4 );
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
C_BasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->DrawClientHitboxes( 4, true );
}
#else
// draw blue server impact markers
NDebugOverlay::Box( tr.endpos, Vector(-2,-2,-2), Vector(2,2,2), 0,0,255,127, 4 );
if ( tr.m_pEnt && tr.m_pEnt->IsPlayer() )
{
CBasePlayer *player = ToBasePlayer( tr.m_pEnt );
player->DrawServerHitboxes( 4, true );
}
#endif
}
//calculate the damage based on the distance the bullet travelled.
flCurrentDistance += tr.fraction * flMaxRange;
// damage get weaker of distance
fCurrentDamage *= pow ( 0.85f, (flCurrentDistance / 500));
int iDamageType = DMG_BULLET | DMG_NEVERGIB;
if( bDoEffects )
{
// See if the bullet ended up underwater + started out of the water
if ( enginetrace->GetPointContents( tr.endpos ) & (CONTENTS_WATER|CONTENTS_SLIME) )
{
trace_t waterTrace;
UTIL_TraceLine( vecSrc, tr.endpos, (MASK_SHOT|CONTENTS_WATER|CONTENTS_SLIME), this, COLLISION_GROUP_NONE, &waterTrace );
if( waterTrace.allsolid != 1 )
{
CEffectData data;
data.m_vOrigin = waterTrace.endpos;
data.m_vNormal = waterTrace.plane.normal;
data.m_flScale = random->RandomFloat( 8, 12 );
if ( waterTrace.contents & CONTENTS_SLIME )
{
data.m_fFlags |= FX_WATER_IN_SLIME;
}
DispatchEffect( "gunshotsplash", data );
}
}
else
{
//Do Regular hit effects
// Don't decal nodraw surfaces
if ( !( tr.surface.flags & (SURF_SKY|SURF_NODRAW|SURF_HINT|SURF_SKIP) ) )
{
//.........这里部分代码省略.........
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:101,代码来源:sdk_player_shared.cpp
示例13: UTIL_TraceHull
//-----------------------------------------------------------------------------
// Purpose: Do the headlight
//-----------------------------------------------------------------------------
void CFlashlightEffect::UpdateLightNew(const Vector &vecPos, const Vector &vecForward, const Vector &vecRight, const Vector &vecUp)
{
FlashlightState_t state;
Vector end = vecPos + r_flashlightoffsety.GetFloat() * vecUp;
trace_t pmEye, pmEyeBack;
CTraceFilterSkipPlayerAndViewModel traceFilter;
UTIL_TraceHull( vecPos, end, Vector( -4, -4, -4 ), Vector ( 4, 4, 4 ), MASK_SOLID & ~(CONTENTS_HITBOX), &traceFilter, &pmEye );
if ( pmEye.fraction != 1.0f )
{
end = vecPos;
}
int iMask = MASK_OPAQUE_AND_NPCS;
iMask &= ~CONTENTS_HITBOX;
iMask |= CONTENTS_WINDOW;
// Trace a line outward, skipping the player model and the view model.
//Eye -> EyeForward
UTIL_TraceHull( end, vecPos + vecForward * r_flashlightfar.GetFloat(), Vector( -4, -4, -4 ), Vector ( 4, 4, 4 ), iMask, &traceFilter, &pmEye );
UTIL_TraceHull( end, vecPos - vecForward * 128, Vector( -4, -4, -4 ), Vector ( 4, 4, 4 ), iMask, &traceFilter, &pmEyeBack );
float flDist;
float flLength = (pmEye.endpos - end).Length();
if ( flLength <= 128 )
{
flDist = ( ( 1.0f - ( flLength / 128 ) ) * 128.0f );
}
else
{
flDist = 0.0f;
}
m_flDistMod = Lerp( 0.3f, m_flDistMod, flDist );
float flMaxDist = (pmEyeBack.endpos - end).Length();
if( m_flDistMod > flMaxDist )
m_flDistMod = flMaxDist;
Vector vStartPos = end;
Vector vEndPos = pmEye.endpos;
Vector vDir = vEndPos - vStartPos;
VectorNormalize( vDir );
if ( vDir == vec3_origin )
{
vDir = vecForward;
}
vStartPos = vStartPos - vDir * m_flDistMod;
if ( r_flashlightvisualizetrace.GetBool() == true )
{
debugoverlay->AddBoxOverlay( vEndPos, Vector( -4, -4, -4 ), Vector( 4, 4, 4 ), QAngle( 0, 0, 0 ), 0, 0, 255, 16, 0 );
debugoverlay->AddLineOverlay( vStartPos, vEndPos, 255, 0, 0, false, 0 );
}
state.m_vecLightOrigin = vStartPos;
state.m_vecLightDirection = vDir;
state.m_fQuadraticAtten = r_flashlightquadratic.GetFloat();
bool bFlicker = false;
#ifdef HL2_EPISODIC
C_BaseHLPlayer *pPlayer = (C_BaseHLPlayer *)C_BasePlayer::GetLocalPlayer();
if ( pPlayer && pPlayer->m_HL2Local.m_flSuitPower <= 10.0f )
{
float flScale = SimpleSplineRemapVal( pPlayer->m_HL2Local.m_flSuitPower, 10.0f, 4.8f, 1.0f, 0.0f );
flScale = clamp( flScale, 0.0f, 1.0f );
if ( flScale < 0.35f )
{
float flFlicker = cosf( gpGlobals->curtime * 6.0f ) * sinf( gpGlobals->curtime * 15.0f );
if ( flFlicker > 0.25f && flFlicker < 0.75f )
{
// On
state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale;
}
else
{
// Off
state.m_fLinearAtten = 0.0f;
}
}
else
{
float flNoise = cosf( gpGlobals->curtime * 7.0f ) * sinf( gpGlobals->curtime * 25.0f );
state.m_fLinearAtten = r_flashlightlinear.GetFloat() * flScale + 1.5f * flNoise;
//.........这里部分代码省略.........
开发者ID:paralin,项目名称:hl2sdk,代码行数:101,代码来源:flashlighteffect.cpp
示例14: ToBasePlayer
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CWeaponAR2::DelayedAttack( void )
{
m_bShotDelayed = false;
CBasePlayer *pOwner = ToBasePlayer( GetOwner() );
if ( pOwner == NULL )
return;
// Deplete the clip completely
SendWeaponAnim( ACT_VM_SECONDARYATTACK );
m_flNextSecondaryAttack = pOwner->m_flNextAttack = gpGlobals->curtime + SequenceDuration();
// Register a muzzleflash for the AI
pOwner->DoMuzzleFlash();
pOwner->SetMuzzleFlashTime( gpGlobals->curtime + 0.5 );
WeaponSound( WPN_DOUBLE );
pOwner->RumbleEffect(RUMBLE_SHOTGUN_DOUBLE, 0, RUMBLE_FLAG_RESTART );
// Fire the bullets
Vector vecSrc = pOwner->Weapon_ShootPosition( );
Vector vecAiming = pOwner->GetAutoaimVector( AUTOAIM_SCALE_DEFAULT );
Vector impactPoint = vecSrc + ( vecAiming * MAX_TRACE_LENGTH );
// Fire the bullets
Vector vecVelocity = vecAiming * 1000.0f;
// Fire the combine ball
CreateCombineBall( vecSrc,
vecVelocity,
sk_weapon_ar2_alt_fire_radius.GetFloat(),
sk_weapon_ar2_alt_fire_mass.GetFloat(),
sk_weapon_ar2_alt_fire_duration.GetFloat(),
pOwner );
// View effects
color32 white = {255, 255, 255, 64};
UTIL_ScreenFade( pOwner, white, 0.1, 0, FFADE_IN );
//Disorient the player
QAngle angles = pOwner->GetLocalAngles();
angles.x += random->RandomInt( -4, 4 );
angles.y += random->RandomInt( -4, 4 );
angles.z = 0;
pOwner->SnapEyeAngles( angles );
pOwner->ViewPunch( QAngle( random->RandomInt( -8, -12 ), random->RandomInt( 1, 2 ), 0 ) );
// Decrease ammo
pOwner->RemoveAmmo( 1, m_iSecondaryAmmoType );
// Can shoot again immediately
m_flNextPrimaryAttack = gpGlobals->curtime + 0.5f;
// Can blow up after a short delay (so have time to release mouse button)
m_flNextSecondaryAttack = gpGlobals->curtime + 1.0f;
}
开发者ID:SCell555,项目名称:source-sdk-2013,代码行数:64,代码来源:weapon_ar2.cpp
示例15: MAX
//-----------------------------------------------------------------------------
// Purpose: Crane rotates around with +left and +right, and extends/retracts
// the cable with +forward and +back.
//-----------------------------------------------------------------------------
void CPropCrane::DriveCrane( int iDriverButtons, int iButtonsPressed, float flNPCSteering )
{
bool bWasExtending = m_bExtending;
// Handle rotation of the crane
if ( iDriverButtons & IN_MOVELEFT )
{
// NPCs may cheat and set the steering
if ( flNPCSteering )
{
m_flTurn = flNPCSteering;
}
else
{
// Try adding some randomness to make it feel shaky?
float flTurnAdd = m_flTurnAccel;
// If we're turning back on ourselves, use decel speed
if ( m_flTurn < 0 )
{
flTurnAdd = MAX( flTurnAdd, m_flTurnDecel );
}
m_flTurn = UTIL_Approach( m_flMaxTurnSpeed, m_flTurn, flTurnAdd * gpGlobals->frametime );
}
m_iTurning = TURNING_LEFT;
}
else if ( iDriverButtons & IN_MOVERIGHT )
{
// NPCs may cheat and set the steering
if ( flNPCSteering )
{
m_flTurn = flNPCSteering;
}
else
{
// Try adding some randomness to make it feel shaky?
float flTurnAdd = m_flTurnAccel;
// If we're turning back on ourselves, increase the rate
if ( m_flTurn > 0 )
{
flTurnAdd = MAX( flTurnAdd, m_flTurnDecel );
}
m_flTurn = UTIL_Approach( -m_flMaxTurnSpeed, m_flTurn, flTurnAdd * gpGlobals->frametime );
}
m_iTurning = TURNING_RIGHT;
}
else
{
m_flTurn = UTIL_Approach( 0, m_flTurn, m_flTurnDecel * gpGlobals->frametime );
m_iTurning = TURNING_NOT;
}
if ( m_hPlayer )
{
float maxTurn = GetMaxTurnRate();
static float maxRumble = 0.35f;
static float minRumble = 0.1f;
float rumbleRange = maxRumble - minRumble;
float rumble;
float factor = fabs(m_flTurn) / maxTurn;
factor = MIN( factor, 1.0f );
rumble = minRumble + (rumbleRange * factor);
m_hPlayer->RumbleEffect( RUMBLE_FLAT_BOTH, (int)(rumble * 100), RUMBLE_FLAG_UPDATE_SCALE );
}
SetLocalAngularVelocity( QAngle(0,m_flTurn * 10,0) );
// Handle extension / retraction of the arm
if ( iDriverButtons & IN_FORWARD )
{
m_flExtensionRate = UTIL_Approach( m_flMaxExtensionSpeed, m_flExtensionRate, m_flExtensionAccel * gpGlobals->frametime );
m_bExtending = true;
}
else if ( iDriverButtons & IN_BACK )
{
m_flExtensionRate = UTIL_Approach( -m_flMaxExtensionSpeed, m_flExtensionRate, m_flExtensionAccel * gpGlobals->frametime );
m_bExtending = true;
}
else
{
m_flExtensionRate = UTIL_Approach( 0, m_flExtensionRate, m_flExtensionDecel * gpGlobals->frametime );
m_bExtending = false;
}
//Msg("Turn: %f\nExtensionRate: %f\n", m_flTurn, m_flExtensionRate );
//If we're holding down an attack button, update our state
if ( iButtonsPressed & (IN_ATTACK | IN_ATTACK2) )
{
// If we have something on the magnet, turn the magnet off
if ( m_hCraneMagnet->GetTotalMassAttachedObjects() )
{
TurnMagnetOff();
}
//.........这里部分代码省略.........
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:101,代码来源:vehicle_crane.cpp
示例16: AddSpawnFlags
//-----------------------------------------------------------------------------
// Purpose: Called when spawning, after keyvalues have been set.
//-----------------------------------------------------------------------------
void CFuncRotating::Spawn( )
{
#ifdef TF_DLL
AddSpawnFlags( SF_BRUSH_ROTATE_CLIENTSIDE );
#endif
//
// Maintain compatibility with previous maps.
//
if (m_flVolume == 0.0)
{
m_flVolume = 1.0;
}
//
// If the designer didn't set a sound attenuation, default to one.
//
if ( HasSpawnFlags(SF_BRUSH_ROTATE_SMALLRADIUS) )
{
m_flAttenuation = ATTN_IDLE;
}
else if ( HasSpawnFlags(SF_BRUSH_ROTATE_MEDIUMRADIUS) )
{
m_flAttenuation = ATTN_STATIC;
}
else if ( HasSpawnFlags(SF_BRUSH_ROTATE_LARGERADIUS) )
{
m_flAttenuation = ATTN_NORM;
}
else
{
m_flAttenuation = ATTN_NORM;
}
//
// Prevent divide by zero if level designer forgets friction!
//
if ( m_flFanFriction == 0 )
{
m_flFanFriction = 1;
}
//
// Build the axis of rotation based on spawnflags.
//
if ( HasSpawnFlags(SF_BRUSH_ROTATE_Z_AXIS) )
{
m_vecMoveAng = QAngle(0,0,1);
}
else if ( HasSpawnFlags(SF_BRUSH_ROTATE_X_AXIS) )
{
m_vecMoveAng = QAngle(1,0,0);
}
else
{
m_vecMoveAng = QAngle(0,1,0); // y-axis
}
//
// Check for reverse rotation.
//
if ( HasSpawnFlags(SF_BRUSH_ROTATE_BACKWARDS) )
{
m_vecMoveAng = m_vecMoveAng * -1;
}
SetSolid( SOLID_VPHYSICS );
//
// Some rotating objects like fake volumetric lights will not be solid.
//
if ( HasSpawnFlags(SF_ROTATING_NOT_SOLID) )
{
AddSolidFlags( FSOLID_NOT_SOLID );
SetMoveType( MOVETYPE_PUSH );
}
else
{
RemoveSolidFlags( FSOLID_NOT_SOLID );
SetMoveType( MOVETYPE_PUSH );
}
SetModel( STRING( GetModelName() ) );
SetUse( &CFuncRotating::RotatingUse );
//
// Did level designer forget to assign a maximum speed? Prevent a divide by
// zero in RampPitchVol as well as allowing the rotator to work.
//
m_flMaxSpeed = fabs( m_flMaxSpeed );
if (m_flMaxSpeed == 0)
{
m_flMaxSpeed = 100;
}
//
//.........这里部分代码省略.........
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:101,代码来源:bmodels.cpp
示例17: SetTouch
void CSnark::HuntThink( void )
{
if (!IsInWorld())
{
SetTouch( NULL );
UTIL_Remove( this );
return;
}
StudioFrameAdvance( );
SetNextThink( gpGlobals->curtime + 0.1f );
// explode when ready
if ( gpGlobals->curtime >= m_flDie )
{
g_vecAttackDir = GetAbsVelocity();
VectorNormalize( g_vecAttackDir );
m_iHealth = -1;
CTakeDamageInfo info( this, this, 1, DMG_GENERIC );
Event_Killed( info );
return;
}
// float
if ( GetWaterLevel() != 0)
{
if ( GetMoveType() == MOVETYPE_FLYGRAVITY )
{
SetMoveType( MOVETYPE_FLY, MOVECOLLIDE_FLY_BOUNCE );
}
Vector vecVel = GetAbsVelocity();
vecVel *= 0.9;
vecVel.z += 8.0;
SetAbsVelocity( vecVel );
}
else if ( GetMoveType() == MOVETYPE_FLY )
{
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
}
// return if not time to hunt
if ( m_flNextHunt > gpGlobals->curtime )
return;
m_flNextHunt = gpGlobals->curtime + 2.0;
Vector vecFlat = GetAbsVelocity();
vecFlat.z = 0;
VectorNormalize( vecFlat );
if ( GetEnemy() == NULL || !GetEnemy()->IsAlive() )
{
// find target, bounce a bit towards it.
GetSenses()->Look( 512 );
SetEnemy( BestEnemy() );
}
// squeek if it's about time blow up
if ( (m_flDie - gpGlobals->curtime <= 0.5) && (m_flDie - gpGlobals->curtime >= 0.3) )
{
CPASAttenuationFilter filter( this );
enginesound->EmitSound( filter, entindex(), CHAN_VOICE, "squeek/sqk_die1.wav", 1, ATTN_NORM, 0, 100 + random->RandomInt( 0, 0x3F ) );
CSoundEnt::InsertSound( SOUND_COMBAT, GetAbsOrigin(), 256, 0.25 );
}
// higher pitch as squeeker gets closer to detonation time
float flpitch = 155.0 - 60.0 * ( (m_flDie - gpGlobals->curtime) / SQUEEK_DETONATE_DELAY );
if ( flpitch < 80 )
flpitch = 80;
if ( GetEnemy() != NULL )
{
if ( FVisible( GetEnemy() ) )
{
m_vecTarget = GetEnemy()->EyePosition() - GetAbsOrigin();
VectorNormalize( m_vecTarget );
}
float flVel = GetAbsVelocity().Length();
float flAdj = 50.0 / ( flVel + 10.0 );
if ( flAdj > 1.2 )
flAdj = 1.2;
// ALERT( at_console, "think : enemy\n");
// ALERT( at_conso
|
请发表评论