mirror of
https://github.com/celisej567/source-engine.git
synced 2026-01-05 22:09:59 +03:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright <20> 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Client side implementation of CBaseCombatWeapon.
|
||||
//
|
||||
@@ -20,26 +20,13 @@
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Gets the local client's active weapon, if any.
|
||||
//-----------------------------------------------------------------------------
|
||||
C_BaseCombatWeapon *GetActiveWeapon( void )
|
||||
{
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
if ( !player )
|
||||
return NULL;
|
||||
|
||||
return player->GetActiveWeapon();
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::SetDormant( bool bDormant )
|
||||
{
|
||||
// If I'm going from active to dormant and I'm carried by another player, holster me.
|
||||
if ( !IsDormant() && bDormant && GetOwner() && !IsCarriedByLocalPlayer() )
|
||||
if ( !IsDormant() && bDormant && !IsCarriedByLocalPlayer() )
|
||||
{
|
||||
Holster( NULL );
|
||||
}
|
||||
@@ -75,16 +62,13 @@ void C_BaseCombatWeapon::NotifyShouldTransmit( ShouldTransmitState_t state )
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: To wrap PORTAL mod specific functionality into one place
|
||||
//-----------------------------------------------------------------------------
|
||||
static inline bool ShouldDrawLocalPlayerViewModel( void )
|
||||
|
||||
static inline bool ShouldDrawLocalPlayer( C_BasePlayer *pl )
|
||||
{
|
||||
#if defined( PORTAL )
|
||||
return false;
|
||||
#else
|
||||
return !C_BasePlayer::ShouldDrawLocalPlayer();
|
||||
#endif
|
||||
|
||||
Assert( pl );
|
||||
return pl->ShouldDrawLocalPlayer();
|
||||
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -96,7 +80,7 @@ void C_BaseCombatWeapon::OnRestore()
|
||||
|
||||
// if the player is holding this weapon,
|
||||
// mark it as just restored so it won't show as a new pickup
|
||||
if (GetOwner() == C_BasePlayer::GetLocalPlayer())
|
||||
if ( C_BasePlayer::IsLocalPlayer( GetOwner() ) )
|
||||
{
|
||||
m_bJustRestored = true;
|
||||
}
|
||||
@@ -104,17 +88,6 @@ void C_BaseCombatWeapon::OnRestore()
|
||||
|
||||
int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
||||
{
|
||||
if ( GameRules() )
|
||||
{
|
||||
const char *pBaseName = modelinfo->GetModelName( modelinfo->GetModel( m_iWorldModelIndex ) );
|
||||
const char *pTranslatedName = GameRules()->TranslateEffectForVisionFilter( "weapons", pBaseName );
|
||||
|
||||
if ( pTranslatedName != pBaseName )
|
||||
{
|
||||
return modelinfo->GetModelIndex( pTranslatedName );
|
||||
}
|
||||
}
|
||||
|
||||
return m_iWorldModelIndex;
|
||||
}
|
||||
|
||||
@@ -124,22 +97,23 @@ int C_BaseCombatWeapon::GetWorldModelIndex( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
|
||||
{
|
||||
BaseClass::OnDataChanged(updateType);
|
||||
|
||||
CHandle< C_BaseCombatWeapon > handle = this;
|
||||
BaseClass::OnDataChanged( updateType );
|
||||
|
||||
// If it's being carried by the *local* player, on the first update,
|
||||
// find the registered weapon for this ID
|
||||
|
||||
C_BasePlayer *pPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
C_BaseCombatCharacter *pOwner = GetOwner();
|
||||
C_BasePlayer *pPlayer = ToBasePlayer( pOwner );
|
||||
|
||||
// check if weapon is carried by local player
|
||||
bool bIsLocalPlayer = pPlayer && pPlayer == pOwner;
|
||||
if ( bIsLocalPlayer && ShouldDrawLocalPlayerViewModel() ) // TODO: figure out the purpose of the ShouldDrawLocalPlayer() test.
|
||||
bool bIsLocalPlayer = C_BasePlayer::IsLocalPlayer( pPlayer );
|
||||
if ( bIsLocalPlayer )
|
||||
{
|
||||
ACTIVE_SPLITSCREEN_PLAYER_GUARD( C_BasePlayer::GetSplitScreenSlotForPlayer( pPlayer ) );
|
||||
|
||||
// If I was just picked up, or created & immediately carried, add myself to this client's list of weapons
|
||||
if ( (m_iState != WEAPON_NOT_CARRIED ) && (m_iOldState == WEAPON_NOT_CARRIED) )
|
||||
if ( ( m_iState != WEAPON_NOT_CARRIED ) &&
|
||||
( m_iOldState == WEAPON_NOT_CARRIED ) )
|
||||
{
|
||||
// Tell the HUD this weapon's been picked up
|
||||
if ( ShouldDrawPickup() )
|
||||
@@ -154,15 +128,7 @@ void C_BaseCombatWeapon::OnDataChanged( DataUpdateType_t updateType )
|
||||
}
|
||||
}
|
||||
}
|
||||
else // weapon carried by other player or not at all
|
||||
{
|
||||
int overrideModelIndex = CalcOverrideModelIndex();
|
||||
if( overrideModelIndex != -1 && overrideModelIndex != GetModelIndex() )
|
||||
{
|
||||
SetModelIndex( overrideModelIndex );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
UpdateVisibility();
|
||||
|
||||
m_iOldState = m_iState;
|
||||
@@ -200,10 +166,10 @@ ShadowType_t C_BaseCombatWeapon::ShadowCastType()
|
||||
if (!IsBeingCarried())
|
||||
return SHADOWS_RENDER_TO_TEXTURE;
|
||||
|
||||
if (IsCarriedByLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer())
|
||||
if (IsCarriedByLocalPlayer())
|
||||
return SHADOWS_NONE;
|
||||
|
||||
return SHADOWS_RENDER_TO_TEXTURE;
|
||||
return (m_iState != WEAPON_IS_CARRIED_BY_PLAYER) ? SHADOWS_RENDER_TO_TEXTURE : SHADOWS_NONE;
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -212,24 +178,24 @@ ShadowType_t C_BaseCombatWeapon::ShadowCastType()
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::Redraw()
|
||||
{
|
||||
if ( g_pClientMode->ShouldDrawCrosshair() )
|
||||
if ( GetClientMode()->ShouldDrawCrosshair() )
|
||||
{
|
||||
DrawCrosshair();
|
||||
}
|
||||
|
||||
// ammo drawing has been moved into hud_ammo.cpp
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Draw the weapon's crosshair
|
||||
//-----------------------------------------------------------------------------
|
||||
void C_BaseCombatWeapon::DrawCrosshair()
|
||||
{
|
||||
#ifndef INFESTED_DLL
|
||||
C_BasePlayer *player = C_BasePlayer::GetLocalPlayer();
|
||||
if ( !player )
|
||||
return;
|
||||
|
||||
Color clr = gHUD.m_clrNormal;
|
||||
Color clr = GetHud().m_clrNormal;
|
||||
/*
|
||||
|
||||
// TEST: if the thing under your crosshair is on a different team, light the crosshair with a different color.
|
||||
@@ -263,7 +229,7 @@ void C_BaseCombatWeapon::DrawCrosshair()
|
||||
return;
|
||||
|
||||
// Find out if this weapon's auto-aimed onto a target
|
||||
bool bOnTarget = ( m_iState == WEAPON_IS_ONTARGET );
|
||||
bool bOnTarget = ( m_iState == WEAPON_IS_ACTIVE ) && player->m_fOnTarget;
|
||||
|
||||
if ( player->GetFOV() >= 90 )
|
||||
{
|
||||
@@ -296,8 +262,8 @@ void C_BaseCombatWeapon::DrawCrosshair()
|
||||
else
|
||||
crosshair->ResetCrosshair();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: This weapon is the active weapon, and the viewmodel for it was just drawn.
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -313,20 +279,9 @@ bool C_BaseCombatWeapon::IsCarriedByLocalPlayer( void )
|
||||
if ( !GetOwner() )
|
||||
return false;
|
||||
|
||||
return ( GetOwner() == C_BasePlayer::GetLocalPlayer() );
|
||||
return ( C_BasePlayer::IsLocalPlayer( GetOwner() ) );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this client is carrying this weapon and is
|
||||
// using the view models
|
||||
//-----------------------------------------------------------------------------
|
||||
bool C_BaseCombatWeapon::ShouldDrawUsingViewModel( void )
|
||||
{
|
||||
return IsCarriedByLocalPlayer() && !C_BasePlayer::ShouldDrawLocalPlayer();
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Returns true if this weapon is the local client's currently wielded weapon
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -360,10 +315,17 @@ bool C_BaseCombatWeapon::GetShootPosition( Vector &vOrigin, QAngle &vAngles )
|
||||
vAngles.Init();
|
||||
}
|
||||
|
||||
QAngle vDummy;
|
||||
if ( IsActiveByLocalPlayer() && ShouldDrawLocalPlayerViewModel() )
|
||||
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_BasePlayer *player = ToBasePlayer( pEnt );
|
||||
C_BaseViewModel *vm = player ? player->GetViewModel( 0 ) : NULL;
|
||||
if ( vm )
|
||||
{
|
||||
@@ -411,7 +373,6 @@ bool C_BaseCombatWeapon::ShouldDraw( void )
|
||||
return true;
|
||||
|
||||
bool bIsActive = ( m_iState == WEAPON_IS_ACTIVE );
|
||||
|
||||
C_BasePlayer *pLocalPlayer = C_BasePlayer::GetLocalPlayer();
|
||||
|
||||
// carried by local player?
|
||||
@@ -421,15 +382,8 @@ bool C_BaseCombatWeapon::ShouldDraw( void )
|
||||
if ( !bIsActive )
|
||||
return false;
|
||||
|
||||
if ( !pOwner->ShouldDraw() )
|
||||
{
|
||||
// Our owner is invisible.
|
||||
// This also tests whether the player is zoomed in, in which case you don't want to draw the weapon.
|
||||
return false;
|
||||
}
|
||||
|
||||
// 3rd person mode?
|
||||
if ( !ShouldDrawLocalPlayerViewModel() )
|
||||
// 3rd person mode
|
||||
if ( pLocalPlayer->ShouldDrawLocalPlayer() )
|
||||
return true;
|
||||
|
||||
// don't draw active weapon if not in some kind of 3rd person mode, the viewmodel will do that
|
||||
@@ -462,11 +416,40 @@ bool C_BaseCombatWeapon::ShouldDrawPickup( void )
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// Hooks into the fast path render system
|
||||
//----------------------------------------------------------------------------
|
||||
IClientModelRenderable* C_BaseCombatWeapon::GetClientModelRenderable()
|
||||
{
|
||||
if ( !m_bReadyToDraw )
|
||||
return 0;
|
||||
|
||||
// check if local player chases owner of this weapon in first person
|
||||
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( localplayer && localplayer->IsObserver() && GetOwner() )
|
||||
{
|
||||
// don't draw weapon if chasing this guy as spectator
|
||||
// we don't check that in ShouldDraw() since this may change
|
||||
// without notification
|
||||
if ( localplayer->GetObserverMode() == OBS_MODE_IN_EYE &&
|
||||
localplayer->GetObserverTarget() == GetOwner() )
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ( !BaseClass::GetClientModelRenderable() )
|
||||
return NULL;
|
||||
|
||||
EnsureCorrectRenderingModel();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Purpose: Render the weapon. Draw the Viewmodel if the weapon's being carried
|
||||
// by this player, otherwise draw the worldmodel.
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseCombatWeapon::DrawModel( int flags )
|
||||
int C_BaseCombatWeapon::DrawModel( int flags, const RenderableInstance_t &instance )
|
||||
{
|
||||
VPROF_BUDGET( "C_BaseCombatWeapon::DrawModel", VPROF_BUDGETGROUP_MODEL_RENDERING );
|
||||
if ( !m_bReadyToDraw )
|
||||
@@ -489,32 +472,40 @@ int C_BaseCombatWeapon::DrawModel( int flags )
|
||||
return false;
|
||||
}
|
||||
|
||||
return BaseClass::DrawModel( flags );
|
||||
// See comment below
|
||||
EnsureCorrectRenderingModel();
|
||||
|
||||
return BaseClass::DrawModel( flags, instance );
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Allows the client-side entity to override what the network tells it to use for
|
||||
// a model. This is used for third person mode, specifically in HL2 where the
|
||||
// the weapon timings are on the view model and not the world model. That means the
|
||||
// server needs to use the view model, but the client wants to use the world model.
|
||||
//-----------------------------------------------------------------------------
|
||||
int C_BaseCombatWeapon::CalcOverrideModelIndex()
|
||||
{
|
||||
// If the local player is visible (thirdperson mode, tf2 taunts, etc., then make sure that we are using the
|
||||
// w_ (world) model not the v_ (view) model or else the model can flicker, etc.
|
||||
// Otherwise, if we're not the local player, always use the world model
|
||||
void C_BaseCombatWeapon::EnsureCorrectRenderingModel()
|
||||
{
|
||||
C_BasePlayer *localplayer = C_BasePlayer::GetLocalPlayer();
|
||||
if ( localplayer &&
|
||||
localplayer == GetOwner() &&
|
||||
ShouldDrawLocalPlayerViewModel() )
|
||||
!localplayer->ShouldDrawLocalPlayer() )
|
||||
{
|
||||
return BaseClass::CalcOverrideModelIndex();
|
||||
return;
|
||||
}
|
||||
else
|
||||
|
||||
// BRJ 10/14/02
|
||||
// FIXME: Remove when Yahn's client-side prediction is done
|
||||
// It's a hacky workaround for the model indices fighting
|
||||
// (GetRenderBounds uses the model index, which is for the view model)
|
||||
SetModelIndex( GetWorldModelIndex() );
|
||||
|
||||
// Validate our current sequence just in case ( in theory the view and weapon models should have the same sequences for sequences that overlap at least )
|
||||
CStudioHdr *pStudioHdr = GetModelPtr();
|
||||
if ( pStudioHdr &&
|
||||
GetSequence() >= pStudioHdr->GetNumSeq() )
|
||||
{
|
||||
return GetWorldModelIndex();
|
||||
SetSequence( 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// tool recording
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user