void CSDKMapOverview::DrawCamera() { C_BasePlayer *localPlayer = C_BasePlayer::GetLocalPlayer(); if (!localPlayer) return; if( localPlayer->GetObserverMode() == OBS_MODE_ROAMING ) { // Instead of the programmer-art red dot, we'll draw an icon for when our camera is roaming. int alpha = 255; DrawIconSDK(m_cameraIconFree, m_cameraIconFree, localPlayer->GetAbsOrigin(), m_flIconSize * 3.0f, localPlayer->EyeAngles()[YAW], alpha); } else if( localPlayer->GetObserverMode() == OBS_MODE_IN_EYE ) { if( localPlayer->GetObserverTarget() ) { // Fade it if it is on top of a player dot. And don't rotate it. int alpha = 255 * 0.5f; DrawIconSDK(m_cameraIconFirst, m_cameraIconFirst, localPlayer->GetObserverTarget()->GetAbsOrigin(), m_flIconSize * 1.5f, GetViewAngle(), alpha); } } else if( localPlayer->GetObserverMode() == OBS_MODE_CHASE ) { if( localPlayer->GetObserverTarget() ) { // Or Draw the third-camera a little bigger. (Needs room to be off the dot being followed) int alpha = 255; DrawIconSDK(m_cameraIconThird, m_cameraIconThird, localPlayer->GetObserverTarget()->GetAbsOrigin(), m_flIconSize * 3.0f, localPlayer->EyeAngles()[YAW], alpha); } } }
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 C_EnvLightProjectedManager::ClientThink() { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if (!pPlayer) { return; } CUtlVector<int> lightsInRange; CUtlVector<int> lightsNotInRange; int c = m_lights.Count(); for (int i = 0; i < c; i++) { if (!m_lights[i] || !m_lights[i]->IsLightOn()) continue; bool lightInPVS = engine->IsBoxInViewCluster(m_lights[i]->GetAbsOrigin(), m_lights[i]->GetAbsOrigin()); float flDist = (m_lights[i]->GetLightOrigin() - pPlayer->GetAbsOrigin()).LengthSqr(); if (flDist <= Square(m_lights[i]->GetEnableRadius()) && lightInPVS) { lightsInRange.AddToTail(i); } else { lightsNotInRange.AddToTail(i); } } if (lightsInRange.Count() > 0) { int enableLightIndex = GetBestCandidateForShadows(&lightsInRange, &lightsNotInRange); for (int i = 0; i < lightsNotInRange.Count(); i++) { int index = lightsNotInRange[i]; m_lights[index]->SetManagerShadowState(false); } // Turn on The Chosen One m_lights[enableLightIndex]->SetManagerShadowState(true); } SetNextClientThink(gpGlobals->curtime + THINKTIME); }
void CreateHairballCallback() { for ( int i=0; i < 20; i++ ) { C_Hairball *pHairball = new C_Hairball; pHairball->Init(); // Put it a short distance in front of the player. C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pPlayer ) return; Vector vForward; AngleVectors( pPlayer->GetAbsAngles(), &vForward ); pHairball->SetLocalOrigin( pPlayer->GetAbsOrigin() + vForward * 300 + RandomVector( 0, 100 ) ); } }
void C_WeaponSpawner::ClientThink() { m_qAngle.y += 90 * gpGlobals->frametime; if ( m_qAngle.y >= 360 ) m_qAngle.y -= 360; SetAbsAngles( m_qAngle ); C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); bool bShouldGlow = false; bool bTouchingPlayer = false; if ( pPlayer ) { Vector vecPlayerOrigin = pPlayer->GetAbsOrigin(); Vector vecPlayerMins = vecPlayerOrigin + pPlayer->GetPlayerMins(); Vector vecPlayerMaxs = vecPlayerOrigin + pPlayer->GetPlayerMaxs(); bTouchingPlayer = IsBoxIntersectingBox( GetAbsOrigin() + WorldAlignMins(), GetAbsOrigin() + WorldAlignMaxs(), vecPlayerMins, vecPlayerMaxs ); // Disable the outline if the weapon has been picked up. if ( !m_bRespawning && !m_bDisabled ) { // Temp crutch for Occluded\Unoccluded glow parameters not working. trace_t tr; UTIL_TraceLine( GetAbsOrigin(), pPlayer->EyePosition(), MASK_OPAQUE, this, COLLISION_GROUP_NONE, &tr ); if ( tr.fraction == 1.0f ) { bShouldGlow = true; } } } if ( m_bShouldGlow != bShouldGlow || m_bTouchingPlayer != bTouchingPlayer ) { m_bShouldGlow = bShouldGlow; m_bTouchingPlayer = bTouchingPlayer; UpdateGlowEffect(); } SetNextClientThink( CLIENT_THINK_ALWAYS ); }
void C_HLTVCamera::CalcInEyeCamView( Vector& eyeOrigin, QAngle& eyeAngles, float& fov ) { C_BasePlayer *pPlayer = UTIL_PlayerByIndex( m_iTraget1 ); if ( !pPlayer ) return; if ( !pPlayer->IsAlive() ) { // if dead, show from 3rd person CalcChaseCamView( eyeOrigin, eyeAngles, fov ); return; } m_aCamAngle = pPlayer->EyeAngles(); m_vCamOrigin = pPlayer->GetAbsOrigin(); m_flFOV = pPlayer->GetFOV(); if ( pPlayer->GetFlags() & FL_DUCKING ) { m_vCamOrigin += VEC_DUCK_VIEW; } else { m_vCamOrigin += VEC_VIEW; } eyeOrigin = m_vCamOrigin; eyeAngles = m_aCamAngle; fov = m_flFOV; pPlayer->CalcViewModelView( eyeOrigin, eyeAngles); C_BaseViewModel *pViewModel = pPlayer->GetViewModel( 0 ); if ( pViewModel ) { Assert( pViewModel->GetOwner() == pPlayer ); pViewModel->UpdateVisibility(); } }
static void GetPos( const CCommand &args, Vector &vecOrigin, QAngle &angles ) { int nSlot = GET_ACTIVE_SPLITSCREEN_SLOT(); vecOrigin = MainViewOrigin(nSlot); angles = MainViewAngles(nSlot); #ifdef INFESTED_DLL C_ASW_Marine *pMarine = C_ASW_Marine::GetLocalMarine(); if ( pMarine ) { vecOrigin = pMarine->GetAbsOrigin(); angles = pMarine->GetAbsAngles(); } #endif if ( ( args.ArgC() == 2 && atoi( args[1] ) == 2 ) || FStrEq( args[0], "getpos_exact" ) ) { C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); if ( pPlayer ) { vecOrigin = pPlayer->GetAbsOrigin(); angles = pPlayer->GetAbsAngles(); } } }
void CRagdollLRURetirement::Update( float frametime ) // EPISODIC VERSION { VPROF( "CRagdollLRURetirement::Update" ); // Compress out dead items int i, next; int iMaxRagdollCount = m_iMaxRagdolls; if ( iMaxRagdollCount == -1 ) { iMaxRagdollCount = g_ragdoll_maxcount.GetInt(); } // fade them all for the low violence version if ( g_RagdollLVManager.IsLowViolence() ) { iMaxRagdollCount = 0; } m_iRagdollCount = 0; m_iSimulatedRagdollCount = 0; // First, find ragdolls that are good candidates for deletion because they are not // visible at all, or are in a culled visibility box for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { next = m_LRU.Next(i); CBaseAnimating *pRagdoll = m_LRU[i].Get(); if ( pRagdoll ) { m_iRagdollCount++; IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if (pObject && !pObject->IsAsleep()) { m_iSimulatedRagdollCount++; } if ( m_LRU.Count() > iMaxRagdollCount ) { //Found one, we're done. if ( ShouldRemoveThisRagdoll( m_LRU[i] ) == true ) { #ifdef CLIENT_DLL m_LRU[ i ]->SUB_Remove(); #else m_LRU[ i ]->SUB_StartFadeOut( 0 ); #endif m_LRU.Remove(i); return; } } } else { m_LRU.Remove(i); } } ////////////////////////////// /// EPISODIC ALGORITHM /// ////////////////////////////// // If we get here, it means we couldn't find a suitable ragdoll to remove, // so just remove the furthest one. int furthestOne = m_LRU.Head(); float furthestDistSq = 0; #ifdef CLIENT_DLL C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer(); #else CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); #endif if (pPlayer && m_LRU.Count() > iMaxRagdollCount) // find the furthest one algorithm { Vector PlayerOrigin = pPlayer->GetAbsOrigin(); // const CBasePlayer *pPlayer = UTIL_GetLocalPlayer(); for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { CBaseAnimating *pRagdoll = m_LRU[i].Get(); next = m_LRU.Next(i); IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) continue; if ( pRagdoll ) { // float distToPlayer = (pPlayer->GetAbsOrigin() - pRagdoll->GetAbsOrigin()).LengthSqr(); float distToPlayer = (PlayerOrigin - pRagdoll->GetAbsOrigin()).LengthSqr(); if (distToPlayer > furthestDistSq) { furthestOne = i; furthestDistSq = distToPlayer; } } else // delete bad rags first. { furthestOne = i; break; } } #ifdef CLIENT_DLL m_LRU[ furthestOne ]->SUB_Remove(); #else m_LRU[ furthestOne ]->SUB_StartFadeOut( 0 ); #endif } else // fall back on old-style pick the oldest one algorithm { for ( i = m_LRU.Head(); i < m_LRU.InvalidIndex(); i = next ) { if ( m_LRU.Count() <= iMaxRagdollCount ) break; next = m_LRU.Next(i); CBaseAnimating *pRagdoll = m_LRU[i].Get(); //Just ignore it until we're done burning/dissolving. IPhysicsObject *pObject = pRagdoll->VPhysicsGetObject(); if ( pRagdoll && (pRagdoll->GetEffectEntity() || ( pObject && !pObject->IsAsleep()) ) ) continue; #ifdef CLIENT_DLL m_LRU[ i ]->SUB_Remove(); #else m_LRU[ i ]->SUB_StartFadeOut( 0 ); #endif m_LRU.Remove(i); } } }
void CGERadar::WorldToRadar( CGERadarContact *contact ) { // If we are out of range don't bother if ( !IsContactInRange( contact ) ) return; C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer(); if ( !pLocalPlayer ) return; Vector vContact = GetContactPosition(contact); float x_diff = vContact.x - pLocalPlayer->GetAbsOrigin().x; float y_diff = vContact.y - pLocalPlayer->GetAbsOrigin().y; // Supply epsilon values to avoid divide-by-zero if(x_diff == 0.0f ) x_diff = 0.001f; if(y_diff == 0.0f ) y_diff = 0.001f; float fRadarRadius = m_flRadarDiameter * 0.500f; float fRange = GetRadarRange(); float fScale = fRange >= 1.000f ? fRadarRadius / fRange : 0.000f; float dist = min( GetContactRange( vContact ), fRange ); float flOffset = atan(y_diff/x_diff); float flPlayerY; // If we're in first person spectate mode we should use the rotation of whoever we're spectating. if (pLocalPlayer->IsObserver() && pLocalPlayer->GetObserverTarget() && pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE) flPlayerY = (pLocalPlayer->GetLocalAngles().y * M_PI) * 0.0055555f; else flPlayerY = (pLocalPlayer->LocalEyeAngles().y * M_PI) * 0.0055555f; // Always add because atan will return neg angle w/ neg coeff if ( x_diff < 0 ) flOffset += M_PI; else flOffset += M_TWOPI; flOffset = flPlayerY - flOffset; // Transform relative to radar source float xnew_diff = dist * sin(flOffset); float ynew_diff = -dist * cos(flOffset); // Scale the dot's position to match radar scale xnew_diff *= fScale; ynew_diff *= fScale; // Make sure we never leave our radar circle! contact->m_vScaledPos.x = fRadarRadius + xnew_diff + m_iSideBuff; contact->m_vScaledPos.y = fRadarRadius + ynew_diff + m_iSideBuff; contact->m_vScaledPos.z = vContact.z - pLocalPlayer->GetAbsOrigin().z; // Figure out our alpha modulation if ( !contact->m_bAlwaysVisible && dist > fRange * 0.8f ) contact->m_flAlphaMod = RemapValClamped( dist, fRange * 0.8f, fRange, 1.0, 0 ); else contact->m_flAlphaMod = 1.0f; }