Browse Source

game(hl1): fix UTIL_DropToFloor

pull/121/head
nillerusr 2 years ago
parent
commit
fafc3554a5
  1. 6
      game/server/ai_basenpc.cpp
  2. 5
      game/server/func_break.cpp
  3. 55
      game/server/hl1/hl1_basecombatweapon.cpp
  4. 5
      game/server/props.cpp
  5. 6
      game/server/util.cpp
  6. 1
      game/shared/hl1/hl1_basecombatweapon_shared.h
  7. 2
      game/shared/hl1/hl1mp_weapon_mp5.cpp

6
game/server/ai_basenpc.cpp

@ -6560,12 +6560,6 @@ float CAI_BaseNPC::ThrowLimit( const Vector &vecStart, @@ -6560,12 +6560,6 @@ float CAI_BaseNPC::ThrowLimit( const Vector &vecStart,
//-----------------------------------------------------------------------------
void CAI_BaseNPC::SetupVPhysicsHull()
{
if( GetModelPtr() == NULL )
{
UTIL_Remove( this );
return;
}
if ( GetMoveType() == MOVETYPE_VPHYSICS || GetMoveType() == MOVETYPE_NONE )
return;

5
game/server/func_break.cpp

@ -1250,10 +1250,9 @@ void CPushable::Spawn( void ) @@ -1250,10 +1250,9 @@ void CPushable::Spawn( void )
CreateVPhysics();
}
// nillerusr: VALVEWHY?
#if 0 //def HL1_DLL
#ifdef HL1_DLL
// Force HL1 Pushables to stay axially aligned.
VPhysicsGetObject()->SetInertia( Vector( 1e30, 1e30, 1e30 ) );
VPhysicsGetObject()->SetInertia( Vector( 3.f, 3.f, 3.f ) );
#endif//HL1_DLL
}

55
game/server/hl1/hl1_basecombatweapon.cpp

@ -23,26 +23,46 @@ void CBaseHL1CombatWeapon::Precache() @@ -23,26 +23,46 @@ void CBaseHL1CombatWeapon::Precache()
PrecacheScriptSound( "BaseCombatWeapon.WeaponDrop" );
}
bool CBaseHL1CombatWeapon::CreateVPhysics( void )
{
VPhysicsInitNormal( SOLID_BBOX, GetSolidFlags() | FSOLID_TRIGGER, false );
IPhysicsObject *pPhysObj = VPhysicsGetObject();
if ( pPhysObj )
{
pPhysObj->SetMass( 30 );
return true;
}
return false;
}
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CBaseHL1CombatWeapon::FallInit( void )
{
SetModel( GetWorldModel() );
SetMoveType( MOVETYPE_FLYGRAVITY, MOVECOLLIDE_FLY_BOUNCE );
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
AddSolidFlags( FSOLID_NOT_SOLID );
if( !CreateVPhysics() )
{
SetSolid( SOLID_BBOX );
SetMoveType( MOVETYPE_FLYGRAVITY );
SetSolid( SOLID_BBOX );
AddSolidFlags( FSOLID_TRIGGER );
}
SetPickupTouch();
SetThink( &CBaseHL1CombatWeapon::FallThink );
SetNextThink( gpGlobals->curtime + 0.1f );
// HACKHACK - On ground isn't always set, so look for ground underneath
trace_t tr;
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector(0,0,2), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
UTIL_TraceLine( GetAbsOrigin(), GetAbsOrigin() - Vector(0,0,256), MASK_SOLID_BRUSHONLY, this, COLLISION_GROUP_NONE, &tr );
SetAbsOrigin( tr.endpos );
if ( tr.fraction < 1.0 )
{
@ -63,7 +83,20 @@ void CBaseHL1CombatWeapon::FallThink ( void ) @@ -63,7 +83,20 @@ void CBaseHL1CombatWeapon::FallThink ( void )
{
SetNextThink( gpGlobals->curtime + 0.1f );
if ( GetFlags() & FL_ONGROUND )
bool shouldMaterialize = false;
IPhysicsObject *pPhysics = VPhysicsGetObject();
if ( pPhysics )
{
shouldMaterialize = pPhysics->IsAsleep();
}
else
{
shouldMaterialize = (GetFlags() & FL_ONGROUND) ? true : false;
if( shouldMaterialize )
SetSize( Vector( -24, -24, 0 ), Vector( 24, 24, 16 ) );
}
if ( shouldMaterialize )
{
// clatter if we have an owner (i.e., dropped by someone)
// don't clatter if the gun is waiting to respawn (if it's waiting, it is invisible!)
@ -73,14 +106,8 @@ void CBaseHL1CombatWeapon::FallThink ( void ) @@ -73,14 +106,8 @@ void CBaseHL1CombatWeapon::FallThink ( void )
}
// lie flat
QAngle ang = GetAbsAngles();
ang.x = 0;
ang.z = 0;
SetAbsAngles( ang );
Materialize();
Materialize();
SetSize( Vector( -24, -24, 0 ), Vector( 24, 24, 16 ) );
}
}

5
game/server/props.cpp

@ -5525,6 +5525,7 @@ class CPhysicsPropMultiplayer : public CPhysicsProp, public IMultiplayerPhysics @@ -5525,6 +5525,7 @@ class CPhysicsPropMultiplayer : public CPhysicsProp, public IMultiplayerPhysics
{
m_iPhysicsMode = PHYSICS_MULTIPLAYER_AUTODETECT;
m_usingCustomCollisionBounds = false;
m_fMass = 0.f;
}
// IBreakableWithPropData:
@ -5618,8 +5619,8 @@ class CPhysicsPropMultiplayer : public CPhysicsProp, public IMultiplayerPhysics @@ -5618,8 +5619,8 @@ class CPhysicsPropMultiplayer : public CPhysicsProp, public IMultiplayerPhysics
SetCollisionGroup( COLLISION_GROUP_DEBRIS );
}
if(VPhysicsGetObject())
m_fMass = VPhysicsGetObject()->GetMass();
if(VPhysicsGetObject())
m_fMass = VPhysicsGetObject()->GetMass();
// VPhysicsGetObject() is NULL on the client, which prevents the client from finding a decent
// AABB surrounding the collision bounds. If we've got a VPhysicsGetObject()->GetCollide(), we'll

