Skip to content
This repository was archived by the owner on May 25, 2024. It is now read-only.
15 changes: 11 additions & 4 deletions mp/src/game/client/c_baseplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,9 @@ END_RECV_TABLE()
RecvPropEHandle ( RECVINFO( m_hLastWeapon ) ),
RecvPropEHandle ( RECVINFO( m_hGroundEntity ) ),

RecvPropFloat ( RECVINFO(m_vecVelocity[0]), 0, RecvProxy_LocalVelocityX ),
RecvPropFloat ( RECVINFO(m_vecVelocity[1]), 0, RecvProxy_LocalVelocityY ),
RecvPropFloat ( RECVINFO(m_vecVelocity[2]), 0, RecvProxy_LocalVelocityZ ),
RecvPropFloat ( RECVINFO(m_vecVelocity[0]), 0, RecvProxy_LocalVelocityX ),
RecvPropFloat ( RECVINFO(m_vecVelocity[1]), 0, RecvProxy_LocalVelocityY ),
RecvPropFloat ( RECVINFO(m_vecVelocity[2]), 0, RecvProxy_LocalVelocityZ ),

RecvPropVector ( RECVINFO( m_vecBaseVelocity ) ),

Expand Down Expand Up @@ -477,7 +477,7 @@ void C_BasePlayer::Spawn( void )

m_iFOV = 0; // init field of view.

SetModel( "models/player.mdl" );
SetModel( "models/player.mdl" );

Precache();

Expand Down Expand Up @@ -1905,6 +1905,13 @@ void C_BasePlayer::ThirdPersonSwitch( bool bThirdperson )
}
}
}

//Notify weapon.
CBaseCombatWeapon *pWeapon = GetActiveWeapon();
if ( pWeapon )
{
pWeapon->ThirdPersonSwitch( bThirdperson );
}
}
}

Expand Down
13 changes: 8 additions & 5 deletions mp/src/game/client/c_te_effect_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,8 @@ static void RecordEffect( const char *pEffectName, const CEffectData &data )
char pName[1024];
Q_snprintf( pName, sizeof(pName), "TE_DispatchEffect %s %s", pEffectName, pSurfacePropName );

msg->SetInt( "te", TE_DISPATCH_EFFECT );
msg->SetString( "name", pName );
msg->SetInt( "te", TE_DISPATCH_EFFECT );
msg->SetString( "name", pName );
msg->SetFloat( "time", gpGlobals->curtime );
msg->SetFloat( "originx", data.m_vOrigin.x );
msg->SetFloat( "originy", data.m_vOrigin.y );
Expand All @@ -126,10 +126,10 @@ static void RecordEffect( const char *pEffectName, const CEffectData &data )
msg->SetInt( "color", data.m_nColor );
msg->SetInt( "damagetype", data.m_nDamageType );
msg->SetInt( "hitbox", data.m_nHitBox );
msg->SetString( "effectname", pEffectName );
msg->SetString( "effectname", pEffectName );

// FIXME: Need to write the attachment name here
msg->SetInt( "attachmentindex", data.m_nAttachmentIndex );
msg->SetInt( "attachmentindex", data.m_nAttachmentIndex );

// NOTE: Ptrs are our way of indicating it's an entindex
msg->SetPtr( "entindex", (void*)data.entindex() );
Expand Down Expand Up @@ -178,7 +178,10 @@ void DispatchEffect( const char *pName, const CEffectData &data )
CPASFilter filter( data.m_vOrigin );
te->DispatchEffect( filter, 0.0, data.m_vOrigin, pName, data );
}

void DispatchEffect( const char *pName, const CEffectData &data, IRecipientFilter &filter )
{
te->DispatchEffect( filter, 0.0, data.m_vOrigin, pName, data );
}

//-----------------------------------------------------------------------------
// Playback
Expand Down
1 change: 1 addition & 0 deletions mp/src/game/client/c_te_effect_dispatch.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,5 +42,6 @@ class CClientEffectRegistration

void DispatchEffectToCallback( const char *pEffectName, const CEffectData &m_EffectData );
void DispatchEffect( const char *pName, const CEffectData &data );
void DispatchEffect( const char *pName, const CEffectData &data, IRecipientFilter &filter );

