bool CWeaponDODBase::ShouldAutoEjectBrass( void ) { // Don't eject brass if further than N units from the local player C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pLocalPlayer ) return true; float flMaxDistSqr = 250; flMaxDistSqr *= flMaxDistSqr; float flDistSqr = pLocalPlayer->EyePosition().DistToSqr( GetAbsOrigin() ); return ( flDistSqr < flMaxDistSqr ); }
void CPlayerTeamProxy::OnBind( void *pC_BaseEntity ) { C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if (!pPlayer) return; if(pPlayer->GetTeamNumber() == TEAM_PINK) m_pResult->SetIntValue(1); else if(pPlayer->GetTeamNumber() == TEAM_GREEN) m_pResult->SetIntValue(2); else m_pResult->SetIntValue(0); }
float C_FuncAreaPortalWindow::GetDistanceBlend() { // Get the viewer's distance to us. float flDist = CollisionProp()->CalcDistanceFromPoint( CurrentViewOrigin() ); C_BasePlayer *local = C_BasePlayer::GetLocalPlayer(); if ( local ) { flDist *= local->GetFOVDistanceAdjustFactor(); } float flAlpha = RemapVal( flDist, m_flFadeStartDist, m_flFadeDist, m_flTranslucencyLimit, 1 ); flAlpha = clamp( flAlpha, m_flTranslucencyLimit, 1 ); return flAlpha; }
//----------------------------------------------------------------------------- // Purpose: If the shield has no health, and they're trying to raise it, flash the power level //----------------------------------------------------------------------------- void CWeaponCombatShield::HandleInput( void ) { // If the player's dead, ignore input C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer || pPlayer->GetHealth() < 0 ) return; // Attempting to raise the shield? if ( !GetShieldHealth() && ( gHUD.m_iKeyBits & IN_ATTACK2 ) ) { m_flFlashTimeEnd = gpGlobals->curtime + 1.0; } }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() ) // TODO: figure out the purpose of the ShouldDrawLocalPlayer() test. { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { int overrideModelIndex = CalcOverrideModelIndex(); if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() ) { SetModelIndex( overrideModelIndex ); } } if ( updateType == DATA_UPDATE_CREATED ) { UpdateVisibility(); } m_iOldState = m_iState; m_bJustRestored = false; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Vector GetTracerOrigin( const CEffectData &data ) { Vector vecStart = data.m_vStart; QAngle vecAngles; int iAttachment = data.m_nAttachmentIndex;; // Attachment? if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT ) { C_BaseViewModel *pViewModel = NULL; // If the entity specified is a weapon being carried by this player, use the viewmodel instead IClientRenderable *pRenderable = data.GetRenderable(); if ( !pRenderable ) return vecStart; C_BaseEntity *pEnt = data.GetEntity(); FOR_EACH_VALID_SPLITSCREEN_PLAYER( hh ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD( hh ); C_BaseCombatWeapon *pWpn = ToBaseCombatWeapon( pEnt ); if ( pWpn && pWpn->IsCarriedByLocalPlayer() ) { C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() ); if( !player && pWpn->GetOwner() && pWpn->GetOwner()->IsUnit() ) { player = pWpn->GetOwner()->MyUnitPointer()->GetCommander(); } pViewModel = player ? player->GetViewModel( 0 ) : NULL; if ( pViewModel ) { // Get the viewmodel and use it instead pRenderable = pViewModel; break; } } } // Get the attachment origin if ( !pRenderable->GetAttachment( iAttachment, vecStart, vecAngles ) ) { DevMsg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment, modelinfo->GetModelName( pRenderable->GetModel() ) ); } }
static void GetPos( const CCommand &args, Vector &vecOrigin, QAngle &angles ) { vecOrigin = MainViewOrigin(); angles = MainViewAngles(); if ( args.ArgC() == 2 && atoi( args[1] ) == 2 ) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer ) { vecOrigin = pPlayer->GetAbsOrigin(); angles = pPlayer->GetAbsAngles(); } } }
void CHudWeapon::Paint( void ) { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( !player ) return; MDLCACHE_CRITICAL_SECTION(); C_BaseCombatWeapon *pWeapon = player->GetActiveWeapon(); if ( pWeapon ) pWeapon->Redraw(); else if ( m_pCrosshair ) m_pCrosshair->ResetCrosshair(); }
Vector CParticleSystemQuery::GetLocalPlayerPos( void ) { #ifdef CLIENT_DLL C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return vec3_origin; return pPlayer->WorldSpaceCenter(); #else CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); //AI Patch Replacment: CBasePlayer *pPlayer = AI_GetSinglePlayer(); if ( !pPlayer ) return vec3_origin; return pPlayer->WorldSpaceCenter(); #endif }
//----------------------------------------------------------------------------- // Purpose: updates the ammo display counts //----------------------------------------------------------------------------- void CHudAmmo::UpdateAmmoDisplays() { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); IClientVehicle *pVehicle = player ? player->GetVehicle() : NULL; if ( !pVehicle ) { UpdatePlayerAmmo( player ); } else { UpdateVehicleAmmo( player, pVehicle ); } }
/* ============================== CAM_ToFirstPerson ============================== */ void CInput::CAM_ToFirstPerson(void) { g_ThirdPersonManager.SetDesiredCameraOffset( vec3_origin ); m_fCameraInThirdPerson = false; cam_command.SetValue( 0 ); // Let the local player know C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); if ( localPlayer ) { localPlayer->ThirdPersonSwitch( false ); } }
void OpenVoiceMenu( int index ) { // do not show the menu if the player is dead or is an observer C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return; if ( !pPlayer->IsAlive() || pPlayer->IsObserver() ) return; CHudMenu *pMenu = (CHudMenu *) gHUD.FindElement( "CHudMenu" ); if ( !pMenu ) return; // if they hit the key again, close the menu if ( g_ActiveVoiceMenu == index ) { if ( pMenu->IsMenuOpen() ) { pMenu->HideMenu(); g_ActiveVoiceMenu = 0; return; } } if ( index > 0 && index < 9 ) { KeyValues *pKV = new KeyValues( "MenuItems" ); CMultiplayRules *pRules = dynamic_cast< CMultiplayRules * >( GameRules() ); if ( pRules ) { if ( !pRules->GetVoiceMenuLabels( index-1, pKV ) ) { pKV->deleteThis(); return; } } pMenu->ShowMenu_KeyValueItems( pKV ); pKV->deleteThis(); g_ActiveVoiceMenu = index; } else { g_ActiveVoiceMenu = 0; } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- Vector GetTracerOrigin( const CEffectData &data ) { Vector vecStart = data.m_vStart; QAngle vecAngles; int iAttachment = data.m_nAttachmentIndex;; // Attachment? if ( data.m_fFlags & TRACER_FLAG_USEATTACHMENT ) { C_BaseViewModel *pViewModel = NULL; // If the entity specified is a weapon being carried by this player, use the viewmodel instead IClientRenderable *pRenderable = data.GetRenderable(); if ( !pRenderable ) return vecStart; C_BaseEntity *pEnt = data.GetEntity(); // This check should probably be for all multiplayer games, investigate later #if defined( HL2MP ) || defined( TF_CLIENT_DLL ) || defined( TF_CLASSIC_CLIENT ) if ( pEnt && pEnt->IsDormant() ) return vecStart; #endif C_BaseCombatWeapon *pWpn = dynamic_cast<C_BaseCombatWeapon *>( pEnt ); if ( pWpn && pWpn->ShouldDrawUsingViewModel() ) { C_BasePlayer *player = ToBasePlayer( pWpn->GetOwner() ); // Use GetRenderedWeaponModel() instead? pViewModel = player ? player->GetViewModel( 0 ) : NULL; if ( pViewModel ) { // Get the viewmodel and use it instead pRenderable = pViewModel; } } // Get the attachment origin if ( !pRenderable->GetAttachment( iAttachment, vecStart, vecAngles ) ) { DevMsg( "GetTracerOrigin: Couldn't find attachment %d on model %s\n", iAttachment, modelinfo->GetModelName( pRenderable->GetModel() ) ); } } return vecStart; }
//----------------------------------------------------------------------------- // Purpose: Adds a new row to the scoreboard, from the playerinfo structure //----------------------------------------------------------------------------- bool CHL2MPClientScoreBoardDialog::GetPlayerScoreInfo(int playerIndex, KeyValues *kv) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return false; kv->SetInt("playerIndex", playerIndex); kv->SetInt("team", g_PR->GetTeam( playerIndex ) ); kv->SetString("name", g_PR->GetPlayerName(playerIndex) ); //BG2 - Tjoppen - hide non-local player damage //kv->SetInt("deaths", g_PR->GetDeaths( playerIndex )); if ( sv_show_damages.GetBool() ) { kv->SetInt("deaths", g_PR->GetDeaths( playerIndex )); } else { if( playerIndex == pPlayer->entindex() ) kv->SetInt("deaths", g_PR->GetDeaths( playerIndex ) ); else kv->SetString("deaths", "" ); } // kv->SetInt("frags", g_PR->GetPlayerScore( playerIndex )); //BG2 - Tjoppen - dead column //kv->SetString("class", ""); //display for dead participating players kv->SetWString("class", !g_PR->IsAlive(playerIndex) && g_PR->GetTeam(playerIndex) >= TEAM_AMERICANS ? g_pVGuiLocalize->Find("#DEAD") : g_pVGuiLocalize->Find("#ALIVE")); // if (g_PR->GetPing( playerIndex ) < 1) { if ( g_PR->IsFakePlayer( playerIndex ) ) { kv->SetString("ping", "BOT"); } else { kv->SetString("ping", ""); } } else { kv->SetInt("ping", g_PR->GetPing( playerIndex )); } return true; }
void CHudCrosshair::Paint( void ) { if ( !m_pCrosshair ) return; if ( !IsCurrentViewAccessAllowed() ) return; C_BasePlayer* pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return; float x, y; bool bBehindCamera; GetDrawPosition ( &x, &y, &bBehindCamera, m_vecCrossHairOffsetAngle ); if( bBehindCamera ) return; float flWeaponScale = 1.f; int iTextureW = m_pCrosshair->Width(); int iTextureH = m_pCrosshair->Height(); C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if ( pWeapon ) { pWeapon->GetWeaponCrosshairScale( flWeaponScale ); } float flPlayerScale = 1.0f; #ifdef TF_CLIENT_DLL Color clr( cl_crosshair_red.GetInt(), cl_crosshair_green.GetInt(), cl_crosshair_blue.GetInt(), 255 ); flPlayerScale = cl_crosshair_scale.GetFloat() / 32.0f; // the player can change the scale in the options/multiplayer tab #else Color clr = m_clrCrosshair; #endif float flWidth = flWeaponScale * flPlayerScale * (float)iTextureW; float flHeight = flWeaponScale * flPlayerScale * (float)iTextureH; int iWidth = (int)( flWidth + 0.5f ); int iHeight = (int)( flHeight + 0.5f ); int iX = (int)( x + 0.5f ); int iY = (int)( y + 0.5f ); m_pCrosshair->DrawSelfCropped ( iX-(iWidth/2), iY-(iHeight/2), 0, 0, iTextureW, iTextureH, iWidth, iHeight, clr ); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_BaseViewModel::GetBoneControllers(float controllers[MAXSTUDIOBONECTRLS]) { BaseClass::GetBoneControllers( controllers ); // Tell the weapon itself that we've rendered, in case it wants to do something C_BasePlayer *pPlayer = ToBasePlayer( GetOwner() ); if ( !pPlayer ) return; C_BaseCombatWeapon *pWeapon = pPlayer->GetActiveWeapon(); if ( pWeapon ) { pWeapon->GetViewmodelBoneControllers( this, controllers ); } }
//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool C_BaseViewModel::IsTransparent( void ) { // See if the local player wants to override the viewmodel's rendering C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer && pPlayer->IsOverridingViewmodel() ) { return pPlayer->ViewModel_IsTransparent(); } C_BaseCombatWeapon *pWeapon = GetOwningWeapon(); if ( pWeapon && pWeapon->IsOverridingViewmodel() ) return pWeapon->ViewModel_IsTransparent(); return BaseClass::IsTransparent(); }
//----------------------------------------------------------------------------- // Purpose: Return true if the passed in sections of the HUD shouldn't be drawn //----------------------------------------------------------------------------- bool CHud::IsHidden( int iHudFlags, HUDRENDERSTAGE_t stage ) // GSTRINGMIGRATION { // GSTRINGMIGRATION const bool bDrawAll = m_iRenderingStage == HUDRENDERSTAGE_ALL; if ( !bDrawAll && stage != m_iRenderingStage ) return true; // END GSTRINGMIGRATION // Not in game? if ( !engine->IsInGame() ) return true; // No local player yet? C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return true; // Get current hidden flags int iHideHud = pPlayer->m_Local.m_iHideHUD; if ( hidehud.GetInt() ) { iHideHud = hidehud.GetInt(); } // Everything hidden? if ( iHideHud & HIDEHUD_ALL ) return true; // Local player dead? if ( ( iHudFlags & HIDEHUD_PLAYERDEAD ) && ( pPlayer->GetHealth() <= 0 && !pPlayer->IsAlive() ) ) return true; // Need the HEV suit ( HL2 ) if ( ( iHudFlags & HIDEHUD_NEEDSUIT ) && ( !pPlayer->IsSuitEquipped() ) ) return true; // Hide all HUD elements during screenshot if the user's set hud_freezecamhide ( TF2 ) #if defined( TF_CLIENT_DLL ) extern bool IsTakingAFreezecamScreenshot(); extern ConVar hud_freezecamhide; if ( IsTakingAFreezecamScreenshot() && hud_freezecamhide.GetBool() ) return true; #endif return ( ( iHudFlags & iHideHud ) != 0); }
//----------------------------------------------------------------------------- // Purpose: Localize, display, and animate the hud element //----------------------------------------------------------------------------- void CHudSideHintPanel::LocalizeAndDisplay( const char *pszHudTxtMsg, const char *szRawString ) { static wchar_t szBuf[128]; static wchar_t *pszBuf; // init buffers & pointers szBuf[0] = 0; pszBuf = szBuf; // try to localize if ( pszHudTxtMsg ) { pszBuf = g_pVGuiLocalize->Find( pszHudTxtMsg ); } else { pszBuf = g_pVGuiLocalize->Find( szRawString ); } if ( !pszBuf ) { // use plain ASCII string g_pVGuiLocalize->ConvertANSIToUnicode( szRawString, szBuf, sizeof(szBuf) ); pszBuf = szBuf; } // make it visible if ( SetHintText( pszBuf ) ) { SetVisible( true ); g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintShow" ); C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if ( pLocalPlayer ) { pLocalPlayer->EmitSound( "Hud.Hint" ); if ( pLocalPlayer->Hints() ) { pLocalPlayer->Hints()->PlayedAHint(); } } } else { g_pClientMode->GetViewportAnimationController()->StartAnimationSequence( "SideHintHide" ); } }
//Overridden because we want the menu to stay up after selection void CHudMenuStatic::SelectMenuItem(int menu_item) { if (SelectFunc) SelectFunc(menu_item); m_flSelectionTime = gpGlobals->realtime; m_nSelectedItem = menu_item; g_pClientMode->GetViewportAnimationController()->StartAnimationSequence("MenuPulse"); C_BasePlayer *cPlayer = C_BasePlayer::GetLocalPlayer(); if (cPlayer != NULL) { cPlayer->EmitSound("Momentum.UIMenuSelection"); } if (menu_item == 0) HideMenu(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CBaseHudChat::FireGameEvent( IGameEvent *event ) { #ifndef _XBOX const char *eventname = event->GetName(); if ( Q_strcmp( "hltv_chat", eventname ) == 0 ) { C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( !player ) return; ChatPrintf( player->entindex(), CHAT_FILTER_NONE, "(SourceTV) %s", event->GetString( "text" ) ); } #endif }
void C_TriggerPlayerMovement::EndTouch( C_BaseEntity *pOther ) { C_BasePlayer *pPlayer = ToBasePlayer( pOther ); if ( !pPlayer ) return; if ( HasSpawnFlags( SF_TRIGGER_AUTO_DUCK ) ) { pPlayer->UnforceButtons( IN_DUCK ); } if ( HasSpawnFlags( SF_TRIGGER_MOVE_AUTODISABLE ) ) { pPlayer->m_Local.m_bAllowAutoMovement = true; } }
//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- RenderableTranslucencyType_t C_BaseViewModel::ComputeTranslucencyType( void ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() ); // See if the local player wants to override the viewmodel's rendering C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer && pPlayer->IsOverridingViewmodel() ) return pPlayer->ComputeTranslucencyType(); C_BaseCombatWeapon *pWeapon = GetOwningWeapon(); if ( pWeapon && pWeapon->IsOverridingViewmodel() ) return pWeapon->ComputeTranslucencyType(); return BaseClass::ComputeTranslucencyType(); }
//----------------------------------------------------------------------------- // Purpose: // Output : int //----------------------------------------------------------------------------- uint8 C_BaseViewModel::OverrideAlphaModulation( uint8 nAlpha ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( GetOwner() ); // See if the local player wants to override the viewmodel's rendering C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer && pPlayer->IsOverridingViewmodel() ) return pPlayer->AlphaProp()->ComputeRenderAlpha(); C_BaseCombatWeapon *pWeapon = GetOwningWeapon(); if ( pWeapon && pWeapon->IsOverridingViewmodel() ) return pWeapon->AlphaProp()->ComputeRenderAlpha(); return nAlpha; }
/* ============================== CAM_ToThirdPerson ============================== */ void CAM_ToThirdPerson(void) { if ( cl_thirdperson.GetBool() == false ) { g_ThirdPersonManager.SetOverridingThirdPerson( true ); } input->CAM_ToThirdPerson(); // Let the local player know C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); if ( localPlayer ) { localPlayer->ThirdPersonSwitch( true ); } }
//----------------------------------------------------------------------------- // Purpose: // Input : bnewentity - //----------------------------------------------------------------------------- void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); CHandle< C_BaseCombatWeapon > handle = this; // If it's being carried by the *local* player, on the first update, // find the registered weapon for this ID C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); C_BaseCombatCharacter *pOwner = GetOwner(); // check if weapon is carried by local player bool bIsLocalPlayer = pPlayer && pPlayer == pOwner; if ( bIsLocalPlayer && !ShouldDrawLocalPlayer() ) { // If I was just picked up, or created & immediately carried, add myself to this client's list of weapons if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) ) { // Tell the HUD this weapon's been picked up if ( ShouldDrawPickup() ) { CBaseHudWeaponSelection *pHudSelection = GetHudWeaponSelection(); if ( pHudSelection ) { pHudSelection->OnWeaponPickup( this ); } pPlayer->EmitSound( "Player.PickupWeapon" ); } } } else // weapon carried by other player or not at all { // BRJ 10/14/02 // FIXME: Remove when Yahn's client-side prediction is done // It's a hacky workaround for the model indices fighting // (GetRenderBounds uses the model index, which is for the view model) SetModelIndex( GetWorldModelIndex() ); } UpdateVisibility(); m_iOldState = m_iState; m_bJustRestored = false; }
//----------------------------------------------------------------------------- // Purpose: Checks if the hud element needs to fade out //----------------------------------------------------------------------------- void CHUDQuickInfo::OnThink() { BaseClass::OnThink(); C_BasePlayer *player = C_BasePlayer::GetLocalPlayer(); if ( player == NULL ) return; // see if we should fade in/out bool bFadeOut = player->IsZoomed(); // check if the state has changed if ( m_bFadedOut != bFadeOut ) { m_bFadedOut = bFadeOut; m_bDimmed = false; /* if ( bFadeOut ) { g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( this, "Alpha", 0.0f, 0.0f, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR ); } else { g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( this, "Alpha", QUICKINFO_BRIGHTNESS_FULL, 0.0f, 0.25f, vgui::AnimationController::INTERPOLATOR_LINEAR ); } */ } else if ( !m_bFadedOut ) { // If we're dormant, fade out if ( EventTimeElapsed() ) { if ( !m_bDimmed ) { m_bDimmed = false; g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( this, "Alpha", QUICKINFO_BRIGHTNESS_DIM, 0.0f, QUICKINFO_FADE_OUT_TIME, vgui::AnimationController::INTERPOLATOR_LINEAR ); } } else if ( m_bDimmed ) { // Fade back up, we're active m_bDimmed = false; g_pClientMode->GetViewportAnimationController()->RunAnimationCommand( this, "Alpha", QUICKINFO_BRIGHTNESS_FULL, 0.0f, QUICKINFO_FADE_IN_TIME, vgui::AnimationController::INTERPOLATOR_LINEAR ); } } }
bool C_BaseViewModel::Interpolate( float currentTime ) { CStudioHdr *pStudioHdr = GetModelPtr(); // Make sure we reset our animation information if we've switch sequences UpdateAnimationParity(); bool bret = BaseClass::Interpolate( currentTime ); // Hack to extrapolate cycle counter for view model float elapsed_time = currentTime - m_flAnimTime; C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); // Predicted viewmodels have fixed up interval if ( GetPredictable() || IsClientCreated() ) { Assert( pPlayer ); float curtime = pPlayer ? pPlayer->GetFinalPredictedTime() : gpGlobals->curtime; elapsed_time = curtime - m_flAnimTime; // Adjust for interpolated partial frame if ( !engine->IsPaused() ) { elapsed_time += ( gpGlobals->interpolation_amount * TICK_INTERVAL ); } } // Prediction errors? if ( elapsed_time < 0 ) { elapsed_time = 0; } float dt = elapsed_time * GetSequenceCycleRate( pStudioHdr, GetSequence() ) * GetPlaybackRate(); if ( dt >= 1.0f ) { if ( !IsSequenceLooping( GetSequence() ) ) { dt = 0.999f; } else { dt = fmod( dt, 1.0f ); } } SetCycle( dt ); return bret; }
void CMoveHelperClient::ProcessImpacts( void ) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return; // Relink in order to build absorigin and absmin/max to reflect any changes // from prediction. Relink will early out on SOLID_NOT // TODO: Touch triggers on the client //pPlayer->PhysicsTouchTriggers(); // Don't bother if the player ain't solid if ( pPlayer->IsSolidFlagSet( FSOLID_NOT_SOLID ) ) return; // Save off the velocity, cause we need to temporarily reset it Vector vel = pPlayer->GetAbsVelocity(); // Touch other objects that were intersected during the movement. for (int i = 0 ; i < m_TouchList.Size(); i++) { // Run the impact function as if we had run it during movement. C_BaseEntity *entity = ClientEntityList().GetEnt( m_TouchList[i].trace.m_pEnt->entindex() ); if ( !entity ) continue; Assert( entity != pPlayer ); // Don't ever collide with self!!!! if ( entity == pPlayer ) continue; // Reconstruct trace results. m_TouchList[i].trace.m_pEnt = entity; // Use the velocity we had when we collided, so boxes will move, etc. pPlayer->SetAbsVelocity( m_TouchList[i].deltavelocity ); entity->PhysicsImpact( pPlayer, m_TouchList[i].trace ); } // Restore the velocity pPlayer->SetAbsVelocity( vel ); // So no stuff is ever left over, sigh... ResetTouchList(); }
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles ) { // Get the entity because the weapon doesn't have the right angles. C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() ); if ( pEnt ) { if ( pEnt == C_BasePlayer::GetLocalPlayer() ) { vAngles = pEnt->EyeAngles(); } else { vAngles = pEnt->GetRenderAngles(); } } else { vAngles.Init(); } QAngle vDummy; if ( IsActiveByLocalPlayer() && ShouldDrawLocalPlayerViewModel() ) { C_BasePlayer *player = ToBasePlayer( pEnt ); C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL; if ( vm ) { int iAttachment = vm->LookupAttachment( "muzzle" ); if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } } else { // Thirdperson int iAttachment = LookupAttachment( "muzzle" ); if ( GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } vOrigin = GetRenderOrigin(); return false; }