int C_Camera::GetCamMode() { C_SDKPlayer *pLocal = C_SDKPlayer::GetLocalSDKPlayer(); if (!pLocal) return CAM_MODE_ROAMING; if (GetReplayManager() && GetReplayManager()->IsReplaying()) { return CAM_MODE_TVCAM; } else if (GetMatchBall() && GetMatchBall()->m_eBallState == BALL_STATE_GOAL || SDKGameRules()->State_Get() == MATCH_PERIOD_PENALTIES) { if (pLocal->IsObserver() || pLocal->GetFlags() & FL_USE_TV_CAM) return CAM_MODE_TVCAM; else return CAM_MODE_FREE_CHASE; } else { if (pLocal->IsObserver()) return m_nCamMode; else return CAM_MODE_FREE_CHASE; } }
Vector2D CHudAmmo::GetRoundPosition(int i) { int iWidth, iHeight; GetSize(iWidth, iHeight); float flScale = 480.0f/(float)iHeight * hud_ammoscale.GetFloat(); float flRightPadding = scheme()->GetProportionalScaledValueEx(GetScheme(), 40); float flBottomPadding = scheme()->GetProportionalScaledValueEx(GetScheme(), 40); CHudTexture* pTexture = GetTexture(); if ( !pTexture ) return Vector2D(iWidth - flRightPadding*flScale, iHeight - flBottomPadding*flScale); C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); float flSpacing = scheme()->GetProportionalScaledValueEx(GetScheme(), 10*flScale); int iMaxClip = pPlayer->GetActiveSDKWeapon()->GetMaxClip1(); float flTotalWidth = (GetTextureDrawWidth(pTexture, flScale) + flSpacing) * iMaxClip; float flTotalSpace = scheme()->GetProportionalScaledValueEx(GetScheme(), 420*flScale); if (flTotalWidth > flTotalSpace) flSpacing = -scheme()->GetProportionalScaledValueEx(GetScheme(), 5)*flScale; if (flSpacing < 0) { if (i%2 == 0) return Vector2D(iWidth - (i+1)*GetTextureDrawWidth(pTexture, flScale) - i*flSpacing - flRightPadding*flScale, iHeight - GetTextureDrawHeight(pTexture, flScale) - (flBottomPadding+10)*flScale); else return Vector2D(iWidth - (i+1)*GetTextureDrawWidth(pTexture, flScale) - i*flSpacing - flRightPadding*flScale, iHeight - GetTextureDrawHeight(pTexture, flScale) - flBottomPadding*flScale); } else return Vector2D(iWidth - (i+1)*GetTextureDrawWidth(pTexture, flScale) - i*flSpacing - flRightPadding*flScale, iHeight - GetTextureDrawHeight(pTexture, flScale) - flBottomPadding*flScale); }
int ClientModeSDKNormal::HandleSpectatorKeyInput( int down, ButtonCode_t keynum, const char *pszCurrentBinding ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (pPlayer && pPlayer->GetTeamNumber() != TEAM_SPECTATOR) { // Override base class for +attack, it respawns us. if ( down && pszCurrentBinding && Q_strcmp( pszCurrentBinding, "+attack" ) == 0 ) return 1; } // Default binding is +alt1 on the right mouse. Have this switch players. if ( down && pszCurrentBinding && Q_strcmp( pszCurrentBinding, "+alt1" ) == 0 ) { if (pPlayer && pPlayer->GetTeamNumber() != TEAM_SPECTATOR) engine->ClientCmd( "spec_prev" ); else engine->ClientCmd( "spec_next" ); return 0; } // Can't figure out how to get +duck to send a close signal too, so let's just not use the spec menu. if ( down && pszCurrentBinding && Q_strcmp( pszCurrentBinding, "+duck" ) == 0 ) return 0; return BaseClass::HandleSpectatorKeyInput(down, keynum, pszCurrentBinding); }
void CSDKSpectatorGUI::Paint() { BaseClass::Paint(); C_SDKPlayer* pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer(); C_SDKPlayer* pObserved = pLocalPlayer?ToSDKPlayer(pLocalPlayer->GetObserverTarget()):NULL; if (pObserved && SDKGameRules()->CoderHacks()) { std::wstring sButtons = L"Buttons:"; // If either of these guy trip up it means the button list has been changed and s_apszButtons needs to be updated. Assert(IN_ATTACK3 == (1<<25)); Assert(std::wstring(s_apszButtons[25]) == std::wstring(L"IN_ATTACK3")); int iCount = sizeof(s_apszButtons)/sizeof(wchar_t*); for (int i = 0; i < iCount; i++) { if (pObserved->GetCoderHacksButtons() & (1<<i)) { sButtons += L" "; sButtons += s_apszButtons[i]; } } surface()->DrawSetTextPos( GetWide()/4, GetTall()/2 ); surface()->DrawSetTextColor( Color(255, 255, 255, 255) ); surface()->DrawSetTextFont( vgui::scheme()->GetIScheme(vgui::scheme()->GetScheme( "ClientScheme" ))->GetFont( "Default" ) ); //reset the font, draw icon can change it surface()->DrawUnicodeString( sButtons.c_str(), vgui::FONT_DRAW_NONADDITIVE ); } }
void ClientModeSDKNormal::OverrideMouseInput( float *x, float *y ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer) return; float flSlowMultiplier = RemapValClamped(pPlayer->GetSlowMoMultiplier(), 0.4f, 1, m_slowmodamping.GetFloat(), 1); *x *= flSlowMultiplier; *y *= flSlowMultiplier; *y *= m_verticaldamping.GetFloat(); C_WeaponSDKBase* pWeapon = pPlayer->GetActiveSDKWeapon(); if (pWeapon) { float flAimInMultiplier; if (pWeapon->HasAimInSpeedPenalty()) flAimInMultiplier = RemapValClamped(pPlayer->m_Shared.GetAimIn(), 0, 1, 1, m_aimindamping.GetFloat()); else flAimInMultiplier = RemapValClamped(pPlayer->m_Shared.GetAimIn(), 0, 1, 1, m_partialaimindamping.GetFloat()); *x *= flAimInMultiplier; *y *= flAimInMultiplier; } BaseClass::OverrideMouseInput(x, y); }
bool CModHudElement::ShouldDraw() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return false; if ( pPlayer->State_Get() != STATE_ACTIVE ) return false; if ( m_bLevelStarted ) { if ( GameRules()->GetGameModeMask() & m_iGamemodes ) { return BaseClass::ShouldDraw(); } else { return false; } } else if ( !( g_ModHudManager.GetEnabledHudElementMask() & GetElementMask() ) && g_ModHudManager.GetEnabledHudElementMask() != HUDELEM_ALL ) { return false; } else if ( g_ModHudManager.GetEnabledHudElementMask() & GetElementMask() && g_ModHudManager.GetEnabledHudElementMask() != HUDELEM_ALL ) { return true; } return BaseClass::ShouldDraw(); }
void __MsgFunc_ReloadEffect( bf_read &msg ) { int iPlayer = msg.ReadShort(); C_SDKPlayer *pPlayer = dynamic_cast< C_SDKPlayer* >( C_BaseEntity::Instance( iPlayer ) ); if ( pPlayer ) pPlayer->PlayReloadEffect(); }
void C_Camera::CalcHawkEyeView(Vector& eyeOrigin, QAngle& eyeAngles, float& fov) { C_SDKPlayer *pLocal = C_SDKPlayer::GetLocalSDKPlayer(); eyeOrigin = SDKGameRules()->m_vKickOff; eyeOrigin.z += 500; eyeOrigin.y += pLocal->GetTeam()->m_nForward * ((SDKGameRules()->m_vFieldMax.GetY() - SDKGameRules()->m_vFieldMin.GetY()) * (1.0f / 8.0f)); }
C_BaseEntity *CHUDBlockHealth::ProcessTarget( void ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return NULL; // Get our target's ent index int iEntIndex = pPlayer->GetIDTarget(); // Didn't find one? if ( !iEntIndex ) { // Check to see if we should clear our ID if ( m_flLastChangeTime && (gpGlobals->curtime > (m_flLastChangeTime + 0.5)) ) { m_flLastChangeTime = 0; m_iLastEntIndex = 0; m_bBlockInTarget = false; } else { // Keep re-using the old one iEntIndex = m_iLastEntIndex; } } else { m_flLastChangeTime = gpGlobals->curtime; } if ( iEntIndex ) { // set up the vectors and traceline trace_t tr; Vector vecStart, vecStop, vecDir; // get the angles AngleVectors( pPlayer->EyeAngles(), &vecDir ); // get the vectors vecStart = pPlayer->EyePosition(); vecStop = vecStart + vecDir * BLOCK_HINT_DISTANCE; // do the traceline UTIL_TraceLine( vecStart, vecStop, MASK_ALL, pPlayer, COLLISION_GROUP_NPC, &tr ); C_BaseEntity *pEntity = tr.m_pEnt; // check to see if we found a block if ( !pEntity ) return NULL; return pEntity; } return NULL; }
void __MsgFunc_LessonLearned( bf_read &msg ) { char szString[256]; msg.ReadString(szString, sizeof(szString)); C_SDKPlayer* pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); pPlayer->Instructor_LessonLearned(szString); }
virtual void PostDataUpdate( DataUpdateType_t updateType ) { // Create the effect. C_SDKPlayer *pPlayer = dynamic_cast< C_SDKPlayer* >( m_hPlayer.Get() ); if ( pPlayer && !pPlayer->IsDormant() ) { pPlayer->DoAnimationEvent( (PlayerAnimEvent_t)m_iEvent.Get() ); } }
bool CHudCapPoints::ShouldDraw( void ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return false; if ( pPlayer->State_Get() != STATE_ACTIVE ) return false; return CModHudElement::ShouldDraw(); }
bool CSDKPlayer::LessonPriorityLess::Less( const LessonPointer& lhs, const LessonPointer& rhs, void *pCtx ) { C_SDKPlayer* pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); CInstructor* pInstructor = pPlayer->GetInstructor(); //if (pPlayer->m_flLastEnemySeen && gpGlobals->curtime < pPlayer->m_flLastEnemySeen + 3 && lhs->m_bPreferNoEnemies != rhs->m_bPreferNoEnemies) // return !lhs->m_bPreferNoEnemies; return ( pInstructor->GetLesson(lhs->m_sLessonName)->m_iPriority < pInstructor->GetLesson(rhs->m_sLessonName)->m_iPriority ); }
void CC_ResetLessons() { da_instructor_lessons_learned.SetValue(""); C_SDKPlayer* pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer) return; pPlayer->Instructor_Initialize(); pPlayer->Instructor_Reset(); }
void CSpectatorMenu::FireGameEvent( IGameEvent * event ) { if (!Q_strcmp("spec_target_updated", event->GetName())) { IGameResources *gr = GameResources(); if ( !gr ) return; // make sure the player combo box is up to date int playernum; // make sure the player combo box is up to date int targetIndex; if (Camera()->GetTarget()) targetIndex = Camera()->GetTarget()->entindex(); else targetIndex = 0; // If ball is spec target if (targetIndex > gpGlobals->maxClients) { m_pTargetList->ActivateItemByRow(0); } else if (targetIndex >= 1 && targetIndex <= gpGlobals->maxClients) { for (int i = 0; i < m_pTargetList->GetMenu()->GetItemCount(); i++) { if (m_pTargetList->GetMenu()->GetItemUserData(i)->GetInt("index") == targetIndex) { m_pTargetList->GetMenu()->ActivateItemByRow(i); break; } } } } else if (!Q_strcmp("cam_mode_updated", event->GetName())) { m_pCamModes->SetText(g_szCamModeNames[Camera()->GetCamMode()]); m_pTVCamModes->SetVisible(Camera()->GetCamMode() == CAM_MODE_TVCAM); } else if (!Q_strcmp("tvcam_mode_updated", event->GetName())) { m_pTVCamModes->SetText(g_szTVCamModeNames[Camera()->GetTVCamMode()]); } else if (!Q_strcmp("player_team", event->GetName())) { C_SDKPlayer *pLocal = C_SDKPlayer::GetLocalSDKPlayer(); if (!pLocal || pLocal->GetUserID() == event->GetInt("userid")) { SetVisible(event->GetInt("newteam") == TEAM_SPECTATOR); } } }
void CSDKPlayer::DoMuzzleFlash() { #ifdef CLIENT_DLL if (prediction->InPrediction() && !prediction->IsFirstTimePredicted()) return; C_SDKPlayer* pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer(); C_WeaponSDKBase* pActiveWeapon = GetActiveSDKWeapon(); if (pLocalPlayer) { if (pLocalPlayer == this && !::input->CAM_IsThirdPerson() || pLocalPlayer->GetObserverMode() == OBS_MODE_IN_EYE && pLocalPlayer->GetObserverTarget() == this) { for ( int i = 0; i < MAX_VIEWMODELS; i++ ) { CBaseViewModel *vm = GetViewModel( i ); if ( !vm ) continue; vm->DoMuzzleFlash(); } } else if (pActiveWeapon) { // Force world model so the attachments work. pActiveWeapon->SetModelIndex( pActiveWeapon->GetWorldModelIndex() ); switch (pActiveWeapon->GetWeaponType()) { case WT_PISTOL: default: pActiveWeapon->ParticleProp()->Create( "muzzleflash_pistol", PATTACH_POINT_FOLLOW, "muzzle" ); break; case WT_SMG: pActiveWeapon->ParticleProp()->Create( "muzzleflash_smg", PATTACH_POINT_FOLLOW, "muzzle" ); break; case WT_RIFLE: pActiveWeapon->ParticleProp()->Create( "muzzleflash_rifle", PATTACH_POINT_FOLLOW, "muzzle" ); break; case WT_SHOTGUN: pActiveWeapon->ParticleProp()->Create( "muzzleflash_shotgun", PATTACH_POINT_FOLLOW, "muzzle" ); break; } } } #endif }
//----------------------------------------------------------------------------- // Purpose: Save CPU cycles by letting the HUD system early cull // costly traversal. Called per frame, return true if thinking and // painting need to occur. //----------------------------------------------------------------------------- bool CHudChargedshotBar::ShouldDraw() { if (!CHudElement::ShouldDraw()) return false; C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer || pPlayer->GetTeamNumber() != TEAM_A && pPlayer->GetTeamNumber() != TEAM_B) return false; if (GetReplayManager() && GetReplayManager()->IsReplaying()) return false; return true; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CSDKHudArmor::OnThink( void ) { int newArmor = 0; C_SDKPlayer *local = C_SDKPlayer::GetLocalSDKPlayer(); if ( local ) { // Never below zero newArmor = MAX( local->GetArmorValue(), 0 ); } if ( m_iArmor == newArmor ) return; if ( !newArmor ) { GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("SuitPowerZero"); } else if ( newArmor < m_iArmor ) { // battery power has decreased, so play the damaged animation GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("SuitDamageTaken"); // play an extra animation if we're super low if ( newArmor < 20 ) { GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("SuitArmorLow"); } } else { // battery power has increased (if we had no previous armor, or if we just loaded the game, don't use alert state) if ( m_iArmor == INIT_ARMOR || m_iArmor == 0 || newArmor >= 20) { GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("SuitPowerIncreasedAbove20"); } else { GetClientMode()->GetViewportAnimationController()->StartAnimationSequence("SuitPowerIncreasedBelow20"); } } m_iArmor = newArmor; //Tony; moved down to fix localization crash at load, update the label name and armor value when it changes. //TODO (Nican): Find where to define text. const wchar_t *text = g_pVGuiLocalize->Find("#SDK_HudArmor"); if( text ) SetLabelText(text); SetDisplayValue(m_iArmor); }
bool CFolderMenu::IsLoadoutComplete() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer) return false; if (!pPlayer->HasCharacterBeenChosen()) return false; if (pPlayer->m_Shared.m_iStyleSkill == SKILL_NONE) return false; return true; }
bool ClientModeSDKNormal::CanRecordDemo( char *errorMsg, int length ) const { C_SDKPlayer *player = C_SDKPlayer::GetLocalSDKPlayer(); if ( !player ) { return true; } if ( !player->IsAlive() ) { return true; } return true; }
bool CSDKMapOverview::ShouldDraw( void ) { //Tony; don't draw the map unless it's a spectator - you could turn this into a radar if you wanted by using the other modes! C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (!pPlayer) return false; if ( pPlayer->GetTeamNumber() != TEAM_SPECTATOR ) return false; int alpha = GetMasterAlpha(); if( alpha == 0 ) return false;// we have been set to fully transparent return BaseClass::ShouldDraw(); }
void CDAHudCrosshair::Paint( void ) { if ( !m_pCrosshair ) return; if ( !IsCurrentViewAccessAllowed() ) return; m_curViewAngles = CurrentViewAngles(); m_curViewOrigin = CurrentViewOrigin(); float x, y; x = ScreenWidth()/2; y = ScreenHeight()/2; bool bObstruction = false; C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (pPlayer && pPlayer->IsInThirdPerson() && m_pObstructionCrosshair) { Vector vecCamera = pPlayer->GetThirdPersonCameraPosition(); Vector vecForward = pPlayer->GetThirdPersonCameraTarget() - pPlayer->Weapon_ShootPosition(); // Now trace to see where the player will hit trace_t tr2; UTIL_TraceLine( pPlayer->Weapon_ShootPosition(), pPlayer->Weapon_ShootPosition() + vecForward * 1000, MASK_SOLID|CONTENTS_DEBRIS|CONTENTS_HITBOX, pPlayer, COLLISION_GROUP_NONE, &tr2 ); //DebugDrawLine(vecCamera, tr.endpos, 255, 0, 0, true, 0.1f); //DebugDrawLine(pPlayer->Weapon_ShootPosition(), tr2.endpos, 0, 0, 255, true, 0.1f); if ((tr2.endpos - pPlayer->GetThirdPersonCameraTarget()).LengthSqr() > 1) { bObstruction = true; Vector vecScreen; ScreenTransform( tr2.endpos, vecScreen ); float x2, y2; x2 = ScreenWidth()/2 + 0.5 * vecScreen.x * ScreenWidth() + 0.5; y2 = ScreenHeight()/2 - 0.5 * vecScreen.y * ScreenHeight() + 0.5; m_pObstructionCrosshair->DrawSelf( x2 - 0.5f * m_pObstructionCrosshair->Width(), y2 - 0.5f * m_pObstructionCrosshair->Height(), m_clrCrosshair ); } } m_pCrosshair->DrawSelf( x - 0.5f * m_pCrosshair->Width(), y - 0.5f * m_pCrosshair->Height(), bObstruction?Color(128, 128, 128, m_clrCrosshair.a()/2):m_clrCrosshair ); }
void CInstructor::DisplayLesson(const CUtlString& sLesson) { if (!lesson_enable.GetBool()) return; if (!m_bActive) return; if (sLesson.Length() == 0 || m_apLessons.Find(sLesson) == -1) { int iLesson = m_apLessons.Find(m_sCurrentLesson); if (m_apLessons[iLesson] && m_apLessons[iLesson]->m_bKillOnFinish) SetActive(false); HideLesson(); return; } HideLesson(); m_sCurrentLesson = sLesson; m_sLastLesson = m_sCurrentLesson; CLesson* pLesson = m_apLessons[m_apLessons.Find(sLesson)]; C_SDKPlayer *pLocalPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if (pLesson->m_iLearningMethod == CLesson::LEARN_DISPLAYING) pLocalPlayer->Instructor_LessonLearned(sLesson); pLocalPlayer->Instructor_LessonShowed(sLesson); int iLessonTrainings = pLocalPlayer->Instructor_GetLessonTrainings(sLesson); if (pLesson->m_sSideHintText.Length() && iLessonTrainings == 0) { CHudElement* pLessonPanel = gHUD.FindElement("CHudSideHintPanel"); static_cast<CHudSideHintPanel*>(pLessonPanel)->SetLesson(pLesson); m_bSideHintShowing = true; } else { CHudElement* pLessonPanel = gHUD.FindElement("CHudLessonPanel"); static_cast<CHudLessonPanel*>(pLessonPanel)->SetLesson(pLesson); } }
//----------------------------------------------------------------------------- // Purpose: Paints the damage display //----------------------------------------------------------------------------- void CHudDamageIndicator::Paint() { if( m_flFadeCompleteTime > gpGlobals->curtime ) { float flFade = gpGlobals->frametime * 2; C_SDKPlayer* pLocal = C_SDKPlayer::GetLocalSDKPlayer(); if (pLocal) flFade *= pLocal->GetSlowMoMultiplier(); // draw damage indicators DrawDamageIndicatorFront( flFade ); DrawDamageIndicatorRear( flFade ); DrawDamageIndicatorLeft( flFade ); DrawDamageIndicatorRight( flFade ); } }
bool CHUDBlockHealth::ShouldDraw( void ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return false; if ( pPlayer->State_Get() != STATE_ACTIVE ) return false; // Make sure they're holding one of the physcannons if ( Q_strcmp( pPlayer->GetActiveWeapon()->GetName(), "weapon_lf_build_cannon" ) && Q_strcmp( pPlayer->GetActiveWeapon()->GetName(), "weapon_lf_combat_cannon" ) ) { return false; } return CModHudElement::ShouldDraw(); }
bool CSDKSpectatorGUI::NeedsUpdate( void ) { C_SDKPlayer *player = C_SDKPlayer::GetLocalSDKPlayer(); if ( !player ) return false; if ( m_nLastTime != (int)SDKGameRules()->GetMapRemainingTime() ) return true; if ( m_nLastSpecMode != player->GetObserverMode() ) return true; if ( m_nLastSpecTarget != player->GetObserverTarget() ) return true; return BaseClass::NeedsUpdate(); }
void CHudStyleBar::OnThink() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; float flStyle = pPlayer->GetStylePoints(); m_flGoalStyle = flStyle; m_flCurrentStyle = Approach(m_flGoalStyle, m_flCurrentStyle, RemapValClamped(fabs((float)m_flGoalStyle-m_flCurrentStyle), 0, 10, gpGlobals->frametime*10, gpGlobals->frametime*100)); int iNext; for (int i = m_aAnnouncements.Head(); i != m_aAnnouncements.InvalidIndex(); i = iNext) { iNext = m_aAnnouncements.Next( i ); if (gpGlobals->curtime > m_aAnnouncements[i].m_flStartTime + hud_announcementtime.GetFloat()) m_aAnnouncements.Remove(i); } }
// CODE DUPLICATION BELOW. FIXME! C_BaseEntity *ProcessTarget() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return NULL; // Get our target's ent index int iEntIndex = pPlayer->GetIDTarget(); // Didn't find one? if ( !iEntIndex ) { return NULL; } if ( iEntIndex ) { // set up the vectors and traceline trace_t tr; Vector vecStart, vecStop, vecDir; // get the angles AngleVectors( pPlayer->EyeAngles( ), &vecDir ); // get the vectors vecStart = pPlayer->EyePosition(); vecStop = vecStart + vecDir * 1024; // do the traceline UTIL_TraceLine( vecStart, vecStop, MASK_ALL, pPlayer, COLLISION_GROUP_NPC, &tr ); C_BaseEntity *pEntity = tr.m_pEnt; // check to see if we found a block if ( !pEntity ) return NULL; return pEntity; } return NULL; }
void CDAHudCrosshair::CalculateCrosshair( void ) { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; CWeaponSDKBase *pWeapon = pPlayer->GetActiveSDKWeapon(); if (!pWeapon) { ResetCrosshair(); return; } if ( !pWeapon->ShouldDrawCrosshair() ) { ResetCrosshair(); return; } Color clrHUD = Color( 200, 200, 200, 255 ); clrHUD[3] = 255; Color white( 255, 255, 255, 255 ); if ( pPlayer->m_Shared.GetAimIn() <= 0.5f || !pWeapon->HasAimInRecoilBonus() ) { if ( pWeapon->GetWpnData().iconCrosshair ) SetCrosshair( pWeapon->GetWpnData().iconCrosshair, clrHUD ); else ResetCrosshair(); } else { // zoomed crosshairs if ( pWeapon->GetWpnData().iconZoomedCrosshair ) SetCrosshair( pWeapon->GetWpnData().iconZoomedCrosshair, white ); else if ( pWeapon->GetWpnData().iconCrosshair ) SetCrosshair( pWeapon->GetWpnData().iconCrosshair, clrHUD ); else ResetCrosshair(); } }
bool CSDKSpectatorGUI::NeedsUpdate( void ) { C_SDKPlayer *player = C_SDKPlayer::GetLocalSDKPlayer(); if ( !player ) return false; //if ( m_nLastTime != (int)ClassicGameRules()->GetPhaseTime()) // return true; if (m_nLastPhaseID != ClassicGameRules()->GetCurrentPhaseID ()) return true; if ( m_nLastSpecMode != player->GetObserverMode() ) return true; if ( m_nLastSpecTarget != player->GetObserverTarget() ) return true; return BaseClass::NeedsUpdate(); }