6
game/server/util.cpp

@ -352,8 +352,12 @@ int UTIL_DropToFloor( CBaseEntity *pEntity, unsigned int mask, CBaseEntity *pIgn @@ -352,8 +352,12 @@ int UTIL_DropToFloor( CBaseEntity *pEntity, unsigned int mask, CBaseEntity *pIgn
return -1;
#endif // HL2MP
UTIL_TraceEntity( pEntity, pEntity->GetAbsOrigin(), pEntity->GetAbsOrigin() - Vector(0,0,256), mask, pIgnore, pEntity->GetCollisionGroup(), &trace );
UTIL_TraceEntity( pEntity, pEntity->GetAbsOrigin() + Vector(0,0,1), pEntity->GetAbsOrigin() - Vector(0,0,256), mask, pIgnore, pEntity->GetCollisionGroup(), &trace );
#ifdef HL1_DLL
if( fabs(pEntity->GetAbsOrigin().z - trace.endpos.z) <= 2.f )
return -1;
#endif
if (trace.allsolid)
return -1;

1
game/shared/hl1/hl1_basecombatweapon_shared.h

@ -35,6 +35,7 @@ public: @@ -35,6 +35,7 @@ public:
void FallInit( void ); // prepare to fall to the ground
virtual void FallThink( void ); // make the weapon fall to the ground after spawning
bool CreateVPhysics( void );
void EjectShell( CBaseEntity *pPlayer, int iType );

2
game/shared/hl1/hl1mp_weapon_mp5.cpp

@ -125,7 +125,7 @@ void CWeaponMP5::PrimaryAttack( void ) @@ -125,7 +125,7 @@ void CWeaponMP5::PrimaryAttack( void )
EjectShell( pPlayer, 0 );
pPlayer->ViewPunch( QAngle( -1, 0, 0 ) );
pPlayer->ViewPunch( QAngle( random->RandomFloat( -0.5f, 0.5f ), 0, 0 ) );
#ifdef CLIENT_DLL
pPlayer->DoMuzzleFlash();
#else

Loading…
Cancel
Save