//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehicleViewController::InputForcePlayerIn( inputdata_t &inputdata ) { CBasePlayer *pPlayer = UTIL_PlayerByIndex(1); if ( !pPlayer ) return; ResetUseKey( pPlayer ); // Get the entry animation from the input int iEntryAnim = ACTIVITY_NOT_AVAILABLE; if ( inputdata.value.StringID() != NULL_STRING ) { iEntryAnim = LookupSequence( inputdata.value.String() ); if ( iEntryAnim == ACTIVITY_NOT_AVAILABLE ) { Warning("vehicle_viewcontroller %s could not find specified entry animation %s\n", STRING(GetEntityName()), inputdata.value.String() ); return; } } // Make sure we successfully got in the vehicle if ( pPlayer->GetInVehicle( GetServerVehicle(), VEHICLE_ROLE_DRIVER ) == false ) { // The player was unable to enter the vehicle and the output has failed Assert( 0 ); return; } // Setup the "enter" vehicle sequence SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( iEntryAnim ); ResetClientsideFrame(); m_bEnterAnimOn = true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehicleDriveable::Use( CBaseEntity *pActivator, CBaseEntity *pCaller, USE_TYPE useType, float value ) { CBasePlayer *pPlayer = ToBasePlayer( pActivator ); if ( !pPlayer ) return; ResetUseKey( pPlayer ); // Find out which hitbox the player's eyepoint is within int iEntryAnim = m_pServerVehicle->GetEntryAnimForPoint( pPlayer->EyePosition() ); // Are we in an entrypoint zone? if ( iEntryAnim != ACTIVITY_NOT_AVAILABLE ) { // Check to see if this vehicle can be controlled or if it's locked if ( CanControlVehicle() && CanEnterVehicle(pPlayer) ) { pPlayer->GetInVehicle( GetServerVehicle(), VEHICLE_DRIVER); // Setup the "enter" vehicle sequence and skip the animation if it isn't present. m_flCycle = 0; m_flAnimTime = gpGlobals->curtime; ResetSequence( iEntryAnim ); ResetClientsideFrame(); m_bEnterAnimOn = true; } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC::Think( void ) { BaseClass::Think(); SetNextThink( gpGlobals->curtime ); if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } StudioFrameAdvance(); if ( IsSequenceFinished() ) { int iSequence = SelectWeightedSequence( ACT_IDLE ); if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); } } if (m_debugOverlays & OVERLAY_NPC_KILL_BIT) { CTakeDamageInfo info( this, this, m_iHealth, DMG_BLAST ); info.SetDamagePosition( WorldSpaceCenter() ); info.SetDamageForce( Vector( 0, 0, 1 ) ); TakeDamage( info ); } }
//----------------------------------------------------------------------------- // Purpose: Thin wrapper over CBaseAnimating::SetSequence to do bookkeeping. // Input : sequence - //----------------------------------------------------------------------------- void CBaseObject::SetObjectSequence( int sequence ) { ResetSequence( sequence ); SetCycle( 0 ); #if !defined( CLIENT_DLL ) if ( IsUsingClientSideAnimation() ) { ResetClientsideFrame(); } #endif }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropJetski::Think(void) { BaseClass::Think(); // set handbrake after physics sim settles down if ( gpGlobals->curtime < m_flHandbrakeTime ) { SetNextThink( gpGlobals->curtime ); } else if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } // play enter animation if ( (m_bEnterAnimOn || m_bExitAnimOn) && !IsSequenceFinished() ) { StudioFrameAdvance(); } else if ( IsSequenceFinished() ) { if ( m_bExitAnimOn ) { CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); if ( pPlayer ) { pPlayer->LeaveVehicle(); // now that sequence is finished, leave car Vector vecEyes; QAngle vecEyeAng; GetAttachment( "vehicle_driver_eyes", vecEyes, vecEyeAng ); vecEyeAng.x = 0; vecEyeAng.z = 0; pPlayer->SnapEyeAngles( vecEyeAng ); } m_bExitAnimOn = false; } int iSequence = SelectWeightedSequence( ACT_IDLE ); if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle(0); m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); } } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- bool CPropVehicleDriveable::PlayExitAnimation( void ) { int iSequence = m_pServerVehicle->GetExitAnimToUse(); // Skip if no animation present if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { m_flCycle = 0; m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); m_bExitAnimOn = true; return true; } return false; }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CPropVehicleChoreoGeneric::InputOpen( inputdata_t &inputdata ) { int nSequence = LookupSequence( "open" ); // Set to the desired anim, or default anim if the desired is not present if ( nSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( nSequence ); ResetClientsideFrame(); } else { // Not available try to get default anim Msg( "Choreo Generic Vehicle %s: missing open sequence\n", GetDebugName() ); SetSequence( 0 ); } }
//------------------------------------------------------------------------------ // Purpose: //------------------------------------------------------------------------------ void CPropVehiclePrisonerPod::InputClose( inputdata_t &inputdata ) { // The enter anim closes the pod, so don't do this redundantly! if ( m_bLocked || m_bEnterAnimOn ) return; int nSequence = LookupSequence( "close" ); // Set to the desired anim, or default anim if the desired is not present if ( nSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( nSequence ); ResetClientsideFrame(); EmitSound( "d3_citadel.pod_close" ); } else { // Not available try to get default anim Msg( "Prisoner pod %s: missing close sequence\n", GetDebugName() ); SetSequence( 0 ); } }
//----------------------------------------------------------------------------- // Purpose: // NOTE: Doesn't call the base call enter vehicle on purpose! //----------------------------------------------------------------------------- void CPropVehicleManhack::EnterVehicle( CBaseCombatCharacter *pPassenger ) { if ( pPassenger == NULL ) return; DevMsg("CPropVehicleManhack: EnterVehicl(...)\n"); CBasePlayer *pPlayer = ToBasePlayer( pPassenger ); if ( pPlayer != NULL ) { // Remove any player who may be in the vehicle at the moment if ( m_hPlayer ) { ExitVehicle( VEHICLE_ROLE_DRIVER ); } m_hPlayer = pPlayer; m_bHadDriver = true; if (GetNumberOfHacks(false)>1 && m_iHintTimesShown < 2) { m_iHintTimesShown++; m_iHintNoSwapTimesShown++; UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackSwap" ); } else if (m_iHintNoSwapTimesShown < 2) { m_iHintNoSwapTimesShown++; UTIL_HudHintText( pPlayer, "#HLSS_Hint_ManhackExit" ); } else UTIL_HudHintText( pPlayer, "" ); pPlayer->SetViewOffset( vec3_origin ); pPlayer->ShowCrosshair( false ); CHL2_Player *pHL2Player = dynamic_cast<CHL2_Player*>( pPlayer ); if ( pHL2Player ) { if ( pHL2Player->IsSprinting() ) { pHL2Player->StopSprinting(); } if ( pHL2Player->FlashlightIsOn() ) { pHL2Player->FlashlightTurnOff(); } } CNPC_Manhack *pManhack = dynamic_cast<CNPC_Manhack*>((CBaseEntity*)m_hManhack); if (pManhack!=NULL) { pManhack->SetControllable(true); if (manhack_dont_draw.GetBool()) { pManhack->AddEffects( EF_NODRAW ); pManhack->ShowRedGlow(false); } m_vecLastEyeTarget = pManhack->GetManhackView(); m_vecLastEyePos = pManhack->GetManhackView(); m_vecTargetSpeed = pManhack->GetAbsVelocity(); m_vecFlyingDirection = pManhack->GetAbsVelocity(); } //We want to see and feel the "vehicle" in manhack mode //SetRenderMode(kRenderNormal); RemoveEffects( EF_NODRAW ); SetSolid(SOLID_BBOX); RemoveSolidFlags( FSOLID_NOT_SOLID ); if (m_bDriverDucked) { SetCollisionBounds( Vector(-16,-16,0), Vector(16,16,45) ); int nSequence = LookupSequence( "crouch" ); DevMsg("Player is ducking\n"); // Set to the desired anim, or default anim if the desired is not present if ( nSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( nSequence ); ResetClientsideFrame(); } else { // Not available try to get default anim Msg( "Manhack Controller %s: missing crouch sequence\n", GetDebugName() ); SetSequence( 0 ); } } else { SetCollisionBounds( Vector(-16,-16,0), Vector(16,16,72) ); int nSequence = LookupSequence( "idle" ); // Set to the desired anim, or default anim if the desired is not present if ( nSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( nSequence ); ResetClientsideFrame(); } } // Start Thinking SetNextThink( gpGlobals->curtime ); } else { // NPCs not yet supported - jdw Assert( 0 ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropAPC2::Think( void ) { if (!m_bSpawn) { if(m_fReloadTime<=gpGlobals->curtime && m_iAmmoCount<50) { m_iAmmoCount++; m_fReloadTime=gpGlobals->curtime+0.5f; } if(m_fCannonCharge<=gpGlobals->curtime && m_iCannonCount<100) { m_iCannonCount++; m_fCannonCharge=gpGlobals->curtime+0.03f; } BaseClass::Think(); CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); if ( m_bEngineLocked ) { m_bUnableToFire = true; if ( pPlayer != NULL ) { pPlayer->m_Local.m_iHideHUD |= HIDEHUD_VEHICLE_CROSSHAIR; } } else { // Start this as false and update it again each frame m_bUnableToFire = false; if ( pPlayer != NULL ) { pPlayer->m_Local.m_iHideHUD &= ~HIDEHUD_VEHICLE_CROSSHAIR; } } SetNextThink( gpGlobals->curtime ); if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } StudioFrameAdvance(); if ( IsSequenceFinished() ) { int iSequence = SelectWeightedSequence( ACT_IDLE ); if ( iSequence > ACTIVITY_NOT_AVAILABLE ) { SetCycle( 0 ); m_flAnimTime = gpGlobals->curtime; ResetSequence( iSequence ); ResetClientsideFrame(); } } if ( m_hPlayer && !m_bExitAnimOn && !m_bEnterAnimOn ) { Vector vecEyeDir, vecEyePos; m_hPlayer->EyePositionAndVectors( &vecEyePos, &vecEyeDir, NULL, NULL ); // Trace out from the player's eye point. Vector vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH ); trace_t trace; UTIL_TraceLine( vecEyePos, vecEndPos, MASK_SHOT, this, COLLISION_GROUP_NONE, &trace ); // See if we hit something, if so, adjust end position to hit location. if ( trace.fraction < 1.0 ) { vecEndPos = vecEyePos + ( vecEyeDir * MAX_TRACE_LENGTH * trace.fraction ); } //m_vecLookCrosshair = vecEndPos; m_vecGunCrosshair=vecEndPos; AimPrimaryWeapon( vecEndPos ); //GetRocketShootPosition( &vecEndPos ); if ( m_hLaserDot != NULL ) { Vector laserPos = trace.endpos; m_hLaserDot->SetAbsOrigin(laserPos); if ( trace.DidHitNonWorldEntity() ) { CBaseEntity *pHit = trace.m_pEnt; if ( ( pHit != NULL ) && ( pHit->m_takedamage ) ) { SetLaserDotTarget( m_hLaserDot, pHit ); EnableLaserDot( m_hLaserDot, pHit != NULL ); } else { SetLaserDotTarget( m_hLaserDot, NULL ); EnableLaserDot(m_hLaserDot,true); } } else { SetLaserDotTarget( m_hLaserDot, NULL ); EnableLaserDot(m_hLaserDot,true); } } } } }