@ -23,16 +23,34 @@ void CBaseHL1CombatWeapon::Precache()
@@ -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 ) ;
if ( ! CreateVPhysics ( ) )
{
SetSolid ( SOLID_BBOX ) ;
SetMoveType ( MOVETYPE_FLYGRAVITY ) ;
SetSolid ( SOLID_BBOX ) ;
AddSolidFlags ( FSOLID_TRIGGER ) ;
AddSolidFlags ( FSOLID_NOT_SOLID ) ;
}
SetPickupTouch ( ) ;
@ -42,7 +60,9 @@ void CBaseHL1CombatWeapon::FallInit( void )
@@ -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 )
@@ -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 ( ) ;
SetSize ( Vector ( - 24 , - 24 , 0 ) , Vector ( 24 , 24 , 16 ) ) ;
}
}