本文整理汇总了C++中GetLocalOrigin函数的典型用法代码示例。如果您正苦于以下问题:C++ GetLocalOrigin函数的具体用法?C++ GetLocalOrigin怎么用?C++ GetLocalOrigin使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了GetLocalOrigin函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: WeaponManager_RemoveManaged
//-----------------------------------------------------------------------------
// Fling the buster with the physcannon either via punt or launch.
//-----------------------------------------------------------------------------
void CWeaponStriderBuster::Launch( CBasePlayer *pPhysGunUser )
{
if ( !HasSpawnFlags( SF_DONT_WEAPON_MANAGE ) )
{
WeaponManager_RemoveManaged( this );
}
m_bLaunched = true;
// Notify all nearby hunters that we were launched.
Hunter_StriderBusterLaunched( this );
// Start up the eye glow
m_hMainGlow = CSprite::SpriteCreate( "sprites/blueglow1.vmt", GetLocalOrigin(), false );
if ( m_hMainGlow != NULL )
{
m_hMainGlow->FollowEntity( this );
m_hMainGlow->SetTransparency( kRenderGlow, 255, 255, 255, 140, kRenderFxNoDissipation );
m_hMainGlow->SetScale( 2.0f );
m_hMainGlow->SetGlowProxySize( 8.0f );
}
if ( !m_bNoseDiving )
{
DispatchParticleEffect( "striderbuster_trail", PATTACH_ABSORIGIN_FOLLOW, this );
}
else
{
DispatchParticleEffect( "striderbuster_shotdown_trail", PATTACH_ABSORIGIN_FOLLOW, this );
}
// We get our touch function from the physics system
SetTouch ( &CWeaponStriderBuster::BusterTouch );
SetThink( &CWeaponStriderBuster::BusterFlyThink );
SetNextThink( gpGlobals->curtime );
gamestats->Event_WeaponFired( pPhysGunUser, true, GetClassname() );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:43,代码来源:weapon_striderbuster.cpp
示例2: GetAbsVelocity
void CDHLProjectile::ReceiveMessage( int classID, bf_read &msg )
{
if ( classID != GetClientClass()->m_ClassID )
{
// message is for subclass
BaseClass::ReceiveMessage( classID, msg );
return;
}
int iType = msg.ReadByte();
//Server is letting us know that we're about to be deleted
if ( iType == MSG_NOTIFY_REMOVAL )
{
if ( !m_bCollided )
{
Vector vecDir = vec3_origin;
if ( GetAbsVelocity() != vec3_origin )
vecDir = GetAbsVelocity();
else
vecDir = m_vecProjectileVelocity;
VectorNormalize( vecDir );
Vector vecStartPos = GetMoveType() == MOVETYPE_CUSTOM ? GetLocalOrigin() : m_vecProjectileOrigin;
//Try to plant a decal
trace_t decaltr;
UTIL_TraceLine( vecStartPos, vecStartPos + (vecDir * 120.0), MASK_SHOT, this, //Pretty long distance, but seems necessary in practice
COLLISION_GROUP_NONE, &decaltr );
//DebugDrawLine( decaltr.startpos, decaltr.endpos, 255, 0, 0, false, 3.0f );
if ( decaltr.DidHit() )
{
OnTouch( decaltr, true );
}
m_bCollided = true;
}
}
}
开发者ID:dreckard,项目名称:dhl2,代码行数:39,代码来源:dhl_projectile_shared.cpp
示例3: SetTouch
void CASW_Parasite::Leap( const Vector &vecVel )
{
SetTouch( &CASW_Parasite::LeapTouch );
SetCondition( COND_FLOATING_OFF_GROUND );
SetGroundEntity( NULL );
m_flIgnoreWorldCollisionTime = gpGlobals->curtime + PARASITE_IGNORE_WORLD_COLLISION_TIME;
if( HasHeadroom() )
{
// Take him off ground so engine doesn't instantly reset FL_ONGROUND.
UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0, 0, 1 ) );
}
SetAbsVelocity( vecVel );
// Think every frame so the player sees the headcrab where he actually is...
m_bMidJump = true;
SetThink( &CASW_Parasite::LeapThink );
SetNextThink( gpGlobals->curtime );
}
开发者ID:detoxhby,项目名称:SwarmDirector2,代码行数:22,代码来源:asw_parasite.cpp
示例4: Precache
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CASW_Shotgun_Pellet_Predicted::Spawn( void )
{
Precache();
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_CUSTOM );
SetSolid( SOLID_BBOX );
//m_flGravity = 1.0;
SetFriction( 0.75 );
SetModel( PELLET_MODEL );
SetSize( -Vector(1,1,1), Vector(1,1,1) );
SetSolid( SOLID_BBOX );
SetGravity( 0.05f );
SetCollisionGroup( ASW_COLLISION_GROUP_SHOTGUN_PELLET );
SetTouch( &CASW_Shotgun_Pellet_Predicted::PelletTouch );
SetThink( &CASW_Shotgun_Pellet_Predicted::SUB_Remove );
SetNextThink( gpGlobals->curtime + 1.0f );
m_flDamage = 10;
m_takedamage = DAMAGE_NO;
// Create a white light
CBasePlayer *player = ToBasePlayer( GetOwnerEntity() );
if ( player )
{
m_hLiveSprite = SPRITE_CREATE_PREDICTABLE( "sprites/chargeball2.vmt", GetLocalOrigin() + Vector(0,0,1), false );
if ( m_hLiveSprite )
{
m_hLiveSprite->SetOwnerEntity( player );
m_hLiveSprite->SetPlayerSimulated( player );
m_hLiveSprite->SetTransparency( kRenderGlow, 255, 255, 255, 128, kRenderFxNoDissipation );
m_hLiveSprite->SetBrightness( 255 );
m_hLiveSprite->SetScale( 0.15, 5.0f );
m_hLiveSprite->SetAttachment( this, 0 );
}
}
}
开发者ID:Cre3per,项目名称:hl2sdk-csgo,代码行数:42,代码来源:asw_shotgun_pellet_predicted_shared.cpp
示例5: GetLocalOrigin
//-----------------------------------------------------------------------------
// Purpose: Explode
// Input :
// Output :
//-----------------------------------------------------------------------------
void CPlayer_Missile::LoseMissileControl(void)
{
// Create a missile to take the place of this one
CGrenadeHomer *pGrenade = (CGrenadeHomer*)CreateEntityByName( "grenade_homer" );
if ( pGrenade )
{
pGrenade->Spawn();
pGrenade->SetLocalOrigin( GetLocalOrigin() );
pGrenade->SetLocalAngles( GetLocalAngles() );
pGrenade->SetModel( PMISSILE_MISSILE_MODEL );
pGrenade->SetDamage(m_flDamage);
pGrenade->SetDamageRadius(m_flDamageRadius);
pGrenade->Launch(this,NULL,GetAbsVelocity(),0,0,HOMER_SMOKE_TRAIL_OFF);
pGrenade->m_hRocketTrail[0] = m_hSmokeTrail;
((SmokeTrail*)(CBaseEntity*)m_hSmokeTrail)->FollowEntity(ENTINDEX(pGrenade->pev));
}
m_takedamage = DAMAGE_NO;
m_lifeState = LIFE_DEAD;
StopSound( "Player_Manhack.Fly" );
ControlDeactivate();
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:27,代码来源:player_missile.cpp
示例6: GetLocalOrigin
//-----------------------------------------------------------------------------
// Purpose: Aim the offset barrel at a position in parent space
// Input : parentTarget - the position of the target in parent space
// Output : Vector - angles in local space
//-----------------------------------------------------------------------------
QAngle CAPCController::AimBarrelAt( const Vector &parentTarget )
{
Vector target = parentTarget - GetLocalOrigin();
float quadTarget = target.LengthSqr();
float quadTargetXY = target.x*target.x + target.y*target.y;
// 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_barrelPos.y, sqrt( quadTarget - (m_barrelPos.y*m_barrelPos.y) ) );
float targetToCenterPitch = atan2( target.z, sqrt( quadTargetXY ) );
float centerToGunPitch = atan2( -m_barrelPos.z, sqrt( quadTarget - (m_barrelPos.z*m_barrelPos.z) ) );
return QAngle( -RAD2DEG(targetToCenterPitch+centerToGunPitch), RAD2DEG( targetToCenterYaw + centerToGunYaw ), 0 );
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:28,代码来源:point_apc_controller.cpp
示例7: GetLocalOrigin
// Assumes this is ALWAYS enabled
CPathTrack *CPathTrack::Nearest( const Vector &origin )
{
int deadCount;
float minDist, dist;
Vector delta;
CPathTrack *ppath, *pnearest;
delta = origin - GetLocalOrigin();
delta.z = 0;
minDist = delta.Length();
pnearest = this;
ppath = GetNext();
// Hey, I could use the old 2 racing pointers solution to this, but I'm lazy :)
deadCount = 0;
while ( ppath && ppath != this )
{
deadCount++;
if ( deadCount > 9999 )
{
Warning( "Bad sequence of path_tracks from %s\n", GetDebugName() );
Assert(0);
return NULL;
}
delta = origin - ppath->GetLocalOrigin();
delta.z = 0;
dist = delta.Length();
if ( dist < minDist )
{
minDist = dist;
pnearest = ppath;
}
ppath = ppath->GetNext();
}
return pnearest;
}
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:38,代码来源:pathtrack.cpp
示例8: switch
//------------------------------------------------------------------------------
// Purpose: routine called every frame when a task is running
// Input : pTask - the task structure
//------------------------------------------------------------------------------
void CAI_ASW_MeleeBehavior::RunTask( const Task_t *pTask )
{
switch( pTask->iTask )
{
case TASK_MELEE_FLIP_AROUND:
{
CBaseEntity *pTarget = GetEnemy();
if ( pTarget )
{
GetMotor()->SetIdealYawAndUpdate( pTarget->GetAbsOrigin() - GetLocalOrigin(), AI_KEEP_YAW_SPEED );
}
if ( GetOuter()->IsActivityFinished() )
{
TaskComplete();
}
}
break;
default:
BaseClass::RunTask( pTask );
break;
}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:28,代码来源:asw_ai_behavior_melee.cpp
示例9: SetMoveType
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CShieldGrenade::Spawn( void )
{
BaseClass::Spawn();
m_LastCollision.Init( 0, 0, 0 );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
SetGravity( 1.0 );
SetFriction( 0.9 );
SetModel( "models/weapons/w_grenade.mdl");
UTIL_SetSize(this, Vector( -4, -4, -4), Vector(4, 4, 4));
m_IsEMPed = false;
m_IsDeployed = false;
m_flEMPDamageEndTime = 0.0f;
SetTouch( StickyTouch );
SetCollisionGroup( TFCOLLISION_GROUP_GRENADE );
// Create a green light
m_pLiveSprite = CSprite::SpriteCreate( "sprites/redglow1.vmt", GetLocalOrigin() + Vector(0,0,1), false );
m_pLiveSprite->SetTransparency( kRenderGlow, 0, 0, 255, 128, kRenderFxNoDissipation );
m_pLiveSprite->SetScale( 1 );
m_pLiveSprite->SetAttachment( this, 0 );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:27,代码来源:tf_shieldgrenade.cpp
示例10: SetModel
//-----------------------------------------------------------------------------
// Little hack to avoid game crash when changing bodygroup (DmitRex)
//-----------------------------------------------------------------------------
void CZombie::SetHeadlessModel( void )
{
SetModel("");
CreateRagGib( "models/zombie/classic.mdl", GetLocalOrigin(), GetLocalAngles(), GetLocalVelocity(), 0, ShouldIgniteZombieGib() );
}
开发者ID:SCell555,项目名称:hl2-asw-port,代码行数:8,代码来源:npc_zombie.cpp
示例11: SetNextThink
//.........这里部分代码省略.........
// Calculate angle needed to aim at target
worldTargetPosition = pEntity->EyePosition();
}
float range = (worldTargetPosition - barrelEnd).Length();
if ( !InRange( range ) )
{
m_fireLast = 0;
return;
}
UTIL_TraceLine( barrelEnd, worldTargetPosition, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr );
if (m_spawnflags & SF_TANK_AIM_AT_POS)
{
updateTime = TRUE;
m_sightOrigin = m_vTargetPosition;
}
else
{
lineOfSight = FALSE;
// No line of sight, don't track
if ( tr.fraction == 1.0 || tr.m_pEnt == pTarget )
{
lineOfSight = TRUE;
CBaseEntity *pInstance = pTarget;
if ( InRange( range ) && pInstance && pInstance->IsAlive() )
{
updateTime = TRUE;
// Sight position is BodyTarget with no noise (so gun doesn't bob up and down)
m_sightOrigin = pInstance->BodyTarget( GetLocalOrigin(), false );
}
}
}
// Convert targetPosition to parent
angles = AimBarrelAt( m_parentMatrix.WorldToLocal( m_sightOrigin ) );
}
// Force the angles to be relative to the center position
float offsetY = UTIL_AngleDistance( angles.y, m_yawCenter );
float offsetX = UTIL_AngleDistance( angles.x, m_pitchCenter );
angles.y = m_yawCenter + offsetY;
angles.x = m_pitchCenter + offsetX;
// Limit against range in y
// MDB - don't check pitch! If two func_tanks are meant to align,
// and one can pitch and the other cannot, this can lead to them getting
// different values for angles.y. Nothing is lost by not updating yaw
// because the target is not in pitch range.
bool bOutsideYawRange = ( fabs( offsetY ) > m_yawRange + m_yawTolerance );
bool bOutsidePitchRange = ( fabs( offsetX ) > m_pitchRange + m_pitchTolerance );
Vector vecToTarget = m_sightOrigin - GetLocalOrigin();
// if target is outside yaw range
if ( bOutsideYawRange )
{
if ( angles.y > m_yawCenter + m_yawRange )
{
angles.y = m_yawCenter + m_yawRange;
开发者ID:AgentAgrimar,项目名称:source-sdk-trilogy,代码行数:67,代码来源:hl1_func_tank.cpp
示例12: GetLocalOrigin
void CPhysMotor::Spawn( void )
{
m_motor.m_axis -= GetLocalOrigin();
VectorNormalize(m_motor.m_axis);
UTIL_SnapDirectionToAxis( m_motor.m_axis );
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:6,代码来源:phys_controller.cpp
示例13: SetBits
void CBaseDoor::Spawn( void )
{
if( pev->skin == CONTENTS_NONE )
{
// normal door
if( FBitSet( pev->spawnflags, SF_DOOR_PASSABLE ))
pev->solid = SOLID_NOT;
else
pev->solid = SOLID_BSP;
}
else
{
SetBits( pev->spawnflags, SF_DOOR_SILENT );
pev->solid = SOLID_NOT; // special contents
}
Precache();
pev->movetype = MOVETYPE_PUSH;
SET_MODEL( edict(), GetModel() );
// NOTE: original Half-Life was contain a bug in LinearMove function
// while m_flWait was equal 0 then object has stopped forever. See code from quake:
/*
void LinearMove( Vector vecDest, float flSpeed )
{
...
...
...
if( flTravelTime < 0.1f )
{
pev->velocity = g_vecZero;
pev->nextthink = pev->ltime + 0.1f;
return;
}
}
*/
// this block was removed from Half-Life and there no difference
// between wait = 0 and wait = -1. But in Xash this bug was fixed
// and level-designer errors is now actual. I'm set m_flWait to -1 for compatibility
if( m_flWait == 0.0f )
m_flWait = -1;
if( pev->speed == 0 )
pev->speed = 100;
if( pev->movedir == g_vecZero )
pev->movedir = Vector( 1.0f, 0.0f, 0.0f );
m_vecPosition1 = GetLocalOrigin();
// Subtract 2 from size because the engine expands bboxes by 1 in all directions making the size too big
Vector vecSize = pev->size - Vector( 2, 2, 2 );
m_vecPosition2 = m_vecPosition1 + (pev->movedir * (DotProductAbs( pev->movedir, vecSize ) - m_flLip));
ASSERTSZ( m_vecPosition1 != m_vecPosition2, "door start/end positions are equal" );
if( FBitSet( pev->spawnflags, SF_DOOR_START_OPEN ))
{
UTIL_SetOrigin( this, m_vecPosition2 );
m_vecPosition2 = m_vecPosition1;
m_vecPosition1 = GetLocalOrigin();
}
else
{
UTIL_SetOrigin( this, m_vecPosition1 );
}
// another hack: PhysX 2.8.4.0 crashed while trying to created kinematic body from this brush-model
if ( FStrEq( STRING( gpGlobals->mapname ), "c2a5e" ) && FStrEq( STRING( pev->model ), "*103" ));
else m_pUserData = WorldPhysic->CreateKinematicBodyFromEntity( this );
m_iState = STATE_OFF;
// if the door is flagged for USE button activation only, use NULL touch function
if( FBitSet( pev->spawnflags, SF_DOOR_USE_ONLY ))
{
SetTouch( NULL );
}
else
{
// touchable button
SetTouch( DoorTouch );
}
}
开发者ID:XashDev,项目名称:XashXT,代码行数:84,代码来源:doors.cpp
示例14: GetMoveProbe
//-----------------------------------------------------------------------------
// Step iteratively toward a destination position
//-----------------------------------------------------------------------------
AIMotorMoveResult_t CAI_Motor::MoveGroundStep( const Vector &newPos, CBaseEntity *pMoveTarget, float yaw, bool bAsFarAsCan, bool bTestZ, AIMoveTrace_t *pTraceResult )
{
// By definition, this will produce different results than GroundMoveLimit()
// because there's no guarantee that it will step exactly one step
// See how far toward the new position we can step...
// But don't actually test for ground geometric validity;
// if it isn't valid, there's not much we can do about it
AIMoveTrace_t moveTrace;
unsigned testFlags = AITGM_IGNORE_FLOOR;
char *pchHackBoolToInt = (char*)(&bTestZ);
if ( *pchHackBoolToInt == 2 )
{
testFlags |= AITGM_CRAWL_LARGE_STEPS;
}
else
{
if ( !bTestZ )
testFlags |= AITGM_2D;
}
#ifdef DEBUG
if ( ai_draw_motor_movement.GetBool() )
testFlags |= AITGM_DRAW_RESULTS;
#endif
GetMoveProbe()->TestGroundMove( GetLocalOrigin(), newPos, GetOuter()->GetAITraceMask(), testFlags, &moveTrace );
if ( pTraceResult )
{
*pTraceResult = moveTrace;
}
bool bHitTarget = (moveTrace.pObstruction && (pMoveTarget == moveTrace.pObstruction ));
// Move forward either if there was no obstruction or if we're told to
// move as far as we can, regardless
bool bIsBlocked = IsMoveBlocked(moveTrace.fStatus);
if ( !bIsBlocked || bAsFarAsCan || bHitTarget )
{
#ifdef DEBUG
if ( GetMoveProbe()->CheckStandPosition( GetLocalOrigin(), GetOuter()->GetAITraceMask() ) && !GetMoveProbe()->CheckStandPosition( moveTrace.vEndPosition, GetOuter()->GetAITraceMask() ) )
{
DevMsg( 2, "Warning: AI motor probably given invalid instructions\n" );
}
#endif
// The true argument here causes it to touch all triggers
// in the volume swept from the previous position to the current position
UTIL_SetOrigin(GetOuter(), moveTrace.vEndPosition, true);
// check to see if our ground entity has changed
// NOTE: This is to detect changes in ground entity as the movement code has optimized out
// ground checks. So now we have to do a simple recheck to make sure we detect when we've
// stepped onto a new entity.
if ( GetOuter()->GetFlags() & FL_ONGROUND )
{
GetOuter()->PhysicsStepRecheckGround();
}
// skip tiny steps, but notify the shadow object of any large steps
if ( moveTrace.flStepUpDistance > 0.1f )
{
float height = clamp( moveTrace.flStepUpDistance, 0, StepHeight() );
IPhysicsObject *pPhysicsObject = GetOuter()->VPhysicsGetObject();
if ( pPhysicsObject )
{
IPhysicsShadowController *pShadow = pPhysicsObject->GetShadowController();
if ( pShadow )
{
pShadow->StepUp( height );
}
}
}
if ( yaw != -1 )
{
QAngle angles = GetLocalAngles();
angles.y = yaw;
SetLocalAngles( angles );
}
if ( bHitTarget )
return AIM_PARTIAL_HIT_TARGET;
if ( !bIsBlocked )
return AIM_SUCCESS;
if ( moveTrace.fStatus == AIMR_BLOCKED_NPC )
return AIM_PARTIAL_HIT_NPC;
return AIM_PARTIAL_HIT_WORLD;
}
return AIM_FAILED;
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:96,代码来源:ai_motor.cpp
示例15: SetNextThink
void CAPCController::TrackTarget( void )
{
trace_t tr;
bool updateTime = FALSE, lineOfSight;
QAngle angles;
Vector barrelEnd;
CBaseEntity *pTarget = NULL;
barrelEnd.Init();
if ( IsActive() )
{
SetNextThink( gpGlobals->curtime + 0.1f );
}
else
{
return;
}
// -----------------------------------
// Get world target position
// -----------------------------------
barrelEnd = WorldBarrelPosition();
Vector worldTargetPosition;
CBaseEntity *pEntity = (CBaseEntity *)m_hTarget;
if ( !pEntity || ( pEntity->GetFlags() & FL_NOTARGET ) )
{
m_hTarget = FindTarget( m_targetEntityName, NULL );
if ( IsActive() )
{
SetNextThink( gpGlobals->curtime + 2 ); // Wait 2 sec s
}
return;
}
pTarget = pEntity;
// Calculate angle needed to aim at target
worldTargetPosition = pEntity->EyePosition();
float range = (worldTargetPosition - barrelEnd).Length();
if ( !InRange( range ) )
{
m_bFireDelayed = false;
return;
}
UTIL_TraceLine( barrelEnd, worldTargetPosition, MASK_BLOCKLOS, this, COLLISION_GROUP_NONE, &tr );
lineOfSight = FALSE;
// No line of sight, don't track
if ( tr.fraction == 1.0 || tr.m_pEnt == pTarget )
{
lineOfSight = TRUE;
CBaseEntity *pInstance = pTarget;
if ( InRange( range ) && pInstance && pInstance->IsAlive() )
{
updateTime = TRUE;
// Sight position is BodyTarget with no noise (so gun doesn't bob up and down)
m_sightOrigin = pInstance->BodyTarget( GetLocalOrigin(), false );
}
}
// Convert targetPosition to parent
angles = AimBarrelAt( m_parentMatrix.WorldToLocal( m_sightOrigin ) );
// Force the angles to be relative to the center position
float offsetY = UTIL_AngleDistance( angles.y, m_yawCenter );
float offsetX = UTIL_AngleDistance( angles.x, m_pitchCenter );
angles.y = m_yawCenter + offsetY;
angles.x = m_pitchCenter + offsetX;
// Move toward target at rate or less
float distY = UTIL_AngleDistance( angles.y, GetLocalAngles().y );
QAngle vecAngVel = GetLocalAngularVelocity();
vecAngVel.y = distY * 10;
vecAngVel.y = clamp( vecAngVel.y, -m_yawRate, m_yawRate );
// Move toward target at rate or less
float distX = UTIL_AngleDistance( angles.x, GetLocalAngles().x );
vecAngVel.x = distX * 10;
vecAngVel.x = clamp( vecAngVel.x, -m_pitchRate, m_pitchRate );
SetLocalAngularVelocity( vecAngVel );
SetMoveDoneTime( 0.1 );
Vector forward;
AngleVectors( GetLocalAngles(), &forward );
forward = m_parentMatrix.ApplyRotation( forward );
AngleVectors(angles, &forward);
if ( lineOfSight == TRUE )
{
// FIXME: This will ultimately have to deal with NPCs being in the vehicle as well
//.........这里部分代码省略.........
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:101,代码来源:point_apc_controller.cpp
示例16: switch
//.........这里部分代码省略.........
}
if ( GetHintNode() )
{
TaskComplete();
}
else
{
TaskFail( FAIL_NO_HINT_NODE );
}
break;
}
case TASK_GET_PATH_TO_HINTNODE:
{
//How did this happen?!
if ( GetGoalEnt() == this )
{
SetGoalEnt( NULL );
}
if ( GetGoalEnt() )
{
SetFlyingState( FlyState_Flying );
StartTargetHandling( GetGoalEnt() );
m_bReachedMoveGoal = false;
TaskComplete();
SetHintNode( NULL );
return;
}
if ( GetHintNode() )
{
Vector vHintPos;
GetHintNode()->GetPosition(this, &vHintPos);
SetNavType( NAV_FLY );
CapabilitiesAdd( bits_CAP_MOVE_FLY );
if ( !GetNavigator()->SetGoal( vHintPos ) )
SetHintNode(NULL);
CapabilitiesRemove( bits_CAP_MOVE_FLY );
}
if ( GetHintNode() )
{
m_bReachedMoveGoal = false;
TaskComplete();
}
else
{
TaskFail( FAIL_NO_ROUTE );
}
break;
}
//
// We have failed to fly normally. Pick a random "up" direction and fly that way.
//
case TASK_CROW_FLY:
{
float flYaw = UTIL_AngleMod( random->RandomInt( -180, 180 ) );
Vector vecNewVelocity( cos( DEG2RAD( flYaw ) ), sin( DEG2RAD( flYaw ) ), random->RandomFloat( 0.1f, 0.5f ) );
vecNewVelocity *= CROW_AIRSPEED;
SetAbsVelocity( vecNewVelocity );
SetIdealActivity( ACT_FLY );
m_bSoar = false;
m_flSoarTime = gpGlobals->curtime + random->RandomFloat( 2, 5 );
break;
}
case TASK_CROW_PICK_RANDOM_GOAL:
{
m_vSavePosition = GetLocalOrigin() + Vector( random->RandomFloat( -48.0f, 48.0f ), random->RandomFloat( -48.0f, 48.0f ), 0 );
TaskComplete();
break;
}
case TASK_CROW_HOP:
{
SetIdealActivity( ACT_HOP );
m_flHopStartZ = GetLocalOrigin().z;
break;
}
case TASK_CROW_WAIT_FOR_BARNACLE_KILL:
{
break;
}
default:
{
BaseClass::StartTask( pTask );
}
}
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:101,代码来源:npc_crow.cpp
示例17: Takeoff
//-----------------------------------------------------------------------------
// Purpose: Catches the monster-specific messages that occur when tagged
// animation frames are played.
// Input : pEvent -
//-----------------------------------------------------------------------------
void CNPC_Crow::HandleAnimEvent( animevent_t *pEvent )
{
if ( pEvent->event == AE_CROW_TAKEOFF )
{
if ( GetNavigator()->GetPath()->GetCurWaypoint() )
{
Takeoff( GetNavigator()->GetCurWaypointPos() );
}
return;
}
if( pEvent->event == AE_CROW_HOP )
{
SetGroundEntity( NULL );
//
// Take him off ground so engine doesn't instantly reset FL_ONGROUND.
//
UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0 , 0 , 1 ));
//
// How fast does the crow need to travel to reach the hop goal given gravity?
//
float flHopDistance = ( m_vSavePosition - GetLocalOrigin() ).Length();
float gravity = sv_gravity.GetFloat();
if ( gravity <= 1 )
{
gravity = 1;
}
float height = 0.25 * flHopDistance;
float speed = sqrt( 2 * gravity * height );
float time = speed / gravity;
//
// Scale the sideways velocity to get there at the right time
//
Vector vecJumpDir = m_vSavePosition - GetLocalOrigin();
vecJumpDir = vecJumpDir / time;
//
// Speed to offset gravity at the desired height.
//
vecJumpDir.z = speed;
//
// Don't jump too far/fast.
//
float distance = vecJumpDir.Length();
if ( distance > 650 )
{
vecJumpDir = vecJumpDir * ( 650.0 / distance );
}
m_nMorale -= random->RandomInt( 1, 6 );
if ( m_nMorale <= 0 )
{
m_nMorale = 0;
}
// Play a hop flap sound.
EmitSound( "NPC_Crow.Hop" );
SetAbsVelocity( vecJumpDir );
return;
}
if( pEvent->event == AE_CROW_FLY )
{
//
// Start flying.
//
SetActivity( ACT_FLY );
m_bSoar = false;
m_flSoarTime = gpGlobals->curtime + random->RandomFloat( 3, 5 );
return;
}
CAI_BaseNPC::HandleAnimEvent( pEvent );
}
开发者ID:Bubbasacs,项目名称:FinalProj,代码行数:87,代码来源:npc_crow.cpp
示例18: SetOwnerEntity
//-----------------------------------------------------------------------------
// Purpose: Stick to an entity (using hierarchy if we can)
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CWeaponStriderBuster::StickToEntity( CBaseEntity *pOther )
{
// Make sure the object is travelling fast enough to stick
if ( m_flCollisionSpeedSqr > 50 && !m_bNoseDiving )
{
// See if this is a valid strider bit
if ( ShouldStickToEntity( pOther ) )
{
// Attempt to constraint to it
if ( CreateConstraintToObject( pOther ) )
{
// Only works for striders, at the moment
CBaseEntity *pFollowParent = pOther->GetOwnerEntity();
if ( pFollowParent == NULL )
return false;
// Allows us to identify our constrained object later
SetOwnerEntity( pFollowParent );
// Make a sound
EmitSound( "Weapon_StriderBuster.StickToEntity" );
DispatchParticleEffect( "striderbuster_attach", GetAbsOrigin(), GetAbsAngles(), NULL );
if( striderbuster_use_particle_flare.GetBool() )
{
// We don't have to save any pointers or handles to this because it's parented to the buster.
// So it will die when the buster dies. Yay.
CParticleSystem *pFlare = (CParticleSystem *) CreateEntityByName( "info_particle_system" );
if ( pFlare != NULL )
{
pFlare->KeyValue( "start_active", "1" );
pFlare->KeyValue( "effect_name", "striderbuster_attached_pulse" );
pFlare->SetParent( this );
pFlare->SetLocalOrigin( vec3_origin );
DispatchSpawn( pFlare );
pFlare->Activate();
}
}
else
{
// Create a glow sprite
m_hGlowSprite = CSprite::SpriteCreate( "sprites/orangeflare1.vmt", GetLocalOrigin(), false );
Assert( m_hGlowSprite );
if ( m_hGlowSprite != NULL )
{
m_hGlowSprite->TurnOn();
m_hGlowSprite->SetTransparency( kRenderWorldGlow, 255, 255, 255, 255, kRenderFxNoDissipation );
m_hGlowSprite->SetAbsOrigin( GetAbsOrigin() );
m_hGlowSprite->SetScale( 5.0f );
m_hGlowSprite->m_nRenderFX = kRenderFxStrobeFaster;
m_hGlowSprite->SetGlowProxySize( 16.0f );
m_hGlowSprite->SetParent( this );
}
}
// Stop touching things
SetTouch( NULL );
// Must be a strider
CNPC_Strider *pStrider = dynamic_cast<CNPC_Strider *>(pFollowParent);
if ( pStrider == NULL )
return false;
// Notify the strider we're attaching to him
pStrider->StriderBusterAttached( this );
m_OnAttachToStrider.FireOutput( this, this );
// Start the ping sound.
SetContextThink( &CWeaponStriderBuster::BusterPingThink, gpGlobals->curtime + BUSTER_PING_SOUND_FREQ, s_pBusterPingThinkContext );
// Don't autodelete this one!
WeaponManager_RemoveManaged( this );
return true;
}
return false;
}
}
return false;
}
开发者ID:FooGames,项目名称:SecobMod,代码行数:90,代码来源:weapon_striderbuster.cpp
示例19: switch
//=========================================================
// HandleAnimEvent - catches the monster-specific messages
// that occur when tagged animation frames are played.
//=========================================================
void CNPC_Houndeye::HandleAnimEvent( animevent_t *pEvent )
{
switch ( pEvent->event )
{
case HOUND_AE_WARN:
// do stuff for this event.
WarnSound();
break;
case HOUND_AE_STARTATTACK:
WarmUpSound();
break;
case HOUND_AE_HOPBACK:
{
float flGravity = sv_gravity.GetFloat();
SetGroundEntity( NULL );
Vector forward;
AngleVectors( GetLocalAngles(), &forward );
Vector vecNewVelocity = forward * -200;
//jump up 36 inches
vecNewVelocity.z += sqrt( 2 * flGravity * 36 );
SetAbsVelocity( vecNewVelocity );
break;
}
case HOUND_AE_THUMP:
// emit the shockwaves
SonicAttack();
m_flNextAttack = gpGlobals->curtime + random->RandomFloat( 5.0, 8.0 );
break;
case HOUND_AE_ANGERSOUND1:
{
EmitSound( "NPC_Houndeye.Anger1" );
}
break;
case HOUND_AE_ANGERSOUND2:
{
EmitSound( "NPC_Houndeye.Anger2" );
}
break;
case HOUND_AE_CLOSE_EYE:
if ( !m_fDontBlink )
{
//<<TEMP>> pev->skin = HOUNDEYE_EYE_FRAMES - 1;
}
break;
case HOUND_AE_LEAP_HIT:
{
//<<TEMP>>return;//<<TEMP>>
SetGroundEntity( NULL );
//
// Take him off ground so engine doesn't instantly reset FL_ONGROUND.
//
UTIL_SetOrigin( this, GetLocalOrigin() + Vector( 0 , 0 , 1 ));
Vector vecJumpDir;
if ( GetEnemy() != NULL )
{
Vector vecEnemyEyePos = GetEnemy()->EyePosition();
float gravity = sv_gravity.GetFloat();
if ( gravity <= 1 )
{
gravity = 1;
}
//
// How fast does the houndeye need to travel to reach my enemy's eyes given gravity?
//
float height = ( vecEnemyEyePos.z - GetAbsOrigin().z );
if ( height < 16 )
{
height = 16;
}
else if ( height > 120 )
{
height = 120;
}
float speed = sqrt( 2 * gravity * height );
float time = speed / gravity;
//
// Scale the sideways velocity to get there at the right time
//
vecJumpDir = vecEnemyEyePos - GetAbsOrigin();
vecJumpDir = vecJumpDir / time;
//
// Speed to offset gravity at the desired height.
//.........这里部分代码省略.........
开发者ID:AluminumKen,项目名称:hl2sb-src,代码行数:101,代码来源:npc_houndeye.cpp
示例20: switch
void CAI_LeadBehavior::RunTask( const Task_t *pTask )
{
switch ( pTask->iTask )
{
case TASK_LEAD_SUCCEED:
{
if ( !IsSpeaking() )
{
TaskComplete();
NotifyEvent( LBE_DONE );
}
break;
}
case TASK_LEAD_ARRIVE:
{
if ( !IsSpeaking() )
{
TaskComplete();
NotifyEvent( LBE_ARRIVAL_DONE );
}
break;
}
case TASK_LEAD_MOVE_TO_RANGE:
{
// If we haven't spoken our start speech, move closer
if ( !m_hasspokenstart)
{
ChainRunTask( TASK_MOVE_TO_GOAL_RANGE, m_leaddistance - 24 );
}
else
{
ChainRunTask( TASK_MOVE_TO_GOAL_RANGE, m_retrievedistance );
if ( !TaskIsComplete() )
{
// Transition to a walk when we get near the player
// Check Z first, and only check 2d if we're within that
Vector vecGoalPos = GetNavigator()->GetGoalPos();
float distance = fabs(vecGoalPos.z - GetLocalOrigin().z);
bool bWithinZ = false;
if ( distance < m_retrievedistance )
{
distance = ( vecGoalPos - GetLocalOrigin() ).Length2D();
bWithinZ = true;
}
if ( distance > m_retrievedistance )
{
Activity followActivity = ACT_WALK;
if ( GetOuter()->GetState() == NPC_STATE_COMBAT || ( (!bWithinZ || distance < (m_retrievedistance*4)) && GetOuter()->GetState() != NPC_STATE_COMBAT ) )
{
followActivity = ACT_RUN;
}
// Don't confuse move and shoot by resetting the activity every think
Activity curActivity = GetNavigator()->GetMovementActivity();
switch( curActivity )
{
case ACT_WALK_AIM: curActivity = ACT_WALK; break;
case ACT_RUN_AIM: curActivity = ACT_RUN; break;
}
if ( curActivity != followActivity )
{
GetNavigator()->SetMovementActivity(followActivity);
}
GetNavigator()->SetArrivalDirection( GetOuter()->GetTarget() );
}
}
}
break;
}
case TASK_LEAD_RETRIEVE_WAIT:
{
ChainRunTask( TASK_WAIT_INDEFINITE );
break;
}
case TASK_LEAD_WALK_PATH:
{
// If we're leading, and we're supposed to run, run instead of walking
if ( m_run &&
( IsCurSchedule( SCHED_LEAD_WAITFORPLAYER, false ) || IsCurSchedule( SCHED_LEAD_PLAYER, false ) || IsCurSchedule( SCHED_LEAD_SPEAK_THEN_LEAD_PLAYER, false )|| IsCurSchedule( SCHED_LEAD_RETRIEVE, false ) ) )
{
ChainRunTask( TASK_RUN_PATH );
}
else
{
ChainRunTask( TASK_WALK_PATH );
}
// While we're walking
if ( TaskIsRunning() && IsCurSchedule( SCHED_LEAD_PLAYER, false ) )
{
// If we're not speaking, and we haven't tried for a while, try to speak lead idle
if ( m_flNextLeadIdle < gpGlobals->curtime && !IsSpeaking() )
{
m_flNextLeadIdle = gpGlobals->curtime + RandomFloat( 10,15 );
//.........这里部分代码省略.........
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:101,代码来源:ai_behavior_lead.cpp
注:本文中的GetLocalOrigin函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论