HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. ---------------------------------------------------------
  3.   # # # #=== ### ## #
  4.   # ## #=== # # # #
  5.   # # #=== ### ## #
  6. ---------------------------------------------------------
  7. Gib Death 1.7
  8.  
  9. Plugin made by <VeCo>
  10. Special thanks to:
  11.  - IMBA : for removing the death bodies.
  12.  - hateYou : for the optimization
  13.  - papyrus_kn : for the video of the plugin
  14.  - alan_el_more : for using Ham_Spawn instead of ResetHUD
  15.  - Nextra : for the optimization
  16.  - Arkshine : for fixing the bugs in version 1.7
  17.  
  18. If you modify the code, please DO NOT change the author!
  19. ---------------------------------------------------------
  20. Contacts:
  21. e-mail: veco.kn@gmail.com
  22. skype: veco_kn
  23. ---------------------------------------------------------
  24. Changes log:
  25.  -> v 1.0 = First release!
  26.  -> v 1.1 = Optimization.
  27.  -> v 1.2 = Fixed bug with spectators.
  28.   Fixed bug with some of materials.
  29.   Plugin needs fun module.
  30. Added two new materials.
  31.  -> v 1.3 = Fixed part of code for removing
  32. the death bodies.
  33. Plugin doesn't needs engine module.
  34. Added new material.
  35.  -> v 1.4 = Changed ResetHUD to Ham_Spawn.
  36.   Plugin needs hamsandwich module.
  37. Removed fun module.
  38.  -> v 1.5 = Optimization.
  39.   Added new material.
  40.  -> v 1.6 = Added CVAR for changing the spread of the gibs.
  41.   Optimization.
  42. Added new material.
  43.  -> v 1.7 = Fixed a lot of bugs.
  44. Plugin doesn't need fakemeta module.
  45. Plugin needs engine and fun modules.
  46. ---------------------------------------------------------
  47. Don't forget to visit http://www.amxmodxbg.org :)
  48. ---------------------------------------------------------
  49. */
  50.  
  51. #include <amxmodx>
  52. #include <fun>
  53. #include <engine>
  54. #include <hamsandwich>
  55.  
  56. enum GIBS
  57. {
  58. HGIBS = 1,
  59. GGIBS,
  60. WGIBS,
  61. MGIBS,
  62. CGIBS,
  63. CEGIBS,
  64. COGIBS,
  65. RGIBS,
  66. BGIBS,
  67. GAGIBS,
  68. BOGIBS,
  69. PGIBS,
  70. WGIBS
  71. }
  72.  
  73. new gcvar,scvar,material[33],gibtypes[GIBS]
  74. public plugin_precache()
  75. {
  76. gibtypes[HGIBS] = precache_model("models/hgibs.mdl")
  77. gibtypes[GGIBS] = precache_model("models/glassgibs.mdl")
  78. gibtypes[WGIBS] = precache_model("models/woodgibs.mdl")
  79. gibtypes[MGIBS] = precache_model("models/metalplategibs.mdl")
  80. gibtypes[CGIBS] = precache_model("models/cindergibs.mdl")
  81. gibtypes[CEGIBS] = precache_model("models/ceilinggibs.mdl")
  82. gibtypes[COGIBS] = precache_model("models/computergibs.mdl")
  83. gibtypes[RGIBS] = precache_model("models/rockgibs.mdl")
  84. gibtypes[BGIBS] = precache_model("models/bookgibs.mdl")
  85. gibtypes[GAGIBS] = precache_model("models/garbagegibs.mdl")
  86. gibtypes[BOGIBS] = precache_model("models/bonegibs.mdl")
  87. gibtypes[PGIBS] = precache_model("models/cactusgibs.mdl")
  88. gibtypes[WGIBS] = precache_model("models/webgibs.mdl")
  89. }
  90.  
  91. public plugin_init() {
  92. register_plugin("Gib Death", "1.7", "VeCo")
  93. register_event("DeathMsg","hook_death","a")
  94. RegisterHam(Ham_Spawn,"player","reset_vis",1)
  95. gcvar = register_cvar("gib_type","0")
  96. scvar = register_cvar("gib_spread","10")
  97. register_cvar("gib_version", "1.7", FCVAR_SERVER|FCVAR_SPONLY)
  98. set_msg_block( get_user_msgid( "ClCorpse" ), BLOCK_SET )
  99. }
  100.  
  101. public hook_death()
  102. {
  103. new id = read_data(2)
  104. set_user_rendering(id,kRenderFxNone,255,255,255,kRenderTransAlpha,0)
  105. gib_death(id)
  106. }
  107.  
  108. public gib_death(id)
  109. {
  110. new origin[3]
  111. get_user_origin(id,origin)
  112.  
  113. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  114. write_byte(TE_BREAKMODEL)
  115. write_coord(origin[0])
  116. write_coord(origin[1])
  117. write_coord(origin[2] + 24)
  118. write_coord(16)
  119. write_coord(16)
  120. write_coord(16)
  121. write_coord(random_num(-50,50))
  122. write_coord(random_num(-50,50))
  123. write_coord(25)
  124. write_byte(get_pcvar_num(scvar))
  125.  
  126. new gibvalue = clamp(get_pcvar_num(gcvar),0,13)
  127. if(!gibvalue)
  128. {
  129. new rnum = random_num(1,13)
  130. write_short(gibtypes[GIBS:rnum])
  131. material[id] = rnum
  132. } else {
  133. write_short(gibtypes[GIBS:gibvalue])
  134. material[id] = gibvalue
  135. }
  136.  
  137. write_byte(14)
  138. write_byte(30)
  139.  
  140. switch(material[id])
  141. {
  142. case 2: write_byte(0x01)
  143. case 3: write_byte(0x08)
  144. case 4,7: write_byte(0x02)
  145. case 5,6,11: write_byte(0x04)
  146. default: write_byte(0)
  147. }
  148.  
  149. message_end()
  150. }
  151.  
  152. public reset_vis(id)
  153. {
  154. if(!is_user_alive(id)) return
  155. set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,0)
  156. }
  157.