HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <hamsandwich>
  4.  
  5. new const VERSION[] = "1.1.1"
  6.  
  7. const MAX_ENTSARRAYS_SIZE = 64
  8.  
  9. new g_bitGonnaExplode[MAX_ENTSARRAYS_SIZE]
  10. #define SetGrenadeExplode(%1) g_bitGonnaExplode[%1>>5] |= 1<<(%1 & 31)
  11. #define ClearGrenadeExplode(%1) g_bitGonnaExplode[%1>>5] &= ~( 1 << (%1 & 31) )
  12. #define WillGrenadeExplode(%1) g_bitGonnaExplode[%1>>5] & 1<<(%1 & 31)
  13.  
  14. const XTRA_OFS_PLAYER = 5
  15. const m_iTeam = 114
  16. #define cs_get_user_team_index(%1) get_pdata_int(%1, m_iTeam, XTRA_OFS_PLAYER)
  17.  
  18. new Float:g_flCurrentGameTime, g_iCurrentFlasher, g_iCurrentFlashBang
  19.  
  20. new mp_friendlyfire
  21.  
  22. new g_iMaxPlayers
  23. #define IsPlayer(%1) ( 1 <= %1 <= g_iMaxPlayers )
  24.  
  25. public plugin_init()
  26. {
  27. register_plugin("Anti Flashbang Bug", VERSION, "Numb / ConnorMcLeod")
  28.  
  29. RegisterHam(Ham_Think, "grenade", "Ham__CGrenade_Think__Pre")
  30.  
  31. register_forward(FM_FindEntityInSphere, "Fm__FindEntityInSphere__Pre")
  32.  
  33. mp_friendlyfire = get_cvar_pointer("mp_friendlyfire")
  34.  
  35. g_iMaxPlayers = get_maxplayers()
  36. }
  37.  
  38. public Ham__CGrenade_Think__Pre( iEnt )
  39. {
  40. static Float:flGameTime, Float:flDmgTime, iOwner
  41. flGameTime = get_gametime()
  42. pev(iEnt, pev_dmgtime, flDmgTime)
  43. if( flDmgTime <= flGameTime
  44. && get_pdata_int(iEnt, 114) == 0 // has a bit when is HE or SMOKE
  45. && !(get_pdata_int(iEnt, 96) & (1<<8)) // has this bit when is c4
  46. && IsPlayer( (iOwner = pev(iEnt, pev_owner)) ) ) // if no owner grenade gonna be removed from world
  47. {
  48. if( ~WillGrenadeExplode(iEnt) ) // grenade gonna explode on next think
  49. {
  50. SetGrenadeExplode( iEnt )
  51. }
  52. else
  53. {
  54. ClearGrenadeExplode( iEnt )
  55. g_flCurrentGameTime = flGameTime
  56. g_iCurrentFlasher = iOwner
  57. g_iCurrentFlashBang = iEnt
  58. }
  59. }
  60. }
  61.  
  62. public Fm__FindEntityInSphere__Pre(iStartEnt, Float:fVecOrigin[3], Float:flRadius)
  63. {
  64. const Float:FLASHBANG_SEARCH_RADIUS = 1500.0
  65. if( flRadius == FLASHBANG_SEARCH_RADIUS
  66. && get_gametime() == g_flCurrentGameTime )
  67. {
  68. new id = iStartEnt, Float:fVecPlayerEyeOrigin[3], Float:flFraction, friendlyfire = get_pcvar_num(mp_friendlyfire)
  69.  
  70. while( IsPlayer( (id=engfunc(EngFunc_FindEntityInSphere, id, fVecOrigin, flRadius)) ) )
  71. {
  72. if( is_user_alive(id) )
  73. {
  74. pev(id, pev_origin, fVecPlayerEyeOrigin)
  75. fVecPlayerEyeOrigin[2] += ((pev(id, pev_flags) & FL_DUCKING) ? 12.0 : 18.0)
  76.  
  77. engfunc(EngFunc_TraceLine, fVecOrigin, fVecPlayerEyeOrigin, DONT_IGNORE_MONSTERS, g_iCurrentFlashBang, 0)
  78.  
  79. get_tr2(0, TR_flFraction, flFraction)
  80.  
  81. if( flFraction < 1.0 && get_tr2(0, TR_pHit) == id )
  82. {
  83. engfunc(EngFunc_TraceLine, fVecPlayerEyeOrigin, fVecOrigin, DONT_IGNORE_MONSTERS, id, 0)
  84. get_tr2(0, TR_flFraction, flFraction)
  85. if( flFraction == 1.0
  86. && ( friendlyfire
  87. || id == g_iCurrentFlasher
  88. || cs_get_user_team_index(id) != cs_get_user_team_index(g_iCurrentFlasher) ) )
  89. {
  90. forward_return(FMV_CELL, id)
  91. return FMRES_SUPERCEDE
  92. }
  93. }
  94. }
  95. }
  96. forward_return(FMV_CELL, 0)
  97. return FMRES_SUPERCEDE
  98. }
  99. return FMRES_IGNORED
  100.  
  101.