void CWeaponGravityGun::AttachObject( CBaseEntity *pObject, const Vector& start, const Vector &end, float distance ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if( !pOwner ) return; m_hObject = pObject; m_useDown = false; IPhysicsObject *pPhysics = pObject ? (pObject->VPhysicsGetObject()) : NULL; if ( pPhysics && pObject->GetMoveType() == MOVETYPE_VPHYSICS ) { m_distance = distance; Vector worldPosition; pObject->WorldToEntitySpace( end, &worldPosition ); m_worldPosition = worldPosition; m_gravCallback.AttachEntity( pOwner, pObject, pPhysics, pObject->GetAbsOrigin() ); m_originalObjectPosition = pObject->GetAbsOrigin(); pPhysics->Wake(); PhysSetGameFlags( pPhysics, FVPHYSICS_PLAYER_HELD ); #ifndef CLIENT_DLL Pickup_OnPhysGunPickup( pObject, pOwner ); #endif } else { m_hObject = NULL; } }
void CWeaponGravityGun::AttachObject( CBaseEntity *pObject, const Vector& start, const Vector &end, float distance ) { m_hObject = pObject; m_useDown = false; IPhysicsObject *pPhysics = pObject ? (pObject->VPhysicsGetObject()) : NULL; if ( pPhysics && pObject->GetMoveType() == MOVETYPE_VPHYSICS ) { m_distance = distance; m_gravCallback.AttachEntity( pObject, pPhysics, end ); float mass = pPhysics->GetMass(); Msg( "Object mass: %.2f lbs (%.2f kg)\n", kg2lbs(mass), mass ); float vel = phys_gunvel.GetFloat(); if ( mass > phys_gunmass.GetFloat() ) { vel = (vel*phys_gunmass.GetFloat())/mass; } m_gravCallback.SetMaxVelocity( vel ); // Msg( "Object mass: %.2f lbs (%.2f kg) %f %f %f\n", kg2lbs(mass), mass, pObject->GetAbsOrigin().x, pObject->GetAbsOrigin().y, pObject->GetAbsOrigin().z ); // Msg( "ANG: %f %f %f\n", pObject->GetAbsAngles().x, pObject->GetAbsAngles().y, pObject->GetAbsAngles().z ); m_originalObjectPosition = pObject->GetAbsOrigin(); m_pelletAttract = -1; m_pelletHeld = -1; pPhysics->Wake(); SortPelletsForObject( pObject ); CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if( pOwner ) { Pickup_OnPhysGunPickup( pObject, pOwner ); } } else { m_hObject = NULL; } }
void CWeaponGravityGun::AttachObject( CBaseEntity *pObject, IPhysicsObject *pPhysics, short physicsbone, const Vector& start, const Vector &end, float distance ) { CBasePlayer *pOwner = ToBasePlayer( GetOwner() ); if( !pOwner ) return; m_hObject = pObject; m_physicsBone = physicsbone; m_useDown = false; if ( pPhysics && pObject->GetMoveType() == MOVETYPE_VPHYSICS ) { m_distance = distance; Vector worldPosition; pPhysics->WorldToLocal( &worldPosition, end ); m_worldPosition = worldPosition; Vector vecOrigin; pPhysics->GetPosition( &vecOrigin, NULL ); m_gravCallback.AttachEntity( pOwner, pObject, pPhysics, physicsbone, vecOrigin ); m_originalObjectPosition = vecOrigin; pPhysics->Wake(); IPhysicsObject *pList[VPHYSICS_MAX_OBJECT_LIST_COUNT]; int count = pObject->VPhysicsGetObjectList( pList, ARRAYSIZE(pList) ); for ( int i = 0; i < count; i++ ) { PhysSetGameFlags( pList[i], FVPHYSICS_PLAYER_HELD ); } #ifndef CLIENT_DLL Pickup_OnPhysGunPickup( pObject, pOwner ); #endif } else { m_hObject = NULL; m_physicsBone = 0; } }