//----------------------------------------------------------------------------- // Purpose: // Output : Returns true on success, false on failure. //----------------------------------------------------------------------------- bool C_BaseCombatWeapon::ShouldDraw( void ) { if ( m_iWorldModelIndex == 0 ) { return false; } // carried by player? if ( IsCarriedByLocalPlayer() ) { // Only ever show the active weapon if ( !IsActiveByLocalPlayer() ) return false; // Don't show it if it's the view model and we're in firstperson if (input->CAM_IsThirdPerson() == false) return false; return true; } // If it's a player, then only show active weapons if ( GetOwner() && GetOwner()->IsPlayer() ) { // Show it if it's active... return (m_iState == WEAPON_IS_ACTIVE); } // FIXME: We may want to only show active weapons on NPCs // These are carried by AIs; always show them return true; }
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles ) { // Get the entity because the weapon doesn't have the right angles. C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() ); if ( pEnt ) { if ( pEnt == C_BasePlayer::GetLocalPlayer() ) { vAngles = pEnt->EyeAngles(); } else { vAngles = pEnt->GetRenderAngles(); } } else { vAngles.Init(); } C_BasePlayer *player = ToBasePlayer( pEnt ); bool bUseViewModel = false; if ( C_BasePlayer::IsLocalPlayer( pEnt ) ) { ACTIVE_SPLITSCREEN_PLAYER_GUARD_ENT( pEnt ); bUseViewModel = !player->ShouldDrawLocalPlayer(); } QAngle vDummy; if ( IsActiveByLocalPlayer() && bUseViewModel ) { C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL; if ( vm ) { int iAttachment = vm->LookupAttachment( "muzzle" ); if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } } else { // Thirdperson int iAttachment = LookupAttachment( "muzzle" ); if ( GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } vOrigin = GetRenderOrigin(); return false; }
bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles ) { // Get the entity because the weapon doesn't have the right angles. C_BaseCombatCharacter *pEnt = ToBaseCombatCharacter( GetOwner() ); if ( pEnt ) { if ( pEnt == C_BasePlayer::GetLocalPlayer() ) { vAngles = pEnt->EyeAngles(); } else { vAngles = pEnt->GetRenderAngles(); } } else { vAngles.Init(); } QAngle vDummy; if ( IsActiveByLocalPlayer() && !input->CAM_IsThirdPerson() ) { C_BasePlayer *player = ToBasePlayer( pEnt ); C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL; if ( vm ) { int iAttachment = vm->LookupAttachment( "muzzle" ); if ( vm->GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } } else { // Thirdperson int iAttachment = LookupAttachment( "muzzle" ); if ( GetAttachment( iAttachment, vOrigin, vDummy ) ) { return true; } } vOrigin = GetRenderOrigin(); return false; }
//----------------------------------------------------------------------------- // Purpose: // Input : updateType - //----------------------------------------------------------------------------- void CWeaponMedigun::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged( updateType ); if ( m_bUpdateHealingTargets ) { UpdateEffects(); m_bUpdateHealingTargets = false; } // Think? if ( m_bHealing ) { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_ALWAYS ); } else { ClientThinkList()->SetNextClientThink( GetClientHandle(), CLIENT_THINK_NEVER ); m_bPlayingSound = false; StopHealSound( true, false ); // Are they holding the attack button but not healing anyone? Give feedback. if ( IsActiveByLocalPlayer() && GetOwner() && GetOwner()->IsAlive() && m_bAttacking && GetOwner() == C_BasePlayer::GetLocalPlayer() && CanAttack() == true ) { if ( gpGlobals->curtime >= m_flNextBuzzTime ) { CLocalPlayerFilter filter; EmitSound( filter, entindex(), "WeaponMedigun.NoTarget" ); m_flNextBuzzTime = gpGlobals->curtime + 0.5f; // only buzz every so often. } } else { StopHealSound( false, true ); // Stop the "no target" sound. } } ManageChargeEffect(); }
//----------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------- void C_WeaponMortar::OnDataChanged( DataUpdateType_t updateType ) { BaseClass::OnDataChanged(updateType); // If the mortar's being carried by some other player, don't make a ground line if ( !IsCarriedByLocalPlayer() ) return; // Draw power chart if the mortar is deployed if ( !m_bCarried && !m_bMortarReloading ) { vgui::Panel *pParent = GetClientModeNormal()->GetViewport(); int parentWidth, parentHeight; pParent->GetSize(parentWidth, parentHeight); int iWidth = 256; int iHeight = 40; int iX = (parentWidth - iWidth) / 2; int iY = (parentHeight - 200); // Only show the power bar if the mortar's the active weapon if ( IsActiveByLocalPlayer() ) { m_pPowerBar->SetBounds( iX, iY, iWidth, iHeight ); m_pPowerBar->SetParent(pParent); } else { m_pPowerBar->SetParent( (vgui::Panel *)NULL ); } if ( !m_bRotating && m_flPrevMortarServerYaw != m_vecMortarAngles.y ) { m_flMortarYaw = m_vecMortarAngles.y; } // Create the Ground lines if ( !m_pGroundLine ) { m_pGroundLine = new CGroundLine(); m_pGroundLine->Init( "player/support/mortarline" ); } if ( !m_pDarkLine ) { m_pDarkLine = new CGroundLine(); m_pDarkLine->Init( "player/support/mortarline" ); } } else { m_pPowerBar->SetParent( (vgui::Panel *)NULL ); if ( m_pGroundLine ) { delete m_pGroundLine; m_pGroundLine = NULL; } if ( m_pDarkLine ) { delete m_pDarkLine; m_pDarkLine = NULL; } } }