//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehicleDriveable::InputTurnOn( inputdata_t &inputdata ) { // If the player's in the vehicle, start the engine. if ( GetServerVehicle()->GetPassenger( VEHICLE_DRIVER ) ) { StartEngine(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropVehicleDriveable::EnterVehicle( CBasePlayer *pPlayer ) { if ( !pPlayer ) return; // Remove any player who may be in the vehicle at the moment ExitVehicle(VEHICLE_DRIVER); m_VehiclePhysics.ReleaseHandbrake(); m_hPlayer = pPlayer; m_savedViewOffset = pPlayer->GetViewOffset(); pPlayer->SetViewOffset( vec3_origin ); m_playerOn.FireOutput( pPlayer, this, 0 ); StartEngine(); // Start Thinking SetNextThink( gpGlobals->curtime ); m_VehiclePhysics.GetVehicle()->OnVehicleEnter(); }
bool CCar::bfAssignMovement(CScriptEntityAction *tpEntityAction) { if (tpEntityAction->m_tMovementAction.m_bCompleted) return(false); u32 l_tInput = tpEntityAction->m_tMovementAction.m_tInputKeys; vfProcessInputKey(kFWD , !!(l_tInput & CScriptMovementAction::eInputKeyForward )); vfProcessInputKey(kBACK , !!(l_tInput & CScriptMovementAction::eInputKeyBack )); vfProcessInputKey(kL_STRAFE , !!(l_tInput & CScriptMovementAction::eInputKeyLeft )); vfProcessInputKey(kR_STRAFE , !!(l_tInput & CScriptMovementAction::eInputKeyRight )); vfProcessInputKey(kACCEL , !!(l_tInput & CScriptMovementAction::eInputKeyShiftUp )); vfProcessInputKey(kCROUCH , !!(l_tInput & CScriptMovementAction::eInputKeyShiftDown )); vfProcessInputKey(kJUMP , !!(l_tInput & CScriptMovementAction::eInputKeyBreaks )); if (!!(l_tInput & CScriptMovementAction::eInputKeyEngineOn)) StartEngine(); if (!!(l_tInput & CScriptMovementAction::eInputKeyEngineOff)) StopEngine(); //if (_abs(tpEntityAction->m_tMovementAction.m_fSpeed) > EPS_L) //m_current_rpm = _abs(tpEntityAction->m_tMovementAction.m_fSpeed*m_current_gear_ratio); return (true); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CASW_PropJeep::Think(void) { m_VehiclePhysics.Think(); // Derived classes of CPropVehicle have their own code to determine how frequently to think. // But the prop_vehicle entity native to this class will only think one time, so this flag // was added to allow prop_vehicle to always think without affecting the derived classes. if( HasSpawnFlags(SF_PROP_VEHICLE_ALWAYSTHINK) ) { SetNextThink(gpGlobals->curtime); } if ( ShouldThink() ) { SetNextThink( gpGlobals->curtime ); } // If we have an NPC Driver, tell him to drive if ( m_hNPCDriver ) { GetServerVehicle()->NPC_DriveVehicle(); } // Keep thinking while we're waiting to turn off the keep upright if ( m_flTurnOffKeepUpright ) { SetNextThink( gpGlobals->curtime ); // Time up? if ( m_hKeepUpright != NULL && m_flTurnOffKeepUpright < gpGlobals->curtime ) { variant_t emptyVariant; m_hKeepUpright->AcceptInput( "TurnOff", this, this, emptyVariant, USE_TOGGLE ); m_flTurnOffKeepUpright = 0; UTIL_Remove( m_hKeepUpright ); } } /* CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); if ( m_bEngineLocked ) { m_bUnableToFire = true; if ( pPlayer != NULL ) { pPlayer->m_Local.m_iHideHUD |= HIDEHUD_VEHICLE_CROSSHAIR; } } else if ( m_bHasGun ) { // Start this as false and update it again each frame m_bUnableToFire = false; if ( pPlayer != NULL ) { pPlayer->m_Local.m_iHideHUD &= ~HIDEHUD_VEHICLE_CROSSHAIR; } }*/ // Water!? HandleWater(); SetSimulationTime( gpGlobals->curtime ); SetNextThink( gpGlobals->curtime ); SetAnimatedEveryTick( true ); if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } // Check overturned status. if ( !IsOverturned() ) { m_flOverturnedTime = 0.0f; } else { m_flOverturnedTime += gpGlobals->frametime; } // spin gun if charging cannon //FIXME: Don't bother for E3 if ( m_bCannonCharging ) { m_nSpinPos += JEEP_GUN_SPIN_RATE; SetPoseParameter( JEEP_GUN_SPIN, m_nSpinPos ); } // Aim gun based on the player view direction. 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; AimGunAt( &vecEndPos, 0.1f ); } StudioFrameAdvance(); // If the enter or exit animation has finished, tell the server vehicle if ( IsSequenceFinished() && (m_bExitAnimOn || m_bEnterAnimOn) ) { if ( m_bEnterAnimOn ) { m_VehiclePhysics.ReleaseHandbrake(); StartEngine(); // HACKHACK: This forces the jeep to play a sound when it gets entered underwater if ( m_VehiclePhysics.IsEngineDisabled() ) { CBaseServerVehicle *pServerVehicle = dynamic_cast<CBaseServerVehicle *>(GetServerVehicle()); if ( pServerVehicle ) { pServerVehicle->SoundStartDisabled(); } } // The first few time we get into the jeep, print the jeep help if ( m_iNumberOfEntries < asw_hud_jeephint_numentries.GetInt() ) { UTIL_HudHintText( m_hPlayer, "#Valve_Hint_JeepKeys" ); m_iNumberOfEntries++; } } // If we're exiting and have had the tau cannon removed, we don't want to reset the animation GetServerVehicle()->HandleEntryExitFinish( m_bExitAnimOn, !(m_bExitAnimOn && TauCannonHasBeenCutOff()) ); } // See if the ammo crate needs to close if ( ( m_flAmmoCrateCloseTime < gpGlobals->curtime ) && ( GetSequence() == LookupSequence( "ammo_open" ) ) ) { m_flAnimTime = gpGlobals->curtime; m_flPlaybackRate = 0.0; SetCycle( 0 ); ResetSequence( LookupSequence( "ammo_close" ) ); } else if ( ( GetSequence() == LookupSequence( "ammo_close" ) ) && IsSequenceFinished() ) { m_flAnimTime = gpGlobals->curtime; m_flPlaybackRate = 0.0; SetCycle( 0 ); ResetSequence( LookupSequence( "idle" ) ); CPASAttenuationFilter sndFilter( this, "PropJeep.AmmoClose" ); EmitSound( sndFilter, entindex(), "PropJeep.AmmoClose" ); } }
WError Setup() { WError err = StartEngine(500, 500); return err; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CPropJeep::Think(void) { 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; } } */ // Water!? HandleWater(); SetSimulationTime( gpGlobals->curtime ); SetNextThink( gpGlobals->curtime ); SetAnimatedEveryTick( true ); if ( !m_bInitialHandbrake ) // after initial timer expires, set the handbrake { m_bInitialHandbrake = true; m_VehiclePhysics.SetHandbrake( true ); m_VehiclePhysics.Think(); } // Check overturned status. if ( !IsOverturned() ) { m_flOverturnedTime = 0.0f; } else { m_flOverturnedTime += gpGlobals->frametime; } // spin gun if charging cannon //FIXME: Don't bother for E3 if ( m_bCannonCharging ) { m_nSpinPos += JEEP_GUN_SPIN_RATE; SetPoseParameter( JEEP_GUN_SPIN, m_nSpinPos ); } // Aim gun based on the player view direction. 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; AimGunAt( &vecEndPos, 0.1f ); } StudioFrameAdvance(); // If the enter or exit animation has finished, tell the server vehicle if ( IsSequenceFinished() && (m_bExitAnimOn || m_bEnterAnimOn) ) { if ( m_bEnterAnimOn ) { m_VehiclePhysics.ReleaseHandbrake(); StartEngine(); // HACKHACK: This forces the jeep to play a sound when it gets entered underwater if ( m_VehiclePhysics.IsEngineDisabled() ) { CBaseServerVehicle *pServerVehicle = dynamic_cast<CBaseServerVehicle *>(GetServerVehicle()); if ( pServerVehicle ) { pServerVehicle->SoundStartDisabled(); } } // The first few time we get into the jeep, print the jeep help if ( m_iNumberOfEntries < hud_jeephint_numentries.GetInt() ) { UTIL_HudHintText( m_hPlayer, "#Valve_Hint_JeepKeys" ); m_iNumberOfEntries++; } } // If we're exiting and have had the tau cannon removed, we don't want to reset the animation GetServerVehicle()->HandleEntryExitFinish( m_bExitAnimOn, true ); } // See if the ammo crate needs to close if ( ( m_flAmmoCrateCloseTime < gpGlobals->curtime ) && ( GetSequence() == LookupSequence( "ammo_open" ) ) ) { m_flAnimTime = gpGlobals->curtime; m_flPlaybackRate = 0.0; SetCycle( 0 ); ResetSequence( LookupSequence( "ammo_close" ) ); } else if ( ( GetSequence() == LookupSequence( "ammo_close" ) ) && IsSequenceFinished() ) { m_flAnimTime = gpGlobals->curtime; m_flPlaybackRate = 0.0; SetCycle( 0 ); ResetSequence( LookupSequence( "idle" ) ); CPASAttenuationFilter sndFilter( this, "PropJeep.AmmoClose" ); EmitSound( sndFilter, entindex(), "PropJeep.AmmoClose" ); } }
void CCar::SwitchEngine() { if(b_engine_on) StopEngine(); else StartEngine(); }