Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // IN LUA BINDING //
- CBaseEntity *pRagdoll;
- // Was a ragdoll created?
- LUA->PushBool( ent->BecomeRagdoll( info, force, &pRagdoll ) );
- LUA->PushUserType( pRagdoll, GarrysMod::Lua::Type::ENTITY );
- return 2;
- // CODE //
- bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vector &forceVector, CBaseEntity **pRetRagdoll = NULL )
- {
- // Clear the return
- if ( pRetRagdoll != NULL )
- *pRetRagdoll = NULL;
- if ( (info.GetDamageType() & DMG_VEHICLE) && !g_pGameRules->IsMultiplayer() )
- {
- CTakeDamageInfo info2 = info;
- info2.SetDamageForce( forceVector );
- Vector pos = info2.GetDamagePosition();
- float flAbsMinsZ = GetAbsOrigin().z + WorldAlignMins().z;
- if ( (pos.z - flAbsMinsZ) < 24 )
- {
- // HACKHACK: Make sure the vehicle impact is at least 2ft off the ground
- pos.z = flAbsMinsZ + 24;
- info2.SetDamagePosition( pos );
- }
- // UNDONE: Put in a real sound cue here, don't do this bogus hack anymore
- #if 0
- Vector soundOrigin = info.GetDamagePosition();
- CPASAttenuationFilter filter( soundOrigin );
- EmitSound_t ep;
- ep.m_nChannel = CHAN_STATIC;
- ep.m_pSoundName = "NPC_MetroPolice.HitByVehicle";
- ep.m_flVolume = 1.0f;
- ep.m_SoundLevel = SNDLVL_NORM;
- ep.m_pOrigin = &soundOrigin;
- EmitSound( filter, SOUND_FROM_WORLD, ep );
- #endif
- // in single player create ragdolls on the server when the player hits someone
- // with their vehicle - for more dramatic death/collisions
- CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, info2, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
- if ( pRetRagdoll != NULL )
- *pRetRagdoll = pRagdoll;
- FixupBurningServerRagdoll( pRagdoll );
- RemoveDeferred();
- return true;
- }
- //Fix up the force applied to server side ragdolls. This fixes magnets not affecting them.
- CTakeDamageInfo newinfo = info;
- newinfo.SetDamageForce( forceVector );
- #ifdef HL2_EPISODIC
- // Burning corpses are server-side in episodic, if we're in darkness mode
- if ( IsOnFire() && HL2GameRules()->IsAlyxInDarknessMode() )
- {
- CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_DEBRIS );
- if ( pRetRagdoll != NULL )
- *pRetRagdoll = pRagdoll;
- FixupBurningServerRagdoll( pRagdoll );
- RemoveDeferred();
- return true;
- }
- #endif
- #ifdef HL2_DLL
- bool bMegaPhyscannonActive = false;
- #if !defined( HL2MP )
- bMegaPhyscannonActive = HL2GameRules()->MegaPhyscannonActive();
- #endif // !HL2MP
- // Mega physgun requires everything to be a server-side ragdoll
- if ( m_bForceServerRagdoll == true || ( ( bMegaPhyscannonActive == true ) && !IsPlayer() && Classify() != CLASS_PLAYER_ALLY_VITAL && Classify() != CLASS_PLAYER_ALLY ) )
- {
- if ( CanBecomeServerRagdoll() == false )
- return false;
- //FIXME: This is fairly leafy to be here, but time is short!
- CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
- if ( pRetRagdoll != NULL )
- *pRetRagdoll = pRagdoll;
- FixupBurningServerRagdoll( pRagdoll );
- PhysSetEntityGameFlags( pRagdoll, FVPHYSICS_NO_SELF_COLLISIONS );
- RemoveDeferred();
- return true;
- }
- if( hl2_episodic.GetBool() && Classify() == CLASS_PLAYER_ALLY_VITAL )
- {
- CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
- if ( pRetRagdoll != NULL )
- *pRetRagdoll = pRagdoll;
- RemoveDeferred();
- return true;
- }
- #endif //HL2_DLL
- return BecomeRagdollOnClient( forceVector );
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement