mirror of
https://github.com/nillerusr/source-engine.git
synced 2026-08-30 14:09:19 +00:00
upload "kind" alien swarm
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//========= Copyright © 1996-2005, Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose:
|
||||
//
|
||||
@@ -10,24 +10,10 @@
|
||||
#include "gamerules.h"
|
||||
#include "player.h"
|
||||
#include "model_types.h"
|
||||
#include "movehelper_server.h"
|
||||
#include "imovehelper.h"
|
||||
#include "shake.h" // For screen fade constants
|
||||
#include "engine/IEngineSound.h"
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN
|
||||
// [dwenger] Necessary for stats tracking
|
||||
//=============================================================================
|
||||
#ifdef CSTRIKE_DLL
|
||||
|
||||
#include "cs_gamestats.h"
|
||||
#include "cs_achievement_constants.h"
|
||||
|
||||
#endif
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
// memdbgon must be the last include file in a .cpp file!!!
|
||||
#include "tier0/memdbgon.h"
|
||||
|
||||
@@ -38,7 +24,7 @@ extern IPhysicsCollision *physcollision;
|
||||
// Implementation of the movehelper on the server
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
class CMoveHelperServer : public IMoveHelperServer
|
||||
class CMoveHelperServer : public IMoveHelper
|
||||
{
|
||||
public:
|
||||
CMoveHelperServer( void );
|
||||
@@ -50,6 +36,7 @@ public:
|
||||
// Touch list...
|
||||
virtual void ResetTouchList( void );
|
||||
virtual bool AddToTouched( const trace_t &tr, const Vector& impactvelocity );
|
||||
virtual void SetGroundNormal( const Vector& groundNormal );
|
||||
virtual void ProcessImpacts( void );
|
||||
|
||||
virtual bool PlayerFallingDamage( void );
|
||||
@@ -65,12 +52,12 @@ public:
|
||||
virtual void PlaybackEventFull( int flags, int clientindex, unsigned short eventindex, float delay, Vector& origin, Vector& angles, float fparam1, float fparam2, int iparam1, int iparam2, int bparam1, int bparam2 );
|
||||
virtual IPhysicsSurfaceProps *GetSurfaceProps( void );
|
||||
|
||||
void SetHost( CBasePlayer *host );
|
||||
void SetHost( CBaseEntity *host );
|
||||
|
||||
virtual bool IsWorldEntity( const CBaseHandle &handle );
|
||||
|
||||
private:
|
||||
CBasePlayer* m_pHostPlayer;
|
||||
CBaseEntity* m_pHost;
|
||||
|
||||
// results, tallied on client and server, but only used by server to run SV_Impact.
|
||||
// we store off our velocity in the trace_t structure so that we can determine results
|
||||
@@ -82,6 +69,9 @@ private:
|
||||
};
|
||||
|
||||
CUtlVector<touchlist_t> m_TouchList;
|
||||
|
||||
Vector m_collisionNormal;
|
||||
Vector m_groundNormal;
|
||||
};
|
||||
|
||||
|
||||
@@ -91,12 +81,7 @@ private:
|
||||
|
||||
IMPLEMENT_MOVEHELPER();
|
||||
|
||||
IMoveHelperServer* MoveHelperServer()
|
||||
{
|
||||
static CMoveHelperServer s_MoveHelperServer;
|
||||
return &s_MoveHelperServer;
|
||||
}
|
||||
|
||||
static CMoveHelperServer s_MoveHelperServer;
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Converts the entity handle into a edict_t
|
||||
@@ -114,7 +99,7 @@ static inline edict_t* GetEdict( EntityHandle_t handle )
|
||||
|
||||
CMoveHelperServer::CMoveHelperServer( void ) : m_TouchList( 0, 128 )
|
||||
{
|
||||
m_pHostPlayer = 0;
|
||||
m_pHost = 0;
|
||||
SetSingleton( this );
|
||||
}
|
||||
|
||||
@@ -127,9 +112,9 @@ CMoveHelperServer::~CMoveHelperServer( void )
|
||||
// Indicates which player we're going to move
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CMoveHelperServer::SetHost( CBasePlayer *host )
|
||||
void CMoveHelperServer::SetHost( CBaseEntity *host )
|
||||
{
|
||||
m_pHostPlayer = host;
|
||||
m_pHost = host;
|
||||
|
||||
// In case any stuff is ever left over, sigh...
|
||||
ResetTouchList();
|
||||
@@ -168,6 +153,10 @@ char const* CMoveHelperServer::GetName( EntityHandle_t handle ) const
|
||||
void CMoveHelperServer::ResetTouchList( void )
|
||||
{
|
||||
m_TouchList.RemoveAll();
|
||||
|
||||
// Track collision normal
|
||||
m_collisionNormal.Init();
|
||||
m_groundNormal.Init();
|
||||
}
|
||||
|
||||
|
||||
@@ -177,20 +166,23 @@ void CMoveHelperServer::ResetTouchList( void )
|
||||
|
||||
bool CMoveHelperServer::AddToTouched( const trace_t &tr, const Vector& impactvelocity )
|
||||
{
|
||||
Assert( m_pHostPlayer );
|
||||
Assert( m_pHost );
|
||||
|
||||
// Trace missed
|
||||
if ( !tr.m_pEnt )
|
||||
return false;
|
||||
|
||||
if ( tr.m_pEnt == m_pHostPlayer )
|
||||
if ( tr.m_pEnt == m_pHost )
|
||||
{
|
||||
Assert( !"CMoveHelperServer::AddToTouched: Tried to add self to touchlist!!!" );
|
||||
return false;
|
||||
}
|
||||
|
||||
// Track collision normal
|
||||
m_collisionNormal += tr.plane.normal;
|
||||
|
||||
// Check for duplicate entities
|
||||
for ( int j = m_TouchList.Size(); --j >= 0; )
|
||||
for ( int j = m_TouchList.Count(); --j >= 0; )
|
||||
{
|
||||
if ( m_TouchList[j].trace.m_pEnt == tr.m_pEnt )
|
||||
{
|
||||
@@ -206,26 +198,34 @@ bool CMoveHelperServer::AddToTouched( const trace_t &tr, const Vector& impactvel
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// When the ground is hit, update the normal
|
||||
//-----------------------------------------------------------------------------
|
||||
|
||||
void CMoveHelperServer::SetGroundNormal( const Vector& groundNormal )
|
||||
{
|
||||
m_groundNormal = groundNormal;
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// After we built the touch list, deal with all the impacts...
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMoveHelperServer::ProcessImpacts( void )
|
||||
{
|
||||
Assert( m_pHostPlayer );
|
||||
Assert( m_pHost );
|
||||
|
||||
// Relink in order to build absorigin and absmin/max to reflect any changes
|
||||
// from prediction. Relink will early out on SOLID_NOT
|
||||
m_pHostPlayer->PhysicsTouchTriggers();
|
||||
m_pHost->PhysicsTouchTriggers();
|
||||
|
||||
// Don't bother if the player ain't solid
|
||||
if ( m_pHostPlayer->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
|
||||
if ( m_pHost->IsSolidFlagSet( FSOLID_NOT_SOLID ) )
|
||||
return;
|
||||
|
||||
// Save off the velocity, cause we need to temporarily reset it
|
||||
Vector vel = m_pHostPlayer->GetAbsVelocity();
|
||||
Vector vel = m_pHost->GetAbsVelocity();
|
||||
|
||||
// Touch other objects that were intersected during the movement.
|
||||
for (int i = 0 ; i < m_TouchList.Size(); i++)
|
||||
for (int i = 0 ; i < m_TouchList.Count(); i++)
|
||||
{
|
||||
CBaseHandle entindex = m_TouchList[i].trace.m_pEnt->GetRefEHandle();
|
||||
|
||||
@@ -241,22 +241,39 @@ void CMoveHelperServer::ProcessImpacts( void )
|
||||
if ( !entity )
|
||||
continue;
|
||||
|
||||
Assert( entity != m_pHostPlayer );
|
||||
Assert( entity != m_pHost );
|
||||
// Don't ever collide with self!!!!
|
||||
if ( entity == m_pHostPlayer )
|
||||
if ( entity == m_pHost )
|
||||
continue;
|
||||
|
||||
// Reconstruct trace results.
|
||||
m_TouchList[i].trace.m_pEnt = CBaseEntity::Instance( ent );
|
||||
|
||||
// Use the velocity we had when we collided, so boxes will move, etc.
|
||||
m_pHostPlayer->SetAbsVelocity( m_TouchList[i].deltavelocity );
|
||||
m_pHost->SetAbsVelocity( m_TouchList[i].deltavelocity );
|
||||
|
||||
entity->PhysicsImpact( m_pHostPlayer, m_TouchList[i].trace );
|
||||
entity->PhysicsImpact( m_pHost, m_TouchList[i].trace );
|
||||
}
|
||||
|
||||
// Restore the velocity
|
||||
m_pHostPlayer->SetAbsVelocity( vel );
|
||||
m_pHost->SetAbsVelocity( vel );
|
||||
|
||||
// Track collision normal
|
||||
if ( m_pHost && m_pHost->IsPlayer() )
|
||||
{
|
||||
CBasePlayer *pPlayerHost = static_cast< CBasePlayer * >( m_pHost );
|
||||
Assert( pPlayerHost );
|
||||
if ( !m_collisionNormal.IsZero() )
|
||||
{
|
||||
m_collisionNormal.NormalizeInPlace();
|
||||
pPlayerHost->m_movementCollisionNormal = m_collisionNormal;
|
||||
}
|
||||
|
||||
if ( !m_groundNormal.IsZero() )
|
||||
{
|
||||
pPlayerHost->m_groundNormal = m_groundNormal;
|
||||
}
|
||||
}
|
||||
|
||||
// So no stuff is ever left over, sigh...
|
||||
ResetTouchList();
|
||||
@@ -275,7 +292,7 @@ void CMoveHelperServer::StartSound( const Vector& origin, const char *soundname
|
||||
CRecipientFilter filter;
|
||||
filter.AddRecipientsByPAS( origin );
|
||||
|
||||
CBaseEntity::EmitSound( filter, m_pHostPlayer->entindex(), soundname );
|
||||
CBaseEntity::EmitSound( filter, m_pHost->entindex(), soundname );
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
@@ -301,7 +318,7 @@ void CMoveHelperServer::StartSound( const Vector& origin, int channel, char cons
|
||||
ep.m_nPitch = pitch;
|
||||
ep.m_pOrigin = &origin;
|
||||
|
||||
CBaseEntity::EmitSound( filter, m_pHostPlayer->entindex(), ep );
|
||||
CBaseEntity::EmitSound( filter, m_pHost->entindex(), ep );
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -316,7 +333,7 @@ void CMoveHelperServer::StartSound( const Vector& origin, int channel, char cons
|
||||
ep.m_nPitch = pitch;
|
||||
ep.m_pOrigin = &origin;
|
||||
|
||||
CBaseEntity::EmitSound( filter, m_pHostPlayer->entindex(), ep );
|
||||
CBaseEntity::EmitSound( filter, m_pHost->entindex(), ep );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -359,42 +376,26 @@ void CMoveHelperServer::Con_NPrintf( int idx, char const* pFormat, ...)
|
||||
//-----------------------------------------------------------------------------
|
||||
bool CMoveHelperServer::PlayerFallingDamage( void )
|
||||
{
|
||||
float flFallDamage = g_pGameRules->FlPlayerFallDamage( m_pHostPlayer );
|
||||
if ( flFallDamage > 0 )
|
||||
if ( m_pHost->IsPlayer() )
|
||||
{
|
||||
m_pHostPlayer->TakeDamage( CTakeDamageInfo( GetContainingEntity(INDEXENT(0)), GetContainingEntity(INDEXENT(0)), flFallDamage, DMG_FALL ) );
|
||||
StartSound( m_pHostPlayer->GetAbsOrigin(), "Player.FallDamage" );
|
||||
CBasePlayer *pPlayer = static_cast< CBasePlayer * >( m_pHost );
|
||||
|
||||
//=============================================================================
|
||||
// HPE_BEGIN:
|
||||
// [dwenger] Needed for fun-fact implementation
|
||||
//=============================================================================
|
||||
|
||||
#ifdef CSTRIKE_DLL
|
||||
|
||||
// Increment the stat for fall damage
|
||||
CCSPlayer* pPlayer = ToCSPlayer(m_pHostPlayer);
|
||||
|
||||
if ( pPlayer )
|
||||
{
|
||||
CCS_GameStats.IncrementStat( pPlayer, CSSTAT_FALL_DAMAGE, (int)flFallDamage );
|
||||
}
|
||||
|
||||
#endif
|
||||
//=============================================================================
|
||||
// HPE_END
|
||||
//=============================================================================
|
||||
|
||||
}
|
||||
|
||||
if ( m_pHostPlayer->m_iHealth <= 0 )
|
||||
{
|
||||
if ( g_pGameRules->FlPlayerFallDeathDoesScreenFade( m_pHostPlayer ) )
|
||||
float flFallDamage = g_pGameRules->FlPlayerFallDamage( pPlayer );
|
||||
if ( flFallDamage > 0 )
|
||||
{
|
||||
color32 black = {0, 0, 0, 255};
|
||||
UTIL_ScreenFade( m_pHostPlayer, black, 0, 9999, FFADE_OUT | FFADE_STAYOUT );
|
||||
pPlayer->TakeDamage( CTakeDamageInfo( GetContainingEntity(INDEXENT(0)), GetContainingEntity(INDEXENT(0)), flFallDamage, DMG_FALL ) );
|
||||
StartSound( pPlayer->GetAbsOrigin(), "Player.FallDamage" );
|
||||
}
|
||||
|
||||
if ( pPlayer->m_iHealth <= 0 )
|
||||
{
|
||||
if ( g_pGameRules->FlPlayerFallDeathDoesScreenFade( pPlayer ) )
|
||||
{
|
||||
color32 black = {0, 0, 0, 255};
|
||||
UTIL_ScreenFade( pPlayer, black, 0, 9999, FFADE_OUT | FFADE_STAYOUT );
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
return(false);
|
||||
}
|
||||
|
||||
return(true);
|
||||
@@ -407,10 +408,20 @@ bool CMoveHelperServer::PlayerFallingDamage( void )
|
||||
//-----------------------------------------------------------------------------
|
||||
void CMoveHelperServer::PlayerSetAnimation( PLAYER_ANIM eAnim )
|
||||
{
|
||||
m_pHostPlayer->SetAnimation( eAnim );
|
||||
if ( m_pHost && m_pHost->IsPlayer() )
|
||||
{
|
||||
static_cast< CBasePlayer * >( m_pHost )->SetAnimation( eAnim );
|
||||
}
|
||||
}
|
||||
|
||||
bool CMoveHelperServer::IsWorldEntity( const CBaseHandle &handle )
|
||||
{
|
||||
return handle == CBaseEntity::Instance( 0 );
|
||||
}
|
||||
|
||||
|
||||
// todo: remove this and find/replace all the MoveHelperServer() calls (server no longer uses a specialized version of the IMoveHelper interface)
|
||||
IMoveHelper* MoveHelperServer()
|
||||
{
|
||||
return MoveHelper();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user