#endif // C_TE_EFFECT_DISPATCH_H
5 changes: 5 additions & 0 deletions mp/src/game/client/hl2/c_basehlplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ void CC_DropPrimary( void )

static ConCommand dropprimary("dropprimary", CC_DropPrimary, "dropprimary: Drops the primary weapon of the player.");

// link to the correct class.
#if !defined ( HL2MP )
LINK_ENTITY_TO_CLASS( player, C_BaseHLPlayer );
#endif

//-----------------------------------------------------------------------------
// Constructor
//-----------------------------------------------------------------------------
Expand Down
23 changes: 22 additions & 1 deletion mp/src/game/server/baseentity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1577,7 +1577,28 @@ int CBaseEntity::VPhysicsTakeDamage( const CTakeDamageInfo &info )
if ( gameFlags & FVPHYSICS_PLAYER_HELD )
{
// if the player is holding the object, use it's real mass (player holding reduced the mass)
CBasePlayer *pPlayer = UTIL_GetLocalPlayer();

CBasePlayer *pPlayer = NULL;

if ( gpGlobals->maxClients == 1 )
{
pPlayer = UTIL_GetLocalPlayer();
}
else
{
// See which MP player is holding the physics object and then use that player to get the real mass of the object.
// This is ugly but better than having linkage between an object and its "holding" player.
for ( int i = 1; i <= gpGlobals->maxClients; i++ )
{
CBasePlayer *tempPlayer = UTIL_PlayerByIndex( i );
if ( tempPlayer && (tempPlayer->GetHeldObject() == this ) )
{
pPlayer = tempPlayer;
break;
}
}
}

if ( pPlayer )
{
float mass = pPlayer->GetHeldObjectMass( VPhysicsGetObject() );
Expand Down
3 changes: 2 additions & 1 deletion mp/src/game/server/filters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,8 @@ class FilterDamageType : public CBaseFilter

bool PassesDamageFilterImpl(const CTakeDamageInfo &info)
{
return info.GetDamageType() == m_iDamageType;
//Tony; these are bitflags. check them as so.
return ((info.GetDamageType() & m_iDamageType) == m_iDamageType);
}

int m_iDamageType;
Expand Down
8 changes: 6 additions & 2 deletions mp/src/game/server/hl2/hl2_player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,7 @@ bool CHL2_Player::IsIlluminatedByFlashlight( CBaseEntity *pEntity, float *flRetu
}

// Within 50 feet?
float flDistSqr = GetAbsOrigin().DistToSqr(pEntity->GetAbsOrigin());
float flDistSqr = GetAbsOrigin().DistToSqr(pEntity->GetAbsOrigin());
if( flDistSqr > FLASHLIGHT_RANGE )
return false;

Expand Down Expand Up @@ -2242,7 +2242,7 @@ void CHL2_Player::SetPlayerUnderwater( bool state )
}
else
{
SuitPower_RemoveDevice( SuitDeviceBreather );
SuitPower_RemoveDevice( SuitDeviceBreather );
}

BaseClass::SetPlayerUnderwater( state );
Expand Down Expand Up @@ -3251,6 +3251,10 @@ float CHL2_Player::GetHeldObjectMass( IPhysicsObject *pHeldObject )
return mass;
}

CBaseEntity *CHL2_Player::GetHeldObject( void )
{
return PhysCannonGetHeldEntity( GetActiveWeapon() );
}
//-----------------------------------------------------------------------------
// Purpose: Force the player to drop any physics objects he's carrying
//-----------------------------------------------------------------------------
Expand Down
13 changes: 11 additions & 2 deletions mp/src/game/server/hl2/hl2_player.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@
#include "simtimer.h"
#include "soundenvelope.h"

// In HL2MP we need to inherit from BaseMultiplayerPlayer!
#if defined ( HL2MP )
#include "basemultiplayerplayer.h"
#define BASEPLAYERCLASS CBaseMultiplayerPlayer
#else
#define BASEPLAYERCLASS CBasePlayer
#endif

class CAI_Squad;
class CPropCombineBall;

