//----------------------------------------------------------------------------- // Purpose: Non-Caching CalcVehicleView for Scratch SDK + Multiplayer // TODO: fix the normal CalcVehicleView so that Caching can work in multiplayer. //----------------------------------------------------------------------------- void C_SDKPlayer::CalcVehicleView(IClientVehicle *pVehicle, Vector& eyeOrigin, QAngle& eyeAngles, float& zNear, float& zFar, float& fov ) { Assert( pVehicle ); // Start with our base origin and angles int nRole = pVehicle->GetPassengerRole( this ); // Get our view for this frame pVehicle->GetVehicleViewPosition( nRole, &eyeOrigin, &eyeAngles, &fov ); // Allows the vehicle to change the clip planes pVehicle->GetVehicleClipPlanes( zNear, zFar ); // Snack off the origin before bob + water offset are applied Vector vecBaseEyePosition = eyeOrigin; CalcViewRoll( eyeAngles ); // Apply punch angle VectorAdd( eyeAngles, m_Local.m_vecPunchAngle, eyeAngles ); if ( !prediction->InPrediction() ) { // Shake it up baby! GetViewEffects()->CalcShake(); GetViewEffects()->ApplyShake( eyeOrigin, eyeAngles, 1.0 ); } }
void C_World::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); // Always force reset to normal mode upon receipt of world in new map if ( updateType == DATA_UPDATE_CREATED ) { modemanager->SwitchMode( false, true ); if ( m_bStartDark ) { ScreenFade_t sf; memset( &sf, 0, sizeof( sf ) ); sf.a = 255; sf.r = 0; sf.g = 0; sf.b = 0; sf.duration = (float)(1<<SCREENFADE_FRACBITS) * 5.0f; sf.holdTime = (float)(1<<SCREENFADE_FRACBITS) * 1.0f; sf.fadeFlags = FFADE_IN | FFADE_PURGE; FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); GetViewEffects()->Fade( sf ); } } OcclusionParams_t params; params.m_flMaxOccludeeArea = m_flMaxOccludeeArea; params.m_flMinOccluderArea = m_flMinOccluderArea; engine->SetOcclusionParameters( params ); modelinfo->SetLevelScreenFadeRange( m_flMinPropScreenSpaceWidth, m_flMaxPropScreenSpaceWidth ); }
void CBaseViewModel::CalcViewModelView( CBasePlayer *owner, const Vector& eyePosition, const QAngle& eyeAngles ) { // UNDONE: Calc this on the server? Disabled for now as it seems unnecessary to have this info on the server #if defined( CLIENT_DLL ) QAngle vmangoriginal = eyeAngles; QAngle vmangles = eyeAngles; Vector vmorigin = eyePosition; Vector vecRight; Vector vecUp; Vector vecForward; AngleVectors( vmangoriginal, &vecForward, &vecRight, &vecUp ); //Vector vecOffset = Vector( viewmodel_offset_x.GetFloat(), viewmodel_offset_y.GetFloat(), viewmodel_offset_z.GetFloat() ); vmorigin += (vecForward * viewmodel_offset_y.GetFloat()) + (vecUp * viewmodel_offset_z.GetFloat()) + (vecRight * viewmodel_offset_x.GetFloat()); // TrackIR if ( IsHeadTrackingEnabled() ) { vmorigin = owner->EyePosition(); VectorAngles( owner->GetAutoaimVector( AUTOAIM_5DEGREES ), vmangoriginal ); vmangles = vmangoriginal; } // TrackIR CBaseCombatWeapon *pWeapon = m_hWeapon.Get(); //Allow weapon lagging if ( pWeapon != NULL ) { #if defined( CLIENT_DLL ) if ( !prediction->InPrediction() ) #endif { // add weapon-specific bob pWeapon->AddViewmodelBob( this, vmorigin, vmangles ); } } // Add model-specific bob even if no weapon associated (for head bob for off hand models) AddViewModelBob( owner, vmorigin, vmangles ); // Add lag CalcViewModelLag( vmorigin, vmangles, vmangoriginal ); #if defined( CLIENT_DLL ) if ( !prediction->InPrediction() ) { // Let the viewmodel shake at about 10% of the amplitude of the player's view ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() ); GetViewEffects()->ApplyShake( vmorigin, vmangles, 0.1 ); } #endif CalcIronsights( vmorigin, vmangles ); SetLocalOrigin( vmorigin ); SetLocalAngles( vmangles ); #endif }
void CASW_Weapon_Chainsaw::AdjustChainsawPitch() { if ( !m_pChainsawAttackSound ) { if ( asw_chainsaw_debug.GetBool() ) { Msg( "No chainsaw attack sound, aborting\n" ); } return; } // Translated into the pitch values as represented in the soundscripts that would mean roughly that you // change the pitch value to randomly land between 85 and 90. (Pitch value 100 equals no change. Pitch value 50 is one octave lower.) // The pitch down should happen over 100 milliseconds. 400 ms later (half as second after the impact triggered the pitch down) // reset to the original pitch value over 250 ms. float flTransitionRate = 50.0f; // check for returning to normal pitch if ( ( gpGlobals->curtime - m_flLastHitTime ) > asw_chainsaw_pitch_return_delay.GetFloat() ) { m_flTargetChainsawPitch = 100.0f; flTransitionRate = asw_chainsaw_pitch_return_rate.GetFloat(); } else if ( m_flTargetChainsawPitch == 0.0f ) // just started attacking something { float flPitchMin = asw_chainsaw_pitch_target.GetFloat() - asw_chainsaw_pitch_range.GetFloat(); float flPitchMax = asw_chainsaw_pitch_target.GetFloat() + asw_chainsaw_pitch_range.GetFloat(); if ( asw_chainsaw_debug.GetBool() ) { Msg( "pitch min/max( %f %f )\n", flPitchMin, flPitchMax ); } m_flTargetChainsawPitch = RandomFloat( flPitchMin, flPitchMax ); flTransitionRate = asw_chainsaw_pitch_bite_rate.GetFloat(); #ifdef CLIENT_DLL if ( !( prediction && prediction->InPrediction() && !prediction->IsFirstTimePredicted() ) ) { // move this somewhere else.... ScreenShake_t shake; shake.command = SHAKE_STOP; shake.amplitude = 0; HACK_GETLOCALPLAYER_GUARD( "ASW_AdjustChainsawPitch" ); GetViewEffects()->Shake( shake ); shake.command = SHAKE_START; shake.amplitude = asw_chainsaw_shake_amplitude.GetFloat(); shake.frequency = asw_chainsaw_shake_frequency.GetFloat(); shake.duration = asw_chainsaw_shake_duration.GetFloat(); GetViewEffects()->Shake( shake ); } #endif } float flCurPitch = CSoundEnvelopeController::GetController().SoundGetPitch( m_pChainsawAttackSound ); if ( flCurPitch != m_flTargetChainsawPitch ) { if ( asw_chainsaw_debug.GetBool() ) { Msg( "Changing chainsaw pitch to %f transition rate %f\n", m_flTargetChainsawPitch, flTransitionRate ); } flCurPitch = Approach( m_flTargetChainsawPitch, flCurPitch, flTransitionRate * gpGlobals->curtime ); CSoundEnvelopeController::GetController().SoundChangePitch( m_pChainsawAttackSound, flCurPitch, 0.0f ); } }