game(hl1): fix UTIL_DropToFloor

This commit is contained in:
nillerusr
2022-08-31 18:22:56 +03:00
parent 1fe1d7b419
commit fafc3554a5
7 changed files with 53 additions and 27 deletions
+41 -14
View File
@@ -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 )
{
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();
Materialize();
SetSize( Vector( -24, -24, 0 ), Vector( 24, 24, 16 ) );
}
}