Expand Down Expand Up @@ -75,10 +83,10 @@ class CSuitPowerDevice
//=============================================================================
// >> HL2_PLAYER
//=============================================================================
class CHL2_Player : public CBasePlayer
class CHL2_Player : public BASEPLAYERCLASS
{
public:
DECLARE_CLASS( CHL2_Player, CBasePlayer );
DECLARE_CLASS( CHL2_Player, BASEPLAYERCLASS );

CHL2_Player();
~CHL2_Player( void );
Expand Down Expand Up @@ -261,6 +269,7 @@ class CHL2_Player : public CBasePlayer
virtual bool IsHoldingEntity( CBaseEntity *pEnt );
virtual void ForceDropOfCarriedPhysObjects( CBaseEntity *pOnlyIfHoldindThis );
virtual float GetHeldObjectMass( IPhysicsObject *pHeldObject );
virtual CBaseEntity *GetHeldObject( void );

virtual bool IsFollowingPhysics( void ) { return (m_afPhysicsFlags & PFLAG_ONBARNACLE) > 0; }
void InputForceDropPhysObjects( inputdata_t &data );
Expand Down
124 changes: 107 additions & 17 deletions mp/src/game/server/hl2mp/grenade_tripmine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "cbase.h"
#include "beam_shared.h"
#include "shake.h"
#include "grenade_tripmine.h"
#include "hl2mp/grenade_tripmine.h" // Load the hl2mp header!!
#include "vstdlib/random.h"
#include "engine/IEngineSound.h"
#include "explode.h"
Expand Down Expand Up @@ -49,8 +49,23 @@ CTripmineGrenade::CTripmineGrenade()
m_vecEnd.Init();
m_posOwner.Init();
m_angleOwner.Init();

m_pConstraint = NULL;
m_bAttached = false;
m_hAttachEntity = NULL;
}

//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
CTripmineGrenade::~CTripmineGrenade( void )
{
if (m_pConstraint)
{
physenv->DestroyConstraint(m_pConstraint);
m_pConstraint = NULL;
}
}
void CTripmineGrenade::Spawn( void )
{
Precache( );
Expand All @@ -59,7 +74,7 @@ void CTripmineGrenade::Spawn( void )
SetSolid( SOLID_BBOX );
SetModel( "models/Weapons/w_slam.mdl" );

IPhysicsObject *pObject = VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, true );
IPhysicsObject *pObject = VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, true );
pObject->EnableMotion( false );
SetCollisionGroup( COLLISION_GROUP_WEAPON );

Expand Down Expand Up @@ -117,10 +132,16 @@ void CTripmineGrenade::PowerupThink( void )
{
if (gpGlobals->curtime > m_flPowerUp)
{
m_flPowerUp = 0;
MakeBeam( );
RemoveSolidFlags( FSOLID_NOT_SOLID );
m_bIsLive = true;

// The moment it's live, then do this - incase the attach entity moves between placing it, and activation
// use the absorigin of what we're attaching to for the check, if it moves - we blow up.
if ( m_bAttached && m_hAttachEntity.Get() != NULL )
m_vAttachedPosition = m_hAttachEntity.Get()->GetAbsOrigin();

// play enabled sound
EmitSound( "TripmineGrenade.Activate" );
}
Expand All @@ -146,8 +167,6 @@ void CTripmineGrenade::MakeBeam( void )

m_flBeamLength = tr.fraction;



// If I hit a living thing, send the beam through me so it turns on briefly
// and then blows the living thing up
CBaseEntity *pEntity = tr.m_pEnt;
Expand Down Expand Up @@ -219,31 +238,42 @@ void CTripmineGrenade::BeamBreakThink( void )
CBaseEntity *pEntity = tr.m_pEnt;
CBaseCombatCharacter *pBCC = ToBaseCombatCharacter( pEntity );

if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001)
bool bAttachMoved = false;
if ( m_bAttached && m_hAttachEntity.Get() != NULL )
{
if ( m_hAttachEntity.Get()->GetAbsOrigin() != m_vAttachedPosition )
bAttachMoved = true;
}

