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; } }
//----------------------------------------------------------------------------- // Purpose: draws the stamina bar //----------------------------------------------------------------------------- void CHudChargedshotBar::Paint() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; float stamina = pPlayer->m_Shared.GetStamina(); float relStamina = stamina / 100.0f; Color bgColor; if (pPlayer->GetFlags() & FL_REMOTECONTROLLED) bgColor = Color(255, 255, 255, 255); else bgColor = Color(255 * (1 - relStamina), 255 * relStamina, 0, 255); float shotStrength; bool drawChargedshotIndicator = false; if (pPlayer->m_Shared.m_bDoChargedShot || pPlayer->m_Shared.m_bIsShotCharging) { float currentTime = pPlayer->GetFinalPredictedTime(); currentTime -= TICK_INTERVAL; currentTime += (gpGlobals->interpolation_amount * TICK_INTERVAL); float duration = (pPlayer->m_Shared.m_bIsShotCharging ? currentTime - pPlayer->m_Shared.m_flShotChargingStart : pPlayer->m_Shared.m_flShotChargingDuration); float totalTime = currentTime - pPlayer->m_Shared.m_flShotChargingStart; float activeTime = min(duration, mp_chargedshot_increaseduration.GetFloat()); float extra = totalTime - activeTime; float increaseFraction = clamp(pow(activeTime / mp_chargedshot_increaseduration.GetFloat(), mp_chargedshot_increaseexponent.GetFloat()), 0, 1); float decTime = (pow(1 - increaseFraction, 1.0f / mp_chargedshot_decreaseexponent.GetFloat())) * mp_chargedshot_decreaseduration.GetFloat(); float decreaseFraction = clamp((decTime + extra) / mp_chargedshot_decreaseduration.GetFloat(), 0, 1); shotStrength = 1 - pow(decreaseFraction, mp_chargedshot_decreaseexponent.GetFloat()); // Flash if (shotStrength > 0.95f) { relStamina = 1; bgColor = Color(255, 255, 255, 255); } drawChargedshotIndicator = true; } // Draw stamina bar back surface()->DrawSetColor(0, 0, 0, 255); surface()->DrawFilledRect(BAR_HMARGIN, BAR_VMARGIN, BAR_HMARGIN + BAR_WIDTH, BAR_VMARGIN + BAR_HEIGHT); // Draw stamina bar front surface()->DrawSetColor(bgColor); surface()->DrawFilledRect( BAR_HMARGIN + BAR_HPADDING, BAR_VMARGIN + BAR_VPADDING + (1 - relStamina) * (BAR_HEIGHT - 2 * BAR_VPADDING), BAR_HMARGIN + BAR_WIDTH - BAR_HPADDING, BAR_VMARGIN + BAR_VPADDING + BAR_HEIGHT - 2 * BAR_VPADDING); const int partCount = 4; int vMargin = BAR_HEIGHT / partCount; surface()->DrawSetColor(0, 0, 0, 255); for (int i = 1; i < partCount; i++) { surface()->DrawFilledRect(BAR_HMARGIN, BAR_VMARGIN + i * vMargin, BAR_HMARGIN + BAR_WIDTH, BAR_VMARGIN + i * vMargin + 1); } if (drawChargedshotIndicator) { // Draw chargedshot indicator back surface()->DrawSetColor(0, 0, 0, 255); surface()->DrawFilledRect( BAR_HMARGIN - PS_INDICATOR_OFFSET, BAR_VMARGIN + (1 - shotStrength) * (BAR_HEIGHT - PS_INDICATOR_HEIGHT), BAR_HMARGIN + BAR_WIDTH + PS_INDICATOR_OFFSET, BAR_VMARGIN + (1 - shotStrength) * (BAR_HEIGHT - PS_INDICATOR_HEIGHT) + PS_INDICATOR_HEIGHT); // Draw chargedshot indicator front surface()->DrawSetColor(255, 255, 255, 255); surface()->DrawFilledRect( BAR_HMARGIN - PS_INDICATOR_OFFSET + PS_INDICATOR_BORDER, BAR_VMARGIN + (1 - shotStrength) * (BAR_HEIGHT - PS_INDICATOR_HEIGHT) + PS_INDICATOR_BORDER, BAR_HMARGIN + BAR_WIDTH + PS_INDICATOR_OFFSET - PS_INDICATOR_BORDER, BAR_VMARGIN + (1 - shotStrength) * (BAR_HEIGHT - PS_INDICATOR_HEIGHT) + PS_INDICATOR_HEIGHT - PS_INDICATOR_BORDER); } }
//----------------------------------------------------------------------------- // Purpose: draws the stamina bar //----------------------------------------------------------------------------- void CHudChargedshotBar::Paint() { C_SDKPlayer *pPlayer = C_SDKPlayer::GetLocalSDKPlayer(); if ( !pPlayer ) return; if (!SDKGameRules()) return; float stamina = pPlayer->m_Shared.GetStamina() / 100.0f; Color staminaFgColor = g_ColorOrange; Color staminaBorderColor = Color(0, 0, 0, 255); Color staminaBgColor = Color(33, 33, 33, 255); // Draw shot bar border surface()->DrawSetColor(staminaBorderColor); surface()->DrawFilledRect( ScreenWidth() / 2 - STAMINABAR_WIDTH / 2 - STAMINABAR_BORDER, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - 2 * STAMINABAR_BORDER, ScreenWidth() / 2 - STAMINABAR_WIDTH / 2 - STAMINABAR_BORDER + STAMINABAR_WIDTH + 2 * STAMINABAR_BORDER, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - 2 * STAMINABAR_BORDER + STAMINABAR_HEIGHT + 2 * STAMINABAR_BORDER ); // Draw shot bar background surface()->DrawSetColor(staminaBgColor); surface()->DrawFilledRect( ScreenWidth() / 2 - STAMINABAR_WIDTH / 2, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER, ScreenWidth() / 2 + STAMINABAR_WIDTH / 2, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER + STAMINABAR_HEIGHT ); // Draw shot bar front surface()->DrawSetColor(staminaFgColor); surface()->DrawFilledRect( ScreenWidth() / 2 - STAMINABAR_WIDTH / 2, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER, ScreenWidth() / 2 - STAMINABAR_WIDTH / 2 + stamina * STAMINABAR_WIDTH, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER + STAMINABAR_HEIGHT ); surface()->DrawSetColor(staminaBorderColor); for (int i = 1; i <= 3; i++) { surface()->DrawFilledRect( ScreenWidth() / 2 - STAMINABAR_WIDTH / 2 + i * 0.25f * STAMINABAR_WIDTH - 1, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER, ScreenWidth() / 2 - STAMINABAR_WIDTH / 2 + i * 0.25f * STAMINABAR_WIDTH + 1, ScreenHeight() - STAMINABAR_VMARGIN - STAMINABAR_HEIGHT - STAMINABAR_BORDER + STAMINABAR_HEIGHT ); } Color shotFgColor; Color shotBorderColor = Color(0, 0, 0, 255); Color shotBgColor = Color(33, 33, 33, 255); bool shotBlocked = true; if (pPlayer->GetFlags() & FL_REMOTECONTROLLED) shotFgColor = g_ColorBrown; else if (pPlayer->m_bShotsBlocked) shotFgColor = g_ColorRed; else if (pPlayer->m_bChargedshotBlocked) shotFgColor = g_ColorOrange; else { shotFgColor = g_ColorLightBlue; shotBlocked = false; } float shotStrength = shotBlocked ? 1.0f : pPlayer->GetChargedShotStrength(); // Draw shot bar border surface()->DrawSetColor(shotBorderColor); surface()->DrawFilledRect( ScreenWidth() / 2 - SHOTBAR_WIDTH / 2 - SHOTBAR_BORDER, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - 2 * SHOTBAR_BORDER, ScreenWidth() / 2 - SHOTBAR_WIDTH / 2 - SHOTBAR_BORDER + SHOTBAR_WIDTH + 2 * SHOTBAR_BORDER, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - 2 * SHOTBAR_BORDER + SHOTBAR_HEIGHT + 2 * SHOTBAR_BORDER ); // Draw shot bar background surface()->DrawSetColor(shotBgColor); surface()->DrawFilledRect( ScreenWidth() / 2 - SHOTBAR_WIDTH / 2, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER, ScreenWidth() / 2 + SHOTBAR_WIDTH / 2, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER + SHOTBAR_HEIGHT ); // Draw shot bar front surface()->DrawSetColor(shotFgColor); surface()->DrawFilledRect( ScreenWidth() / 2 - SHOTBAR_WIDTH / 2, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER, ScreenWidth() / 2 - SHOTBAR_WIDTH / 2 + shotStrength * SHOTBAR_WIDTH, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER + SHOTBAR_HEIGHT ); surface()->DrawSetColor(shotBorderColor); for (int i = 1; i <= 3; i++) { surface()->DrawFilledRect( ScreenWidth() / 2 - SHOTBAR_WIDTH / 2 + i * 0.25f * SHOTBAR_WIDTH - 1, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER, ScreenWidth() / 2 - SHOTBAR_WIDTH / 2 + i * 0.25f * SHOTBAR_WIDTH + 1, ScreenHeight() - SHOTBAR_VMARGIN - SHOTBAR_HEIGHT - SHOTBAR_BORDER + SHOTBAR_HEIGHT ); } }