//----------------------------------------------------------------------------- // Purpose: Update all deltas that are not expired. //----------------------------------------------------------------------------- void CTextManager::Update( void ) { for ( int i = 0; i < 10; i++ ) { if ( m_aTexts[i].flDieTime < g_CurTime ) continue; sf::Color deltaColor( 255, 15, 15, 255 ); float flLifetimePercent = ( m_aTexts[i].flDieTime - g_CurTime ) / 1.5f; if ( flLifetimePercent < 0.5f ) { deltaColor.a = (char)( 255.0f * ( flLifetimePercent / 0.5 ) ); } if ( !m_aTexts[i].bMinus ) { deltaColor.r = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 255, 30 ); deltaColor.g = (char)RemapValClamped( flLifetimePercent, 0.0f, 1.0f, 30, 255 ); } float flHeight = 50.0f; float flXPos = m_aTexts[i].vecPos.x; float flYPos = m_aTexts[i].vecPos.y - ( 1.0f - flLifetimePercent ) * flHeight; sf::Text newText( m_aTexts[i].text, m_Font ); sf::FloatRect textBounds = newText.getLocalBounds(); newText.setOrigin( textBounds.width / 2.0f, textBounds.height ); newText.setPosition( flXPos, flYPos ); newText.setFillColor( deltaColor ); g_pGameLogic->GetWindow()->draw( newText ); } }
void CLaser::PostRender() const { BaseClass::PostRender(); if (!GameServer()->GetRenderer()->IsRenderingTransparent()) return; if (!m_bShouldRender) return; if (!m_hOwner) return; CRenderingContext r(DigitanksGame()->GetDigitanksRenderer(), true); r.SetBlend(BLEND_ADDITIVE); Vector vecForward, vecRight, vecUp; float flLength = LaserLength(); CDigitank* pOwner = dynamic_cast<CDigitank*>(GetOwner()); Vector vecMuzzle = m_hOwner->GetGlobalOrigin(); Vector vecTarget = vecMuzzle + AngleVector(GetGlobalAngles()) * flLength; if (pOwner) { Vector vecDirection = (pOwner->GetLastAim() - pOwner->GetGlobalOrigin()).Normalized(); vecTarget = vecMuzzle + vecDirection * flLength; AngleVectors(VectorAngles(vecDirection), &vecForward, &vecRight, &vecUp); vecMuzzle = pOwner->GetGlobalOrigin() + vecDirection * 3 + Vector(0, 0, 3); } float flBeamWidth = 1.5; Vector avecRayColors[] = { Vector(1, 0, 0), Vector(0, 1, 0), Vector(0, 0, 1), }; float flRayRamp = RemapValClamped((float)(GameServer()->GetGameTime() - GetSpawnTime()), 0.5f, 1.5f, 0.0f, 1); float flAlphaRamp = RemapValClamped((float)(GameServer()->GetGameTime() - GetSpawnTime()), 1, 2, 1.0f, 0); size_t iBeams = 21; for (size_t i = 0; i < iBeams; i++) { float flUp = RemapVal((float)i, 0, (float)iBeams, -flLength, flLength); Vector vecRay = LerpValue<Vector>(Vector(1, 1, 1), avecRayColors[i%3], flRayRamp); Color clrRay = vecRay; clrRay.SetAlpha((int)(200*flAlphaRamp)); r.SetColor(clrRay); CRopeRenderer rope(DigitanksGame()->GetDigitanksRenderer(), s_hBeam, vecMuzzle, flBeamWidth); rope.SetTextureOffset(((float)i/20) - GameServer()->GetGameTime() - GetSpawnTime()); rope.Finish(vecTarget + vecUp*flUp); } }
Vector CThirdPersonManager::GetDistanceFraction( void ) { if ( IsOverridingThirdPerson() == true ) { return Vector( m_flTargetFraction, m_flTargetFraction, m_flTargetFraction ); } float flFraction = m_flFraction; float flUpFraction = m_flUpFraction; float flFrac = RemapValClamped( gpGlobals->curtime - m_flLerpTime, 0, CAMERA_OFFSET_LERP_TIME, 0, 1 ); flFraction = Lerp( flFrac, m_flFraction, m_flTargetFraction ); if ( flFrac == 1.0f ) { m_flFraction = m_flTargetFraction; } flFrac = RemapValClamped( gpGlobals->curtime - m_flUpLerpTime, 0, CAMERA_UP_OFFSET_LERP_TIME, 0, 1 ); flUpFraction = 1.0f - Lerp( flFrac, m_flUpFraction, m_flTargetUpFraction ); if ( flFrac == 1.0f ) { m_flUpFraction = m_flTargetUpFraction; } return Vector( flFraction, flFraction, flUpFraction ); }
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); }
void CCPU::ModifyContext(class CRenderingContext* pContext) const { BaseClass::ModifyContext(pContext); if (GameServer()->GetGameTime() - m_flConstructionStartTime < 3) { pContext->SetBlend(BLEND_ALPHA); pContext->SetColor(Color(255, 255, 255)); pContext->SetAlpha(GetVisibility() * RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 2.0f, 0.0f, 1.0f)); pContext->Translate(Vector(0, 0, RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 3.0f, -3.0f, 0.0f))); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_PropCombineBall::DrawMotionBlur( void ) { float color[3]; Vector vecDir = GetAbsOrigin() - m_vecLastOrigin; float speed = VectorNormalize( vecDir ); speed = clamp( speed, 0, 32 ); float stepSize = MIN( ( speed * 0.5f ), 4.0f ); Vector spawnPos = GetAbsOrigin(); Vector spawnStep = -vecDir * stepSize; float base = RemapValClamped( speed, 4, 32, 0.0f, 1.0f ); CMatRenderContextPtr pRenderContext( materials ); pRenderContext->Bind( m_pBlurMaterial ); // Draw the motion blurred trail for ( int i = 0; i < 8; i++ ) { spawnPos += spawnStep; color[0] = color[1] = color[2] = base * ( 1.0f - ( (float) i / 12.0f ) ); DrawHalo( m_pBlurMaterial, spawnPos, m_flRadius, color ); } }
void CStatusEffectSkinProxy::OnBind( C_BaseEntity *pEnt ) { float flEffectMagnitude; if (pEnt->IsPlayer() && ToCFPlayer(pEnt)) { C_CFPlayer* pPlayer = ToCFPlayer(pEnt); flEffectMagnitude = pPlayer->m_pStats->GetEffectFromBitmask(STATUSEFFECT_SLOWNESS); } else if (pEnt->IsNPC() && dynamic_cast<C_CFActor*>(pEnt)) { flEffectMagnitude = dynamic_cast<C_CFActor*>(pEnt)->m_flEffectMagnitude; } else return; if (m_pDetailBlend) { float flCurrent = m_pDetailBlend->GetFloatValue(); float flGoal = RemapValClamped(flEffectMagnitude, 0.0f, 1.0f, 0.3f, 1.0f ); if (flEffectMagnitude < 0.01) flGoal = 0.0f; m_pDetailBlend->SetFloatValue( Approach(flGoal, flCurrent, gpGlobals->frametime/10) ); } }
float SparseConvolutionNoise(Vector const &pnt, float (*pNoiseShapeFunction)(float) ) { // computer integer lattice point int ix=LatticeCoord(pnt.x); int iy=LatticeCoord(pnt.y); int iz=LatticeCoord(pnt.z); // compute offsets within unit cube float xfrac=pnt.x-floor(pnt.x); float yfrac=pnt.y-floor(pnt.y); float zfrac=pnt.z-floor(pnt.z); float sum_out=0.; for(int ox=-1; ox<=1; ox++) for(int oy=-1; oy<=1; oy++) for(int oz=-1; oz<=1; oz++) { sum_out += CellNoise( ix+ox, iy+oy, iz+oz, xfrac-ox, yfrac-oy, zfrac-oz, pNoiseShapeFunction ); } #ifdef MEASURE_RANGE fmin1=min(sum_out,fmin1); fmax1=max(sum_out,fmax1); #endif return RemapValClamped( sum_out, .544487, 9.219176, 0.0, 1.0 ); }
//---------------------------------------------------- // Place dust at vector passed in //---------------------------------------------------- void CFourWheelVehiclePhysics::PlaceWheelDust( int wheelIndex, bool ignoreSpeed ) { Vector vecPos, vecVel; m_pVehicle->GetWheelContactPoint( wheelIndex, vecPos ); vecVel.Random( -1.0f, 1.0f ); vecVel.z = random->RandomFloat( 0.3f, 1.0f ); VectorNormalize( vecVel ); // Higher speeds make larger dust clouds float flSize; if ( ignoreSpeed ) { flSize = 1.0f; } else { flSize = RemapValClamped( m_nSpeed, DUST_SPEED, m_flMaxSpeed, 0.0f, 1.0f ); } if ( flSize ) { CEffectData data; data.m_vOrigin = vecPos; data.m_vNormal = vecVel; data.m_flScale = flSize; DispatchEffect( "WheelDust", data ); } }
//----------------------------------------------------------------------------- // Purpose: // Output : inline float //----------------------------------------------------------------------------- inline float C_AlyxEmpEffect::GetStateDurationPercentage( void ) { if ( m_flDuration == 0 ) return 0.0f; return RemapValClamped( ( gpGlobals->curtime - m_flStartTime ), 0, m_flDuration, 0, 1.0f );; }
//----------------------------------------------------------------------------- // Purpose: Handle grenade detonate in-air (even when no ammo is left) //----------------------------------------------------------------------------- void CWeaponAR2::ItemPostFrame( void ) { // See if we need to fire off our secondary round if ( m_bShotDelayed && gpGlobals->curtime > m_flDelayedFire ) { DelayedAttack(); } // Update our pose parameter for the vents CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if ( pOwner ) { CBaseViewModel *pVM = pOwner->GetViewModel(); if ( pVM ) { if ( m_nVentPose == -1 ) { m_nVentPose = pVM->LookupPoseParameter( "VentPoses" ); } float flVentPose = RemapValClamped( m_nShotsFired, 0, 5, 0.0f, 1.0f ); pVM->SetPoseParameter( m_nVentPose, flVentPose ); } } BaseClass::ItemPostFrame(); }
//----------------------------------------------------------------------------- // Purpose: Calculate the FOV for the intro sequence (needed by both server and client) //----------------------------------------------------------------------------- float ScriptInfo_CalculateFOV( float flFOVBlendStartTime, float flNextFOVBlendTime, int nFOV, int nNextFOV, bool bSplineRamp ) { // Handle the spline case if ( bSplineRamp ) { //If we're past the zoom time, just take the new value and stop transitioning float deltaTime = (float)( gpGlobals->curtime - flFOVBlendStartTime ) / ( flNextFOVBlendTime - flFOVBlendStartTime ); if ( deltaTime >= 1.0f ) return nNextFOV; float flResult = SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, (float) nFOV, (float) nNextFOV ); // Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime ); // Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", SimpleSplineRemapVal( deltaTime, 0.0f, 1.0f, nFOV, nNextFOV ), nFOV, nNextFOV, flResult ); return flResult; } // Common, linear blend if ( (flNextFOVBlendTime - flFOVBlendStartTime) != 0 ) { float flResult = RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, (float) nFOV, (float) nNextFOV ); // Msg("FOV BLENDING: curtime %.2f StartedAt %.2f FinishAt: %.2f\n", gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime ); // Msg(" Perc: %.2f Start: %d End: %d FOV: %.2f\n", RemapValClamped( gpGlobals->curtime, flFOVBlendStartTime, flNextFOVBlendTime, 0.0, 1.0 ), nFOV, nNextFOV, flResult ); return flResult; } // Msg("FOV BLENDING: JUMPED TO NEXT FOV (%d)\n", nNextFOV ); return nNextFOV; }
virtual const Vector& GetBulletSpread( void ) { // Handle NPCs first static Vector npcCone = VECTOR_CONE_5DEGREES; if ( GetOwner() && GetOwner()->IsNPC() ) return npcCone; static Vector cone; if ( pistol_use_new_accuracy.GetBool() ) { float ramp = RemapValClamped( m_flAccuracyPenalty, 0.0f, PISTOL_ACCURACY_MAXIMUM_PENALTY_TIME, 0.0f, 1.0f ); // We lerp from very accurate to inaccurate over time VectorLerp( VECTOR_CONE_1DEGREES, VECTOR_CONE_6DEGREES, ramp, cone ); } else { // Old value cone = VECTOR_CONE_4DEGREES; } return cone; }
//----------------------------------------------------------------------------- // Purpose: // Input : pData - // vehicleEyeAngles - //----------------------------------------------------------------------------- void RemapViewAngles( ViewSmoothingData_t *pData, QAngle &vehicleEyeAngles ) { QAngle vecEyeAnglesRemapped; // Clamp pitch. RemapAngleRange_CurvePart_t ePitchCurvePart; vecEyeAnglesRemapped.x = RemapAngleRange( pData->flPitchCurveZero, pData->flPitchCurveLinear, vehicleEyeAngles.x, &ePitchCurvePart ); vehicleEyeAngles.z = vecEyeAnglesRemapped.z = AngleNormalize( vehicleEyeAngles.z ); // Blend out the roll dampening as our pitch approaches 90 degrees, to avoid gimbal lock problems. float flBlendRoll = 1.0; if ( fabs( vehicleEyeAngles.x ) > 60 ) { flBlendRoll = RemapValClamped( fabs( vecEyeAnglesRemapped.x ), 60, 80, 1, 0); } RemapAngleRange_CurvePart_t eRollCurvePart; float flRollDamped = RemapAngleRange( pData->flRollCurveZero, pData->flRollCurveLinear, vecEyeAnglesRemapped.z, &eRollCurvePart ); vecEyeAnglesRemapped.z = Lerp( flBlendRoll, vecEyeAnglesRemapped.z, flRollDamped ); //Msg("PITCH "); vehicleEyeAngles.x = ApplyViewLocking( vehicleEyeAngles.x, vecEyeAnglesRemapped.x, pData->pitchLockData, ePitchCurvePart ); //Msg("ROLL "); vehicleEyeAngles.z = ApplyViewLocking( vehicleEyeAngles.z, vecEyeAnglesRemapped.z, pData->rollLockData, eRollCurvePart ); }
//----------------------------------------------------------------------------- // Purpose: // Output : inline float //----------------------------------------------------------------------------- inline float C_CitadelEnergyCore::GetStateDurationPercentage( void ) { if ( m_flDuration == 0 ) return 0.0f; return RemapValClamped( ( gpGlobals->curtime - m_flStartTime ), 0, m_flDuration, 0, 1.0f );; }
Vector CSDKPlayer::EyePosition() { Vector vecPosition = BaseClass::EyePosition(); bool bIsInThird = false; #ifdef CLIENT_DLL bIsInThird = ::input->CAM_IsThirdPerson(); if (C_SDKPlayer::GetLocalOrSpectatedPlayer() == this && C_SDKPlayer::GetLocalSDKPlayer() != C_SDKPlayer::GetLocalOrSpectatedPlayer()) bIsInThird = false; #endif if (m_Shared.m_flViewBobRamp && m_Shared.m_flRunSpeed && !bIsInThird) { Vector vecRight, vecUp; AngleVectors(EyeAngles(), NULL, &vecRight, &vecUp); float flViewBobMagnitude = m_Shared.m_flViewBobRamp * da_viewbob.GetFloat(); float flRunPeriod = M_PI * 3; float flRunUpBob = sin(GetCurrentTime() * flRunPeriod * 2) * (flViewBobMagnitude / 2); float flRunRightBob = sin(GetCurrentTime() * flRunPeriod) * flViewBobMagnitude; float flWalkPeriod = M_PI * 1.5f; float flWalkUpBob = sin(GetCurrentTime() * flWalkPeriod * 2) * (flViewBobMagnitude / 2); float flWalkRightBob = sin(GetCurrentTime() * flWalkPeriod) * flViewBobMagnitude; #ifdef CLIENT_DLL // It's not filled in for remote clients, so force the local one since it's the same. float flSpeedRatio = C_SDKPlayer::GetLocalSDKPlayer()->m_Shared.m_flAimInSpeed/C_SDKPlayer::GetLocalSDKPlayer()->m_Shared.m_flRunSpeed; #else float flSpeedRatio = m_Shared.m_flAimInSpeed/m_Shared.m_flRunSpeed; #endif // 0 is walk, 1 is run. float flRunRamp = RemapValClamped(m_Shared.m_flViewBobRamp, flSpeedRatio, 1.0f, 0.0f, 1.0f); float flRightBob = RemapValClamped(flRunRamp, 0, 1, flWalkRightBob, flRunRightBob); float flUpBob = RemapValClamped(flRunRamp, 0, 1, flWalkUpBob, flRunUpBob); vecPosition += vecRight * flRightBob + vecUp * flUpBob; } return vecPosition; }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CTFCompoundBow::GetProjectileSpeed( void ) { return RemapValClamped( ( gpGlobals->curtime - m_flChargeBeginTime ), 0.0f, TF_BOW_MAX_CHARGE_TIME, TF_BOW_MIN_CHARGE_VEL, TF_BOW_MAX_CHARGE_VEL ); }
// maps a float to a byte fraction between min & max static byte Fixed8Fraction( float t, float tMin, float tMax ) { if ( tMax <= tMin ) return 0; float frac = RemapValClamped( t, tMin, tMax, 0.0f, 255.0f ); return byte(frac+0.5f); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CTFCompoundBow::GetProjectileGravity( void ) { return RemapValClamped( ( gpGlobals->curtime - m_flChargeBeginTime ), 0.0f, TF_BOW_MAX_CHARGE_TIME, 0.5f, 0.1f ); }
void C_EnvPortalPathTrack::UpdateParticles_Active ( void ) { // Emitters must be valid if ( SetupEmitters() == false ) return; // Reset our sort origin m_pSimpleEmitter->SetSortOrigin( GetAbsOrigin() ); SimpleParticle *sParticle; // Do the charging particles m_pAttractorEmitter->SetAttractorOrigin( GetAbsOrigin() ); Vector forward, right, up; AngleVectors( GetAbsAngles(), &forward, &right, &up ); Vector offset; float dist; int numParticles = floor( 4.0f ); for ( int i = 0; i < numParticles; i++ ) { dist = random->RandomFloat( 4.0f, 64.0f ); offset = forward * dist; dist = RemapValClamped( dist, 4.0f, 64.0f, 6.0f, 1.0f ); offset += right * random->RandomFloat( -4.0f * dist, 4.0f * dist ); offset += up * random->RandomFloat( -4.0f * dist, 4.0f * dist ); offset += GetAbsOrigin(); sParticle = (SimpleParticle *) m_pAttractorEmitter->AddParticle( sizeof(SimpleParticle), m_pAttractorEmitter->GetPMaterial( "effects/strider_muzzle" ), offset ); if ( sParticle == NULL ) return; sParticle->m_vecVelocity = Vector(0,0,8); sParticle->m_flDieTime = 0.5f; sParticle->m_flLifetime = 0.0f; sParticle->m_flRoll = Helper_RandomInt( 0, 360 ); sParticle->m_flRollDelta = 0.0f; float alpha = 255; sParticle->m_uchColor[0] = alpha; sParticle->m_uchColor[1] = alpha; sParticle->m_uchColor[2] = alpha; sParticle->m_uchStartAlpha = alpha; sParticle->m_uchEndAlpha = 0; sParticle->m_uchStartSize = random->RandomFloat( 1, 2 ); sParticle->m_uchEndSize = 0; } }
void CStructure::ModifyContext(class CRenderingContext* pContext) const { BaseClass::ModifyContext(pContext); if (IsConstructing() || IsUpgrading()) { pContext->SetBlend(BLEND_ALPHA); pContext->SetColor(Color(255, 255, 255)); pContext->SetAlpha(GetVisibility() * RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 2.0f, 0.0f, 1.0f)); pContext->Translate(Vector(0, 0, RemapValClamped((float)(GameServer()->GetGameTime() - m_flConstructionStartTime), 0.0f, 3.0f, -3.0f, 0.0f))); } if (GetPlayerOwner()) { pContext->SetUniform("bColorSwapInAlpha", true); pContext->SetUniform("vecColorSwap", GetPlayerOwner()->GetColor()); } }
void CSDKPlayer::DecayStyle() { if (IsStyleSkillActive()) return; float flDecayPerSecond = RemapValClamped(m_flStylePoints, 0, da_stylemeteractivationcost.GetFloat(), da_style_decay_min.GetFloat(), da_style_decay_max.GetFloat()); float flDecayThisFrame = flDecayPerSecond * gpGlobals->frametime * GetSlowMoMultiplier(); m_flStylePoints = Approach(0, m_flStylePoints, flDecayThisFrame); }
void C_SteamJet::RenderParticles( CParticleRenderIterator *pIterator ) { const SteamJetParticle *pParticle = (const SteamJetParticle*)pIterator->GetFirst(); while ( pParticle ) { // Render. Vector tPos; TransformParticle(m_pParticleMgr->GetModelView(), pParticle->m_Pos, tPos); float sortKey = tPos.z; float lifetimeT = pParticle->m_Lifetime / (pParticle->m_DieTime + 0.001); float fRamp = lifetimeT * (STEAMJET_NUMRAMPS-1); int iRamp = (int)fRamp; float fraction = fRamp - iRamp; Vector vRampColor = m_Ramps[iRamp] + (m_Ramps[iRamp+1] - m_Ramps[iRamp]) * fraction; vRampColor[0] = min( 1.0f, vRampColor[0] ); vRampColor[1] = min( 1.0f, vRampColor[1] ); vRampColor[2] = min( 1.0f, vRampColor[2] ); #ifdef GE_DLL // Determine a linear alpha falloff based on our limits float alphamod = 1.0f; float fadetime = gpGlobals->curtime - m_flStartFadeTime; if ( m_bIsForExplosion && fadetime > 0 && m_flStartFadeTime > 0 ) alphamod = RemapValClamped( fadetime, 0, m_flFadeDuration, 1.0f, 0 ); float sinLifetime = sin(pParticle->m_Lifetime * 3.14159f / pParticle->m_DieTime) * alphamod; #else float sinLifetime = sin(pParticle->m_Lifetime * 3.14159f / pParticle->m_DieTime); #endif if ( m_nType == STEAM_HEATWAVE ) { RenderParticle_ColorSizePerturbNormal( pIterator->GetParticleDraw(), tPos, vRampColor, sinLifetime * (m_clrRender->a/255.0f), FLerp(m_StartSize, m_EndSize, pParticle->m_Lifetime)); } else { RenderParticle_ColorSizeAngle( pIterator->GetParticleDraw(), tPos, vRampColor, sinLifetime * (m_clrRender->a/255.0f), FLerp(pParticle->m_uchStartSize, pParticle->m_uchEndSize, pParticle->m_Lifetime), pParticle->m_flRoll ); } pParticle = (const SteamJetParticle*)pIterator->GetNext( sortKey ); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- float CTFCompoundBow::GetProjectileDamage( void ) { float flMaxChargeDamage = BaseClass::GetProjectileDamage(); return RemapValClamped( ( gpGlobals->curtime - m_flChargeBeginTime ), 0.0f, TF_BOW_MAX_CHARGE_TIME, TF_BOW_MIN_CHARGE_DAMAGE, TF_BOW_MIN_CHARGE_DAMAGE + flMaxChargeDamage ); }
float CTFPipebombLauncher::GetProjectileSpeed( void ) { float flForwardSpeed = RemapValClamped( ( gpGlobals->curtime - m_flChargeBeginTime ), 0.0f, TF_PIPEBOMB_MAX_CHARGE_TIME, TF_PIPEBOMB_MIN_CHARGE_VEL, TF_PIPEBOMB_MAX_CHARGE_VEL ); return flForwardSpeed; }
//----------------------------------------------------------------------------- // Purpose: Draw our special effects //----------------------------------------------------------------------------- void C_WeaponStunStick::DrawFirstPersonEffects( void ) { Vector vecOrigin; QAngle vecAngles; float color[3]; float scale; CMatRenderContextPtr pRenderContext( materials ); IMaterial *pMaterial = materials->FindMaterial( STUNSTICK_GLOW_MATERIAL_NOZ, NULL, false ); // FIXME: Needs to work with new IMaterial system! pRenderContext->Bind( pMaterial ); // Find where we are in the fade float fadeAmount = RemapValClamped( gpGlobals->curtime, m_flFadeTime, m_flFadeTime + FADE_DURATION, 1.0f, 0.1f ); // Get bright when swung if ( InSwing() ) { color[0] = color[1] = color[2] = 0.4f; scale = 22.0f; } else { color[0] = color[1] = color[2] = 0.4f * fadeAmount; scale = 20.0f; } if ( color[0] > 0.0f ) { // Draw an all encompassing glow around the entire head UTIL_GetWeaponAttachment( this, m_BeamCenterAttachment, vecOrigin, vecAngles ); DrawHalo( pMaterial, vecOrigin, scale, color ); } // Draw bright points at each attachment location for ( int i = 0; i < (NUM_BEAM_ATTACHMENTS*2)+1; i++ ) { if ( InSwing() ) { color[0] = color[1] = color[2] = random->RandomFloat( 0.05f, 0.5f ); scale = random->RandomFloat( 4.0f, 5.0f ); } else { color[0] = color[1] = color[2] = random->RandomFloat( 0.05f, 0.5f ) * fadeAmount; scale = random->RandomFloat( 4.0f, 5.0f ) * fadeAmount; } if ( color[0] > 0.0f ) { UTIL_GetWeaponAttachment( this, i, vecOrigin, vecAngles ); DrawHalo( pMaterial, vecOrigin, scale, color ); } } }
int C_Ball::DrawModel(int flags) { if (cl_ball_halo_enabled.GetBool()) { float dist = (GetLocalOrigin() - CurrentViewOrigin()).Length(); float sizeCoeff = RemapValClamped(dist, 100.0f, 5000.0f, 0.0f, 1.0f); float alphaCoeff = RemapValClamped(dist, 100.0f, 1000.0f, 0.0f, 1.0f); IMaterial *pMaterial = materials->FindMaterial("sprites/circle", NULL, false); CMatRenderContextPtr pRenderContext(materials); pRenderContext->Bind(pMaterial); color32 color = { 255, 255, 255, (alphaCoeff * 0.5f) * 255 }; float size = 2 * (BALL_PHYS_RADIUS + sizeCoeff * BALL_PHYS_RADIUS * 3.0f); DrawSprite(GetLocalOrigin(), size, size, color); } return BaseClass::DrawModel(flags); }
//----------------------------------------------------------------------------- // Sweep the laser sight towards the point where the gun should be aimed //----------------------------------------------------------------------------- void CNPC_Combine_Cannon::PaintTarget( const Vector &vecTarget, float flPaintTime ) { // vecStart is the barrel of the gun (or the laser sight) Vector vecStart = GetBulletOrigin(); // keep painttime from hitting 0 exactly. flPaintTime = MAX( flPaintTime, 0.000001f ); // Find out where we are in the arc of the paint duration float flPaintPerc = GetWaitTimePercentage( flPaintTime, false ); ScopeGlint(); // Find out where along our line we're painting Vector vecCurrentDir; float flInterp = RemapValClamped( flPaintPerc, 0.0f, 0.5f, 0.0f, 1.0f ); flInterp = clamp( flInterp, 0.0f, 1.0f ); GetPaintAim( m_vecPaintStart, vecTarget, flInterp, &vecCurrentDir ); #define THRESHOLD 0.9f float flNoiseScale; if ( flPaintPerc >= THRESHOLD ) { flNoiseScale = 1 - (1 / (1 - THRESHOLD)) * ( flPaintPerc - THRESHOLD ); } else if ( flPaintPerc <= 1 - THRESHOLD ) { flNoiseScale = flPaintPerc / (1 - THRESHOLD); } else { flNoiseScale = 1; } // mult by P vecCurrentDir.x += flNoiseScale * ( sin( 3 * M_PI * gpGlobals->curtime ) * 0.0006 ); vecCurrentDir.y += flNoiseScale * ( sin( 2 * M_PI * gpGlobals->curtime + 0.5 * M_PI ) * 0.0006 ); vecCurrentDir.z += flNoiseScale * ( sin( 1.5 * M_PI * gpGlobals->curtime + M_PI ) * 0.0006 ); // Find where our center is trace_t tr; UTIL_TraceLine( vecStart, vecStart + vecCurrentDir * 8192, MASK_SHOT, this, COLLISION_GROUP_NONE, &tr ); m_vecPaintCursor = tr.endpos; // Update our beam position m_pBeam->SetEndPos( tr.startpos ); m_pBeam->SetStartPos( tr.endpos ); m_pBeam->SetBrightness( static_cast<int>(255.0f * flPaintPerc) ); m_pBeam->RelinkBeam(); // Find points around that center point and make our designators converge at that point over time UpdateAncillaryBeams( flPaintPerc, vecStart, vecCurrentDir ); }
const Vector CSDKPlayer::CalculateThirdPersonCameraPosition(const Vector& vecEye, const QAngle& angCamera) { float flCamBackIdle = GetUserInfoFloat("da_cam_back"); float flCamUpIdle = GetUserInfoFloat("da_cam_up"); float flCamRightIdle = GetUserInfoFloat("da_cam_right"); float flCamBackAim = GetUserInfoFloat("da_cam_back_aim"); float flCamUpAim = GetUserInfoFloat("da_cam_up_aim"); float flCamRightAim = GetUserInfoFloat("da_cam_right_aim"); float flCamBack = RemapValClamped(Gain(m_Shared.GetAimIn(), 0.8f), 0, 1, flCamBackIdle, flCamBackAim); float flCamUp = RemapValClamped(Gain(m_Shared.GetAimIn(), 0.8f), 0, 1, flCamUpIdle, flCamUpAim); float flCamRight = RemapValClamped(Gain(m_Shared.GetAimIn(), 0.8f), 0, 1, flCamRightIdle, flCamRightAim); m_flSideLerp = Approach(m_bThirdPersonCamSide?1:-1, m_flSideLerp, gpGlobals->frametime*15); flCamRight *= m_flSideLerp; Vector camForward, camRight, camUp; AngleVectors( angCamera, &camForward, &camRight, &camUp ); Vector vecCameraOffset = -camForward*flCamBack + camRight*flCamRight + camUp*flCamUp; m_flStuntLerp = Approach((m_Shared.IsDiving()||m_Shared.IsRolling())?1:0, m_flStuntLerp, gpGlobals->frametime*2); if (m_flStuntLerp) vecCameraOffset += camUp * (m_flStuntLerp * da_cam_stunt_up.GetFloat()); Vector vecNewOrigin = vecEye + vecCameraOffset; trace_t trace; CTraceFilterSimple traceFilter( this, COLLISION_GROUP_NONE ); UTIL_TraceHull( vecEye, vecNewOrigin, Vector(-CAM_HULL_OFFSET, -CAM_HULL_OFFSET, -CAM_HULL_OFFSET), Vector(CAM_HULL_OFFSET, CAM_HULL_OFFSET, CAM_HULL_OFFSET), MASK_VISIBLE|CONTENTS_GRATE, &traceFilter, &trace ); m_flCameraLerp = Approach(trace.fraction, m_flCameraLerp, da_cambacklerp.GetFloat()*gpGlobals->frametime); return vecEye + vecCameraOffset * m_flCameraLerp; }
void CGlowOverlay::CalcSpriteColorAndSize( float flDot, CGlowSprite *pSprite, float *flHorzSize, float *flVertSize, Vector *vColor ) { // The overlay is largest and completely translucent at g_flOverlayRange. // When the dot product is 1, then it's smaller and more opaque. const float flSizeAtOverlayRangeMul = 150; const float flSizeAtOneMul = 70; const float flOpacityAtOverlayRange = 0; const float flOpacityAtOne = 1; // Figure out how big and how opaque it will be. *flHorzSize = RemapValClamped( flDot, g_flOverlayRange, 1, flSizeAtOverlayRangeMul * pSprite->m_flHorzSize, flSizeAtOneMul * pSprite->m_flHorzSize ); *flVertSize = RemapValClamped( flDot, g_flOverlayRange, 1, flSizeAtOverlayRangeMul * pSprite->m_flVertSize, flSizeAtOneMul * pSprite->m_flVertSize ); float flOpacity = RemapValClamped( flDot, g_flOverlayRange, 1, flOpacityAtOverlayRange, flOpacityAtOne ); flOpacity = flOpacity * m_flGlowObstructionScale; *vColor = pSprite->m_vColor * flOpacity; }