//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponMedigun::ClientThink() { C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); if ( !pLocalPlayer ) return; // Don't show it while the player is dead. Ideally, we'd respond to m_bHealing in OnDataChanged, // but it stops sending the weapon when it's holstered, and it gets holstered when the player dies. CTFPlayer *pFiringPlayer = ToTFPlayer( GetOwnerEntity() ); if ( !pFiringPlayer || pFiringPlayer->IsPlayerDead() || pFiringPlayer->IsDormant() ) { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_NEVER ); m_bPlayingSound = false; StopHealSound(); return; } // If the local player is the guy getting healed, let him know // who's healing him, and their charge level. if( m_hHealingTarget != NULL ) { if ( pLocalPlayer == m_hHealingTarget ) { pLocalPlayer->SetHealer( pFiringPlayer, m_flChargeLevel ); } if ( !m_bPlayingSound ) { m_bPlayingSound = true; CLocalPlayerFilter filter; EmitSound( filter, entindex(), "WeaponMedigun.Healing" ); } } if ( m_bOldChargeRelease != m_bChargeRelease ) { m_bOldChargeRelease = m_bChargeRelease; ForceHealingTargetUpdate(); } }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void CWeaponMedigun::UpdateEffects( void ) { CTFPlayer *pFiringPlayer = ToTFPlayer( GetOwnerEntity() ); if ( !pFiringPlayer ) return; C_TFPlayer *pLocalPlayer = C_TFPlayer::GetLocalTFPlayer(); C_BaseEntity *pEffectOwner = this; if ( pLocalPlayer == pFiringPlayer ) { pEffectOwner = pLocalPlayer->GetViewModel(); if ( !pEffectOwner ) return; } // Remove all the effects if ( pEffectOwner ) { pEffectOwner->ParticleProp()->StopEmission( m_hHealingTargetEffect.pEffect ); } else { m_hHealingTargetEffect.pEffect->StopEmission(); } m_hHealingTargetEffect.pTarget = NULL; m_hHealingTargetEffect.pEffect = NULL; // Don't add targets if the medic is dead if ( !pEffectOwner || pFiringPlayer->IsPlayerDead() || !pFiringPlayer->IsPlayerClass( TF_CLASS_MEDIC ) ) return; // Add our targets // Loops through the healing targets, and make sure we have an effect for each of them if ( m_hHealingTarget ) { if ( m_hHealingTargetEffect.pTarget == m_hHealingTarget ) return; const char *pszEffectName; if (m_bChargeRelease) { switch (GetTeamNumber()) { case TF_TEAM_BLUE: pszEffectName = "medicgun_beam_blue_invun"; break; case TF_TEAM_RED: pszEffectName = "medicgun_beam_red_invun"; break; case TF_TEAM_GREEN: pszEffectName = "medicgun_beam_green_invun"; break; case TF_TEAM_YELLOW: pszEffectName = "medicgun_beam_yellow_invun"; break; default: pszEffectName = "medicgun_beam_blue"; break; } } else { switch (GetTeamNumber()) { case TF_TEAM_BLUE: pszEffectName = "medicgun_beam_blue"; break; case TF_TEAM_RED: pszEffectName = "medicgun_beam_red"; break; case TF_TEAM_GREEN: pszEffectName = "medicgun_beam_green"; break; case TF_TEAM_YELLOW: pszEffectName = "medicgun_beam_yellow"; break; default: pszEffectName = "medicgun_beam_blue"; break; } } CNewParticleEffect *pEffect = pEffectOwner->ParticleProp()->Create( pszEffectName, PATTACH_POINT_FOLLOW, "muzzle" ); pEffectOwner->ParticleProp()->AddControlPoint( pEffect, 1, m_hHealingTarget, PATTACH_ABSORIGIN_FOLLOW, NULL, Vector(0,0,50) ); m_hHealingTargetEffect.pTarget = m_hHealingTarget; m_hHealingTargetEffect.pEffect = pEffect; } }