// Also blow up if the attached entity goes away, ie: a crate
if (pBCC || fabs( m_flBeamLength - tr.fraction ) > 0.001 || ( m_bAttached && m_hAttachEntity.Get() == NULL) || bAttachMoved )
{
m_iHealth = 0;
if (m_pConstraint)
m_pConstraint->Deactivate();

Event_Killed( CTakeDamageInfo( (CBaseEntity*)m_hOwner, this, 100, GIB_NORMAL ) );
return;
}

SetNextThink( gpGlobals->curtime + 0.05f );
}

#if 0 // FIXME: OnTakeDamage_Alive() is no longer called now that base grenade derives from CBaseAnimating
int CTripmineGrenade::OnTakeDamage_Alive( const CTakeDamageInfo &info )
int CTripmineGrenade::OnTakeDamage( const CTakeDamageInfo &info )
{
if (gpGlobals->curtime < m_flPowerUp && info.GetDamage() < m_iHealth)
if ( m_iHealth < 0 )
return 0; //already dead.

if ( gpGlobals->curtime > m_flPowerUp )
{
// disable
// Create( "weapon_tripmine", GetLocalOrigin() + m_vecDir * 24, GetAngles() );
SetThink( &CTripmineGrenade::SUB_Remove );
SetNextThink( gpGlobals->curtime + 0.1f );
KillBeam();
return FALSE;
m_iHealth -= info.GetDamage();

if ( m_iHealth <= 0 )
Event_Killed( info );

return info.GetDamage();
}
return BaseClass::OnTakeDamage_Alive( info );
return 0;
}
#endif

//-----------------------------------------------------------------------------
// Purpose:
Expand All @@ -254,6 +284,9 @@ void CTripmineGrenade::Event_Killed( const CTakeDamageInfo &info )
{
m_takedamage = DAMAGE_NO;

if (m_pConstraint)
m_pConstraint->Deactivate();

SetThink( &CTripmineGrenade::DelayDeathThink );
SetNextThink( gpGlobals->curtime + 0.25 );

Expand All @@ -274,3 +307,60 @@ void CTripmineGrenade::DelayDeathThink( void )
UTIL_Remove( this );
}

bool CTripmineGrenade::MakeConstraint( CBaseEntity *pObject )
{
IPhysicsObject *cMinePhysics = VPhysicsGetObject();

Assert( cMinePhysics );

IPhysicsObject *pAttached = pObject->VPhysicsGetObject();
if ( !cMinePhysics || !pAttached )
return false;

// constraining to the world means object 1 is fixed
if ( pAttached == g_PhysWorldObject )
PhysSetGameFlags( cMinePhysics, FVPHYSICS_CONSTRAINT_STATIC );

IPhysicsConstraintGroup *pGroup = NULL;

constraint_fixedparams_t fixed;
fixed.Defaults();
fixed.InitWithCurrentObjectState( cMinePhysics, pAttached );
fixed.constraint.Defaults();

m_pConstraint = physenv->CreateFixedConstraint( cMinePhysics, pAttached, pGroup, fixed );

if (!m_pConstraint)
return false;

m_pConstraint->SetGameData( (void *)this );

return true;
}

void CTripmineGrenade::AttachToEntity(CBaseEntity *pOther)
{
if (!pOther)
return;

if ( !VPhysicsGetObject() )
return;

m_bAttached = true;
m_hAttachEntity = pOther;

SetMoveType ( MOVETYPE_NONE );

if (pOther->GetSolid() == SOLID_VPHYSICS && pOther->VPhysicsGetObject() != NULL )
{
SetSolid(SOLID_BBOX); //Tony; switch to bbox solid instead of vphysics, because we've made the physics object non-solid
MakeConstraint(pOther);
SetMoveType ( MOVETYPE_VPHYSICS ); // use vphysics while constrained!!
}
//if it isnt vphysics or bsp, use SetParent to follow it.
else if (pOther->GetSolid() != SOLID_BSP)
{
SetSolid(SOLID_BBOX); //Tony; switch to bbox solid instead of vphysics, because we've made the physics object non-solid
SetParent( m_hAttachEntity.Get() );
}
}
Loading