Advertisement
code_gs

Untitled

Mar 5th, 2019
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. // IN LUA BINDING //
  2. CBaseEntity *pRagdoll;
  3.  
  4. // Was a ragdoll created?
  5. LUA->PushBool( ent->BecomeRagdoll( info, force, &pRagdoll ) );
  6. LUA->PushUserType( pRagdoll, GarrysMod::Lua::Type::ENTITY );
  7.  
  8. return 2;
  9.  
  10.  
  11. // CODE //
  12. bool CBaseCombatCharacter::BecomeRagdoll( const CTakeDamageInfo &info, const Vector &forceVector, CBaseEntity **pRetRagdoll = NULL )
  13. {
  14. // Clear the return
  15. if ( pRetRagdoll != NULL )
  16. *pRetRagdoll = NULL;
  17.  
  18. if ( (info.GetDamageType() & DMG_VEHICLE) && !g_pGameRules->IsMultiplayer() )
  19. {
  20. CTakeDamageInfo info2 = info;
  21. info2.SetDamageForce( forceVector );
  22. Vector pos = info2.GetDamagePosition();
  23. float flAbsMinsZ = GetAbsOrigin().z + WorldAlignMins().z;
  24. if ( (pos.z - flAbsMinsZ) < 24 )
  25. {
  26. // HACKHACK: Make sure the vehicle impact is at least 2ft off the ground
  27. pos.z = flAbsMinsZ + 24;
  28. info2.SetDamagePosition( pos );
  29. }
  30.  
  31. // UNDONE: Put in a real sound cue here, don't do this bogus hack anymore
  32. #if 0
  33. Vector soundOrigin = info.GetDamagePosition();
  34. CPASAttenuationFilter filter( soundOrigin );
  35.  
  36. EmitSound_t ep;
  37. ep.m_nChannel = CHAN_STATIC;
  38. ep.m_pSoundName = "NPC_MetroPolice.HitByVehicle";
  39. ep.m_flVolume = 1.0f;
  40. ep.m_SoundLevel = SNDLVL_NORM;
  41. ep.m_pOrigin = &soundOrigin;
  42.  
  43. EmitSound( filter, SOUND_FROM_WORLD, ep );
  44. #endif
  45. // in single player create ragdolls on the server when the player hits someone
  46. // with their vehicle - for more dramatic death/collisions
  47. CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, info2, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
  48.  
  49. if ( pRetRagdoll != NULL )
  50. *pRetRagdoll = pRagdoll;
  51.  
  52. FixupBurningServerRagdoll( pRagdoll );
  53. RemoveDeferred();
  54. return true;
  55. }
  56.  
  57. //Fix up the force applied to server side ragdolls. This fixes magnets not affecting them.
  58. CTakeDamageInfo newinfo = info;
  59. newinfo.SetDamageForce( forceVector );
  60.  
  61. #ifdef HL2_EPISODIC
  62. // Burning corpses are server-side in episodic, if we're in darkness mode
  63. if ( IsOnFire() && HL2GameRules()->IsAlyxInDarknessMode() )
  64. {
  65. CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_DEBRIS );
  66.  
  67. if ( pRetRagdoll != NULL )
  68. *pRetRagdoll = pRagdoll;
  69.  
  70. FixupBurningServerRagdoll( pRagdoll );
  71. RemoveDeferred();
  72. return true;
  73. }
  74. #endif
  75.  
  76. #ifdef HL2_DLL
  77.  
  78. bool bMegaPhyscannonActive = false;
  79. #if !defined( HL2MP )
  80. bMegaPhyscannonActive = HL2GameRules()->MegaPhyscannonActive();
  81. #endif // !HL2MP
  82.  
  83. // Mega physgun requires everything to be a server-side ragdoll
  84. if ( m_bForceServerRagdoll == true || ( ( bMegaPhyscannonActive == true ) && !IsPlayer() && Classify() != CLASS_PLAYER_ALLY_VITAL && Classify() != CLASS_PLAYER_ALLY ) )
  85. {
  86. if ( CanBecomeServerRagdoll() == false )
  87. return false;
  88.  
  89. //FIXME: This is fairly leafy to be here, but time is short!
  90. CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
  91.  
  92. if ( pRetRagdoll != NULL )
  93. *pRetRagdoll = pRagdoll;
  94.  
  95. FixupBurningServerRagdoll( pRagdoll );
  96. PhysSetEntityGameFlags( pRagdoll, FVPHYSICS_NO_SELF_COLLISIONS );
  97. RemoveDeferred();
  98.  
  99. return true;
  100. }
  101.  
  102. if( hl2_episodic.GetBool() && Classify() == CLASS_PLAYER_ALLY_VITAL )
  103. {
  104. CBaseEntity *pRagdoll = CreateServerRagdoll( this, m_nForceBone, newinfo, COLLISION_GROUP_INTERACTIVE_DEBRIS, true );
  105.  
  106. if ( pRetRagdoll != NULL )
  107. *pRetRagdoll = pRagdoll;
  108.  
  109. RemoveDeferred();
  110. return true;
  111. }
  112. #endif //HL2_DLL
  113.  
  114. return BecomeRagdollOnClient( forceVector );
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement