//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponStriderBuster::Spawn( void ) { SetModelName( AllocPooledString("models/magnusson_device.mdl") ); BaseClass::Spawn(); // Setup for being shot by the player m_takedamage = DAMAGE_EVENTS_ONLY; // Ignore touches until launched. SetTouch ( NULL ); AddFlag( FL_AIMTARGET|FL_OBJECT ); m_hParticleEffect = CreateEntityByName( "info_particle_system" ); if ( m_hParticleEffect ) { m_hParticleEffect->KeyValue( "start_active", "1" ); m_hParticleEffect->KeyValue( "effect_name", "striderbuster_smoke" ); DispatchSpawn( m_hParticleEffect ); if ( gpGlobals->curtime > 0.2f ) { m_hParticleEffect->Activate(); } m_hParticleEffect->SetAbsOrigin( GetAbsOrigin() ); m_hParticleEffect->SetParent( this ); } SetHealth( striderbuster_health.GetFloat() ); SetNextThink(gpGlobals->curtime + 0.01f); }
//----------------------------------------------------------------------------- // Purpose: Returns the magnitude of the entity's angular velocity. //----------------------------------------------------------------------------- void CPointVelocitySensor::SampleVelocity( void ) { if ( m_hTargetEntity == NULL ) return; Vector vecVelocity; if ( m_hTargetEntity->GetMoveType() == MOVETYPE_VPHYSICS ) { IPhysicsObject *pPhys = m_hTargetEntity->VPhysicsGetObject(); if ( pPhys != NULL ) { pPhys->GetVelocity( &vecVelocity, NULL ); } } else { vecVelocity = m_hTargetEntity->GetAbsVelocity(); } /* float flSpeed = VectorNormalize( vecVelocity ); float flDot = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f; */ // We want the component of the velocity vector in the direction of the axis, which since the // axis is normalized is simply their dot product (eg V . A = |V|*|A|*cos(theta) ) m_fPrevVelocity = ( m_vecAxis != vec3_origin ) ? DotProduct( vecVelocity, m_vecAxis ) : 1.0f; // if it's changed since the last frame, poke the output if ( m_fPrevVelocity != m_Velocity.Get() ) { m_Velocity.Set( m_fPrevVelocity, NULL, NULL ); } }
void CNPC_Dog::PrescheduleThink( void ) { BaseClass::PrescheduleThink(); if ( m_hPhysicsEnt ) { IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject(); if ( pPhysObj && pPhysObj->GetGameFlags() & FVPHYSICS_PLAYER_HELD ) { m_hPhysicsEnt->SetOwnerEntity( NULL ); } } if ( m_flTimeToCatch < gpGlobals->curtime ) m_flTimeToCatch = 0.0f; if ( GetIdealActivity() == ACT_IDLE ) { if ( m_hPhysicsEnt && m_bHasObject == true ) { SetIdealActivity( (Activity)ACT_DOG_WAITING ); } } }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CPointCommentaryNode::FinishCommentary( bool bBlendOut ) { CBasePlayer *pPlayer = GetCommentaryPlayer(); if ( !pPlayer ) return; // Fire off our postcommands if ( m_iszPostCommands != NULL_STRING ) { g_CommentarySystem.SetCommentaryConvarsChanging( true ); engine->ClientCommand( pPlayer->edict(), STRING(m_iszPostCommands) ); engine->ClientCommand( pPlayer->edict(), "commentary_cvarsnotchanging\n" ); } // Stop the commentary m_flFinishedTime = gpGlobals->curtime; if ( bBlendOut && m_hViewPositionMover ) { m_bActive = false; m_flPlaybackRate = 1.0; m_vecFinishOrigin = m_hViewPositionMover->GetAbsOrigin(); m_vecFinishAngles = m_hViewPositionMover->GetAbsAngles(); m_bPreventChangesWhileMoving = true; // We've moved away from the player's position. Move back to it before ending SetContextThink( &CPointCommentaryNode::UpdateViewPostThink, gpGlobals->curtime, s_pCommentaryUpdateViewThink ); return; } CleanupPostCommentary(); }
//----------------------------------------------------------------------------- // Purpose: Does the linked list work of removing a child object from the hierarchy. // Input : pParent - // pChild - //----------------------------------------------------------------------------- void UnlinkChild( CBaseEntity *pParent, CBaseEntity *pChild ) { CBaseEntity *pList; EHANDLE *pPrev; pList = pParent->m_hMoveChild; pPrev = &pParent->m_hMoveChild; while ( pList ) { CBaseEntity *pNext = pList->m_hMovePeer; if ( pList == pChild ) { // patch up the list pPrev->Set( pNext ); // Clear hierarchy bits for this guy pList->m_hMoveParent.Set( NULL ); pList->m_hMovePeer.Set( NULL ); pList->DispatchUpdateTransmitState(); pList->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL ); pParent->RecalcHasPlayerChildBit(); return; } else { pPrev = &pList->m_hMovePeer; pList = pNext; } } // This only happens if the child wasn't found in the parent's child list Assert(0); }
//----------------------------------------------------------------------------- // Purpose: Returns whether or not the template entities can fit if spawned. // Input : pBlocker - Returns blocker unless NULL. //----------------------------------------------------------------------------- bool CEnvEntityMaker::HasRoomToSpawn() { // Do we have a blocker from last time? if ( m_hCurrentBlocker ) { // If it hasn't moved, abort immediately if ( m_vecBlockerOrigin == m_hCurrentBlocker->GetAbsOrigin() ) { return false; } } // Check to see if there's enough room to spawn trace_t tr; UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin(), m_vecEntityMins, m_vecEntityMaxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.m_pEnt || tr.startsolid ) { // Store off our blocker to check later m_hCurrentBlocker = tr.m_pEnt; if ( m_hCurrentBlocker ) { m_vecBlockerOrigin = m_hCurrentBlocker->GetAbsOrigin(); } return false; } return true; }
void CNPC_GMan::RunTask( const Task_t *pTask ) { switch( pTask->iTask ) { case TASK_WAIT: // look at who I'm talking to if (m_flTalkTime > gpGlobals->curtime && m_hTalkTarget != NULL) { AddLookTarget( m_hTalkTarget->GetAbsOrigin(), 1.0, 2.0 ); } // look at player, but only if playing a "safe" idle animation else if (m_hPlayer != NULL && (GetSequence() == 0 || IsInC5A1()) ) { AddLookTarget( m_hPlayer->EyePosition(), 1.0, 3.0 ); } else { // Just center the head forward. Vector forward; GetVectors( &forward, NULL, NULL ); AddLookTarget( GetAbsOrigin() + forward * 12.0f, 1.0, 1.0 ); SetBoneController( 0, 0 ); } BaseClass::RunTask( pTask ); break; } SetBoneController( 0, 0 ); BaseClass::RunTask( pTask ); }
CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEntIndex, int channel, const char *pSoundName, soundlevel_t soundlevel ) { CSoundPatch *pSound = new CSoundPatch; EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; pSound->Init( &filter, hEnt.Get(), channel, pSoundName, soundlevel ); return pSound; }
//----------------------------------------------------------------------------- // Purpose: Check to see if we should spawn another instance //----------------------------------------------------------------------------- void CEnvEntityMaker::CheckSpawnThink( void ) { SetNextThink( gpGlobals->curtime + 0.5f ); // Do we have an instance? if ( m_hCurrentInstance ) { // If Wait-For-Destruction is set, abort immediately if ( m_spawnflags & SF_ENTMAKER_WAITFORDESTRUCTION ) return; } // Do we have a blocker? if ( m_hCurrentBlocker ) { // If it hasn't moved, abort immediately if ( m_vecBlockerOrigin == m_hCurrentBlocker->GetAbsOrigin() ) return; } // Check to see if there's enough room to spawn trace_t tr; UTIL_TraceHull( GetAbsOrigin(), GetAbsOrigin(), m_vecEntityMins, m_vecEntityMaxs, MASK_SOLID, this, COLLISION_GROUP_NONE, &tr ); if ( tr.m_pEnt || tr.startsolid ) { // Store off our blocker to check later m_hCurrentBlocker = tr.m_pEnt; if ( m_hCurrentBlocker ) { m_vecBlockerOrigin = m_hCurrentBlocker->GetAbsOrigin(); } return; } // We're clear, now check to see if the player's looking if ( !(m_spawnflags & SF_ENTMAKER_IGNOREFACING) ) { for ( int i = 1; i <= gpGlobals->maxClients; i++ ) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(i); if ( pPlayer ) { // Only spawn if the player's looking away from me Vector vLookDir = pPlayer->EyeDirection3D(); Vector vTargetDir = GetAbsOrigin() - pPlayer->EyePosition(); VectorNormalize(vTargetDir); float fDotPr = DotProduct(vLookDir,vTargetDir); if ( fDotPr > 0 ) return; } } } // Clear, no player watching, so spawn! SpawnEntity(); }
CSoundPatch *CSoundControllerImp::SoundCreate( IRecipientFilter& filter, int nEntIndex, const char *pSoundName ) { CSoundPatch *pSound = new CSoundPatch; // FIXME: This is done so we don't have to futz with the public interface EHANDLE hEnt = (nEntIndex != -1) ? g_pEntityList->GetNetworkableHandle( nEntIndex ) : NULL; pSound->Init( &filter, hEnt.Get(), CHAN_AUTO, pSoundName, SNDLVL_NORM ); return pSound; }
void CPhysicsEntitySolver::Spawn() { SetNextThink( gpGlobals->curtime + m_separationDuration ); PhysDisableEntityCollisions( m_hMovingEntity, m_hPhysicsBlocker ); m_savedCollisionGroup = m_hPhysicsBlocker->GetCollisionGroup(); m_hPhysicsBlocker->SetCollisionGroup( COLLISION_GROUP_DEBRIS ); if ( m_hPhysicsBlocker->VPhysicsGetObject() ) { m_hPhysicsBlocker->VPhysicsGetObject()->RecheckContactPoints(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_ScriptIntro::ClientThink( void ) { Assert( m_IntroData.m_Passes.Count() <= 2 ); if ( m_hCameraEntity ) { m_IntroData.m_vecCameraView = m_hCameraEntity->GetAbsOrigin(); m_IntroData.m_vecCameraViewAngles = m_hCameraEntity->GetAbsAngles(); } CalculateFOV(); CalculateAlpha(); // Calculate the blend levels of each pass float flPerc = 1.0; if ( (m_flNextBlendTime - m_flBlendStartTime) != 0 ) { flPerc = clamp( (gpGlobals->curtime - m_flBlendStartTime) / (m_flNextBlendTime - m_flBlendStartTime), 0, 1 ); } // Detect when we're finished blending if ( flPerc >= 1.0 ) { if ( m_IntroData.m_Passes.Count() == 2 ) { // We're done blending m_IntroData.m_Passes[0].m_BlendMode = m_IntroData.m_Passes[1].m_BlendMode; m_IntroData.m_Passes[0].m_Alpha = 1.0; m_IntroData.m_Passes.Remove(1); //Msg("FINISHED BLEND.\n"); } return; } /* if ( m_flNextBlendTime >= gpGlobals->curtime ) { Msg("INTRO BLENDING: Blending from mode %d to %d.\n", m_IntroData.m_Passes[0].m_BlendMode, m_IntroData.m_Passes[1].m_BlendMode ); Msg(" curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, m_flBlendStartTime, m_flNextBlendTime ); Msg(" Perc: %.2f\n", flPerc ); } */ if ( m_IntroData.m_Passes.Count() == 2 ) { m_IntroData.m_Passes[0].m_Alpha = 1.0 - flPerc; m_IntroData.m_Passes[1].m_Alpha = flPerc; } else { m_IntroData.m_Passes[0].m_Alpha = 1.0 - flPerc; } }
void LinkChild( CBaseEntity *pParent, CBaseEntity *pChild ) { EHANDLE hParent; hParent.Set( pParent ); pChild->m_hMovePeer.Set( pParent->FirstMoveChild() ); pParent->m_hMoveChild.Set( pChild ); pChild->m_hMoveParent = hParent; pChild->NetworkProp()->SetNetworkParent( hParent ); pChild->DispatchUpdateTransmitState(); pChild->OnEntityEvent( ENTITY_EVENT_PARENT_CHANGED, NULL ); pParent->RecalcHasPlayerChildBit(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPointCommentaryNode::UpdateViewPostThink( void ) { CBasePlayer *pPlayer = GetCommentaryPlayer(); if ( !pPlayer ) return; if ( m_hViewPosition.Get() && m_hViewPositionMover ) { // Blend back to the player's position over time. float flCurTime = (gpGlobals->curtime - m_flFinishedTime); float flTimeToBlend = min( 2.0, m_flFinishedTime - m_flStartTime ); float flBlendPerc = 1.0 - clamp( flCurTime / flTimeToBlend, 0, 1 ); //Msg("OUT: CurTime %.2f, BlendTime: %.2f, Blend: %.3f\n", flCurTime, flTimeToBlend, flBlendPerc ); // Only do this while we're still moving if ( flBlendPerc > 0 ) { // Figure out the current view position Vector vecPlayerPos = pPlayer->EyePosition(); Vector vecToPosition = (m_vecFinishOrigin - vecPlayerPos); Vector vecCurEye = pPlayer->EyePosition() + (vecToPosition * flBlendPerc); m_hViewPositionMover->SetAbsOrigin( vecCurEye ); if ( m_hViewTarget ) { Quaternion quatFinish; Quaternion quatOriginal; Quaternion quatCurrent; AngleQuaternion( m_vecOriginalAngles, quatOriginal ); AngleQuaternion( m_vecFinishAngles, quatFinish ); QuaternionSlerp( quatFinish, quatOriginal, 1.0 - flBlendPerc, quatCurrent ); QAngle angCurrent; QuaternionAngles( quatCurrent, angCurrent ); m_hViewPositionMover->SetAbsAngles( angCurrent ); } SetNextThink( gpGlobals->curtime, s_pCommentaryUpdateViewThink ); return; } pPlayer->SnapEyeAngles( m_hViewPositionMover->GetAbsAngles() ); } // We're done CleanupPostCommentary(); m_bPreventChangesWhileMoving = false; }
void CNPC_Dog::CleanCatchAndThrow( bool bClearTimers ) { if ( m_hPhysicsEnt ) { if ( m_bHasObject == true ) { IPhysicsObject *pPhysObj = m_hPhysicsEnt->VPhysicsGetObject(); m_hPhysicsEnt->SetParent( NULL ); m_hPhysicsEnt->SetOwnerEntity( NULL ); Vector vGunPos; QAngle angGunAngles; GetAttachment( m_iPhysGunAttachment, vGunPos, angGunAngles ); if ( pPhysObj ) { pPhysObj->Wake(); pPhysObj->RemoveShadowController(); pPhysObj->SetPosition( vGunPos, angGunAngles, true ); } else { Warning( "CleanCatchAndThrow: m_hPhysicsEnt->VPhysicsGetObject == NULL!\n" ); } m_hPhysicsEnt->SetMoveType( (MoveType_t)m_iContainerMoveType ); if ( pPhysObj ) { pPhysObj->RecheckCollisionFilter(); } ClearBeams(); } m_hPhysicsEnt = NULL; } if ( bClearTimers == true ) { m_bDoCatchThrowBehavior = false; m_bDoWaitforObjectBehavior = false; m_flTimeToCatch = 0.0f; m_flNextSwat = 0.0f; SetCondition( COND_DOG_LOST_PHYSICS_ENTITY ); } }
void CASW_DamageAllocationMgr::Remove( const EHANDLE &handle ) { IndexType_t i = Find( handle ); if ( IsValid(i) ) { // strike all projectiles for this target ProjectilePool_t::IndexLocalType_t j = i->m_nProjectiles; while ( m_ProjectileLists.IsValidIndex(j) ) { ProjectilePool_t::IndexLocalType_t old = j; j = m_ProjectileLists.Next(j); m_ProjectileLists.Remove( old ); } int vectoridx = i - m_Targets.Base(); Assert( &m_Targets[vectoridx] == i ); m_Targets.FastRemove( vectoridx ); } else { AssertMsg1( false, "Tried to remove %s from a damage allocation manager whence it was absent.\n", handle->GetDebugName() ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_NPC_Puppet::ClientThink( void ) { if ( m_hAnimationTarget == NULL ) return; C_BaseAnimating *pTarget = m_hAnimationTarget->GetBaseAnimating(); if ( pTarget == NULL ) return; int nTargetSequence = pTarget->GetSequence(); const char *pSequenceName = pTarget->GetSequenceName( nTargetSequence ); int nSequence = LookupSequence( pSequenceName ); if ( nSequence >= 0 ) { if ( nSequence != GetSequence() ) { SetSequence( nSequence ); UpdateVisibility(); } SetCycle( pTarget->GetCycle() ); SetPlaybackRate( pTarget->GetPlaybackRate() ); } }
//------------------------------------------------------------------------------ // Purpose : Fly towards our pickup target //------------------------------------------------------------------------------ void CNPC_CombineDropship::UpdatePickupNavigation( void ) { Vector vecPickup = m_hPickupTarget->WorldSpaceCenter(); SetDesiredPosition( vecPickup ); //NDebugOverlay::Cross3D( GetDesiredPosition(), -Vector(32,32,32), Vector(32,32,32), 0, 255, 255, true, 0.1f ); }
void CPhysicsEntitySolver::UpdateOnRemove() { //physenv->DestroyMotionController( m_pController ); //m_pController = NULL; CBaseEntity *pEntity = m_hMovingEntity.Get(); CBaseEntity *pPhysics = m_hPhysicsBlocker.Get(); if ( pEntity && pPhysics ) { PhysEnableEntityCollisions( pEntity, pPhysics ); } if ( pPhysics ) { pPhysics->SetCollisionGroup( m_savedCollisionGroup ); } BaseClass::UpdateOnRemove(); }
//----------------------------------------------------------------------------- // Purpose: Draws magic lines... //----------------------------------------------------------------------------- void CPointAngularVelocitySensor::DrawDebugLines( void ) { if ( m_hTargetEntity ) { Vector vForward, vRight, vUp; AngleVectors( m_hTargetEntity->GetAbsAngles(), &vForward, &vRight, &vUp ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vForward * 64, 255, 0, 0, false, 0 ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vRight * 64, 0, 255, 0, false, 0 ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vUp * 64, 0, 0, 255, false, 0 ); } if ( m_bUseHelper == true ) { QAngle Angles; Vector vAxisForward, vAxisRight, vAxisUp; Vector vLine = m_vecAxis - GetAbsOrigin(); VectorNormalize( vLine ); VectorAngles( vLine, Angles ); AngleVectors( Angles, &vAxisForward, &vAxisRight, &vAxisUp ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vAxisForward * 64, 255, 0, 0, false, 0 ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vAxisRight * 64, 0, 255, 0, false, 0 ); NDebugOverlay::Line( GetAbsOrigin(), GetAbsOrigin() + vAxisUp * 64, 0, 0, 255, false, 0 ); } }
//----------------------------------------------------------------------------- // Purpose: Charge up, deal damage along our facing direction. //----------------------------------------------------------------------------- void CNPC_RocketTurret::FiringThink( void ) { //Allow descended classes a chance to do something before the think function if ( PreThink() ) return; SetNextThink( gpGlobals->curtime + ROCKET_TURRET_THINK_RATE ); CRocket_Turret_Projectile* pRocket = dynamic_cast<CRocket_Turret_Projectile*>(m_hCurRocket.Get()); if ( pRocket ) { // If this rocket has been out too long, detonate it and launch a new one if ( (gpGlobals->curtime - m_flTimeLastFired) > ROCKET_PROJECTILE_DEFAULT_LIFE ) { pRocket->ShotDown(); m_flTimeLastFired = gpGlobals->curtime; SetThink( &CNPC_RocketTurret::FollowThink ); } } else { // Set Locked sprite UpdateSkin( ROCKET_SKIN_IDLE ); // Rocket dead, or never created. Revert to follow think m_flTimeLastFired = gpGlobals->curtime; SetThink( &CNPC_RocketTurret::FollowThink ); } }
//----------------------------------------------------------------------------- // Purpose: Pick up a specified object // Input : &inputdata - //----------------------------------------------------------------------------- void CNPC_CombineDropship::InputPickup( inputdata_t &inputdata ) { // Can't pickup if we're already carrying something if ( m_hContainer ) { Warning("npc_combinedropship %s was told to pickup, but is already carrying something.\n", STRING(GetEntityName()) ); return; } string_t iszTargetName = inputdata.value.StringID(); if ( iszTargetName == NULL_STRING ) { Warning("npc_combinedropship %s tried to pickup with no specified pickup target.\n", STRING(GetEntityName()) ); return; } CBaseEntity *pTarget = gEntList.FindEntityByName( NULL, iszTargetName, NULL ); if ( !pTarget ) { Warning("npc_combinedropship %s couldn't find pickup target named %s\n", STRING(GetEntityName()), STRING(iszTargetName) ); return; } // Start heading to the point m_hPickupTarget = pTarget; // Disable collisions to my target m_hPickupTarget->SetOwnerEntity(this); if ( m_NPCState == NPC_STATE_IDLE ) { SetState( NPC_STATE_ALERT ); } m_iLandState = LANDING_SWOOPING; m_flLandingSpeed = GetAbsVelocity().Length(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponBugBait::Drop( const Vector &vecVelocity ) { BaseClass::Drop( vecVelocity ); // On touch, stick & stop moving. Increase our thinktime a bit so we don't stomp the touch for a bit SetNextThink( gpGlobals->curtime + 3.0 ); SetTouch( &CWeaponBugBait::BugbaitStickyTouch ); m_hSporeTrail = SporeExplosion::CreateSporeExplosion(); if ( m_hSporeTrail ) { SporeExplosion *pSporeExplosion = (SporeExplosion *)m_hSporeTrail.Get(); QAngle angles; VectorAngles( Vector(0,0,1), angles ); pSporeExplosion->SetAbsAngles( angles ); pSporeExplosion->SetAbsOrigin( GetAbsOrigin() ); pSporeExplosion->SetParent( this ); pSporeExplosion->m_flSpawnRate = 16.0f; pSporeExplosion->m_flParticleLifetime = 0.5f; pSporeExplosion->SetRenderColor( 0, (int)0.5f, (int)0.25f, (int)0.15f ); pSporeExplosion->m_flStartSize = 32; pSporeExplosion->m_flEndSize = 48; pSporeExplosion->m_flSpawnRadius = 4; pSporeExplosion->SetLifetime( 9999 ); } }
//----------------------------------------------------------------------------- // Purpose: Draw any debug text overlays // Output : Current text offset from the top //----------------------------------------------------------------------------- int CFuncTank::DrawDebugTextOverlays(void) { int text_offset = BaseClass::DrawDebugTextOverlays(); if (m_debugOverlays & OVERLAY_TEXT_BIT) { // -------------- // State // -------------- char tempstr[255]; if (IsActive()) { Q_strncpy(tempstr,"State: Active",sizeof(tempstr)); } else { Q_strncpy(tempstr,"State: Inactive",sizeof(tempstr)); } EntityText(text_offset,tempstr,0); text_offset++; // ------------------- // Print Firing Speed // -------------------- Q_snprintf(tempstr,sizeof(tempstr),"Fire Rate: %f",m_fireRate); EntityText(text_offset,tempstr,0); text_offset++; // -------------- // Print Target // -------------- if (m_hTarget!=NULL) { Q_snprintf(tempstr,sizeof(tempstr),"Target: %s",m_hTarget->GetDebugName()); } else { Q_snprintf(tempstr,sizeof(tempstr),"Target: - "); } EntityText(text_offset,tempstr,0); text_offset++; // -------------- // Target Pos // -------------- if (m_spawnflags & SF_TANK_AIM_AT_POS) { Q_snprintf(tempstr,sizeof(tempstr),"Aim Pos: %3.0f %3.0f %3.0f",m_vTargetPosition.x,m_vTargetPosition.y,m_vTargetPosition.z); } else { Q_snprintf(tempstr,sizeof(tempstr),"Aim Pos: - "); } EntityText(text_offset,tempstr,0); text_offset++; } return text_offset; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_NPC_Puppet::AccumulateLayers( CStudioHdr *hdr, Vector pos[], Quaternion q[], float poseparam[], float currentTime, int boneMask ) { if ( m_hAnimationTarget == NULL ) return; C_BaseAnimatingOverlay *pTarget = dynamic_cast<C_BaseAnimatingOverlay *>( m_hAnimationTarget->GetBaseAnimating() ); if ( pTarget == NULL ) return; // resort the layers int layer[MAX_OVERLAYS]; int i; for (i = 0; i < MAX_OVERLAYS; i++) { layer[i] = MAX_OVERLAYS; } for (i = 0; i < pTarget->m_AnimOverlay.Count(); i++) { if (pTarget->m_AnimOverlay[i].m_nOrder < MAX_OVERLAYS) { layer[pTarget->m_AnimOverlay[i].m_nOrder] = i; } } int j; for (j = 0; j < MAX_OVERLAYS; j++) { i = layer[ j ]; if (i < pTarget->m_AnimOverlay.Count()) { float fWeight = pTarget->m_AnimOverlay[i].m_flWeight; if (fWeight > 0) { const char *pSequenceName = pTarget->GetSequenceName( pTarget->m_AnimOverlay[i].m_nSequence ); int nSequence = LookupSequence( pSequenceName ); if ( nSequence >= 0 ) { float fCycle = pTarget->m_AnimOverlay[ i ].m_flCycle; fCycle = ClampCycle( fCycle, IsSequenceLooping( nSequence ) ); if (fWeight > 1) fWeight = 1; AccumulatePose( hdr, NULL, pos, q, nSequence, fCycle, poseparam, boneMask, fWeight, currentTime ); #if _DEBUG if (Q_stristr( hdr->pszName(), r_sequence_debug.GetString()) != NULL) { DevMsgRT( "%6.2f : %30s : %5.3f : %4.2f : %1d\n", currentTime, hdr->pSeqdesc( nSequence ).pszLabel(), fCycle, fWeight, i ); } #endif } } } } }
void CSqueakGrenade :: Killed( entvars_t *pevAttacker, int iGib ) { pev->model = iStringNull;// make invisible SetThink( SUB_Remove ); SetTouch( NULL ); pev->nextthink = gpGlobals->time + 0.1; // since squeak grenades never leave a body behind, clear out their takedamage now. // Squeaks do a bit of radius damage when they pop, and that radius damage will // continue to call this function unless we acknowledge the Squeak's death now. (sjb) pev->takedamage = DAMAGE_NO; // play squeek blast EMIT_SOUND_DYN(ENT(pev), CHAN_ITEM, "squeek/sqk_blast1.wav", 1, 0.5, 0, PITCH_NORM); CSoundEnt::InsertSound ( bits_SOUND_COMBAT, pev->origin, SMALL_EXPLOSION_VOLUME, 3.0 ); UTIL_BloodDrips( pev->origin, g_vecZero, BloodColor(), 80 ); if (m_hOwner != NULL) RadiusDamage ( pev, m_hOwner->pev, pev->dmg, CLASS_NONE, DMG_BLAST ); else RadiusDamage ( pev, pev, pev->dmg, CLASS_NONE, DMG_BLAST ); // reset owner so death message happens if (m_hOwner != NULL) pev->owner = m_hOwner->edict(); CBaseMonster :: Killed( pevAttacker, GIB_ALWAYS ); }
void CNPC_Zombine::ReleaseGrenade( Vector vPhysgunPos ) { if ( HasGrenade() == false ) return; Vector vDir = vPhysgunPos - m_hGrenade->GetAbsOrigin(); VectorNormalize( vDir ); Activity aActivity; Vector vForward, vRight; GetVectors( &vForward, &vRight, NULL ); float flDotForward = DotProduct( vForward, vDir ); float flDotRight = DotProduct( vRight, vDir ); bool bNegativeForward = false; bool bNegativeRight = false; if ( flDotForward < 0.0f ) { bNegativeForward = true; flDotForward = flDotForward * -1; } if ( flDotRight < 0.0f ) { bNegativeRight = true; flDotRight = flDotRight * -1; } if ( flDotRight > flDotForward ) { if ( bNegativeRight == true ) aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_WEST; else aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_EAST; } else { if ( bNegativeForward == true ) aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_BACK; else aActivity = (Activity)ACT_ZOMBINE_GRENADE_FLINCH_FRONT; } AddGesture( aActivity ); DropGrenade( vec3_origin ); if ( IsSprinting() ) { StopSprint(); } else { Sprint(); } }
//----------------------------------------------------------------------------- // Purpose: // // // Output : //----------------------------------------------------------------------------- void CNPC_RollerDozer::RunTask( const Task_t *pTask ) { switch( pTask->iTask ) { case TASK_ROLLERDOZER_CLEAR_DEBRIS: if( gpGlobals->curtime > m_flWaitFinished ) { m_hDebris = NULL; m_flTimeDebrisSearch = gpGlobals->curtime; TaskComplete(); } else if( m_hDebris != NULL ) { float yaw = UTIL_VecToYaw( m_hDebris->GetLocalOrigin() - GetLocalOrigin() ); Vector vecRight, vecForward; AngleVectors( QAngle( 0, yaw, 0 ), &vecForward, &vecRight, NULL ); //Stop pushing if I'm going to push this object sideways or back towards the center of the cleanup area. Vector vecCleanupDir = m_hDebris->GetLocalOrigin() - m_vecCleanupPoint; VectorNormalize( vecCleanupDir ); if( DotProduct( vecForward, vecCleanupDir ) < -0.5 ) { // HACKHACK !!!HACKHACK - right now forcing an unstick. Do this better (sjb) // Clear the debris, suspend the search for debris, trick base class into unsticking me. m_hDebris = NULL; m_flTimeDebrisSearch = gpGlobals->curtime + 4; m_iFail = 10; TaskFail("Pushing Wrong Way"); } m_RollerController.m_vecAngular = WorldToLocalRotation( SetupMatrixAngles(GetLocalAngles()), vecRight, ROLLERDOZER_FORWARD_SPEED * 2 ); } else { TaskFail("No debris!!"); } break; default: BaseClass::RunTask( pTask ); break; } }
void CNPC_Zombine::DropGrenade( Vector vDir ) { if ( m_hGrenade == NULL ) return; m_hGrenade->SetParent( NULL ); m_hGrenade->SetOwnerEntity( NULL ); Vector vGunPos; QAngle angles; GetAttachment( "grenade_attachment", vGunPos, angles ); IPhysicsObject *pPhysObj = m_hGrenade->VPhysicsGetObject(); if ( pPhysObj == NULL ) { m_hGrenade->SetMoveType( MOVETYPE_VPHYSICS ); m_hGrenade->SetSolid( SOLID_VPHYSICS ); m_hGrenade->SetCollisionGroup( COLLISION_GROUP_WEAPON ); m_hGrenade->CreateVPhysics(); } if ( pPhysObj ) { pPhysObj->Wake(); pPhysObj->SetPosition( vGunPos, angles, true ); pPhysObj->ApplyForceCenter( vDir * 0.2f ); pPhysObj->RecheckCollisionFilter(); } m_hGrenade = NULL; }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CAmbientGeneric::Activate( void ) { BaseClass::Activate(); // Initialize sound source. If no source was given, or source can't be found // then this is the source if (m_hSoundSource == NULL) { if (m_sSourceEntName != NULL_STRING) { m_hSoundSource = gEntList.FindEntityByName( NULL, m_sSourceEntName ); if ( m_hSoundSource != NULL ) { m_nSoundSourceEntIndex = m_hSoundSource->entindex(); } } if (m_hSoundSource == NULL) { m_hSoundSource = this; m_nSoundSourceEntIndex = entindex(); } else { if ( !FBitSet( m_spawnflags, SF_AMBIENT_SOUND_EVERYWHERE ) ) { AddEFlags( EFL_FORCE_CHECK_TRANSMIT ); } } } // If active start the sound if ( m_fActive ) { int flags = SND_SPAWNING; // If we are loading a saved game, we can't write into the init/signon buffer here, so just issue // as a regular sound message... if ( gpGlobals->eLoadType == MapLoad_Transition || gpGlobals->eLoadType == MapLoad_LoadGame || g_pGameRules->InRoundRestart() ) { flags = SND_NOFLAGS; } // Tracker 76119: 8/12/07 ywb: // Make sure pitch and volume are set up to the correct value (especially after restoring a .sav file) flags |= ( SND_CHANGE_PITCH | SND_CHANGE_VOL ); // Don't bother sending over to client if volume is zero, though if ( m_dpv.vol > 0 ) { SendSound( (SoundFlags_t)flags ); } SetNextThink( gpGlobals->curtime + 0.1f ); } }