game(hl1): fix UTIL_DropToFloor
This commit is contained in:
parent
1fe1d7b419
commit
fafc3554a5
@ -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;
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -23,16 +23,34 @@ 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();
|
||||
|
||||
@ -42,7 +60,9 @@ void CBaseHL1CombatWeapon::FallInit( void )
|
||||
|
||||
// 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 )
|
||||
{
|
||||
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 )
|
||||
}
|
||||
|
||||
// lie flat
|
||||
QAngle ang = GetAbsAngles();
|
||||
ang.x = 0;
|
||||
ang.z = 0;
|
||||
SetAbsAngles( ang );
|
||||
|
||||
Materialize();
|
||||
|
||||
SetSize( Vector( -24, -24, 0 ), Vector( 24, 24, 16 ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -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 );
|
||||
|
||||
|
@ -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…
Reference in New Issue
Block a user