HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <engine>
  4.  
  5. #define FL_EXPLODED FL_IMMUNE_SLIME
  6.  
  7. #define m_usEvent 114
  8. #define XO_WEAPON 4
  9.  
  10. #define HEGRENADE (1<<0)
  11. #define SMOKENADE (1<<1)
  12.  
  13. new cvar_AffectRadius, cvar_SurvivalChance
  14.  
  15. public plugin_init()
  16. {
  17. register_plugin("HEs destroy grenades", "1.0", "beast")
  18.  
  19. register_think("grenade", "ThinkGrenade")
  20.  
  21. cvar_AffectRadius = register_cvar("hdg_affect_radius", "350")
  22. cvar_SurvivalChance = register_cvar("hdg_survival_chance", "3")
  23. }
  24.  
  25. public ThinkGrenade(he)
  26. {
  27. // ent not valid or not a HE
  28. if(!pev_valid(he) || ~get_pdata_int(he, m_usEvent, XO_WEAPON) & HEGRENADE)
  29. return PLUGIN_CONTINUE
  30.  
  31. static flags
  32.  
  33. flags = pev(he, pev_flags)
  34.  
  35. // grenade has exploded
  36. if(flags & FL_EXPLODED)
  37. return PLUGIN_CONTINUE
  38.  
  39. static Float:dmgTime
  40.  
  41. pev(he, pev_dmgtime, dmgTime)
  42.  
  43. // not ready to explode yet
  44. if(dmgTime > get_gametime())
  45. return PLUGIN_CONTINUE
  46.  
  47. // marking the grenade as exploded
  48. set_pev(he, pev_flags, flags | FL_EXPLODED)
  49.  
  50. static nearbyNades[32], count, nearbyNade, Float:affectRadius, survivalChance,
  51. Float:originHe[3], Float:originNearbyNade[3]
  52.  
  53. affectRadius = get_pcvar_float(cvar_AffectRadius)
  54. survivalChance = get_pcvar_num(cvar_SurvivalChance)
  55.  
  56. pev(he, pev_origin, originHe)
  57.  
  58. // finding nearby grenades
  59. count = find_sphere_class(he, "grenade", affectRadius, nearbyNades, charsmax(nearbyNades))
  60.  
  61. for(new i = 0; i < count; i++)
  62. {
  63. nearbyNade = nearbyNades[i]
  64.  
  65. if(nearbyNade == he)
  66. continue
  67.  
  68. if(survivalChance)
  69. {
  70. pev(nearbyNade, pev_origin, originNearbyNade)
  71.  
  72. // grenade has a chance to survive
  73. if(random_float(0.0, 100.0) <= survivalChance + // some distance randomness
  74. get_distance_f(originHe, originNearbyNade) * random_float(0.0, 5.0) / affectRadius)
  75. continue
  76. }
  77.  
  78. // detonating he and flashbang
  79. set_pev(nearbyNade, pev_dmgtime, 0.0)
  80.  
  81. // detonating smokenade
  82. if(get_pdata_int(nearbyNade, m_usEvent, XO_WEAPON) & SMOKENADE)
  83. {
  84. set_pev(nearbyNade, pev_flags, pev(nearbyNade, pev_flags) | FL_ONGROUND)
  85. dllfunc(DLLFunc_Think, nearbyNade)
  86. }
  87. }
  88.  
  89. return PLUGIN_CONTINUE
  90. }
  91. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  92. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1063\\ f0\\ fs16 \n\\ par }
  93. */
  94.