HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*******************************************************************************************************
  2.   AMX Advanced Slow Motion
  3.  
  4.  
  5.   Author: KRoTaL
  6.   Version: 0.1
  7.  
  8.   0.1 Release
  9.  
  10.  
  11.   Cvar:
  12.  
  13.   adv_slowmo "abcdef" - a: c4 explosion in slow motion
  14.   b: last kill in slow motion
  15.   c: grenade kill in slow motion
  16.   d: knife kill in slow motion
  17.   e: hs kill in slow motion
  18.   f: special effect (progressive slowdown)
  19.  
  20.  
  21.   Setup:
  22.  
  23.   Install the amx file.
  24.   Enable VexdUM.
  25.  
  26.  
  27. *******************************************************************************************************/
  28.  
  29. #include <amxmod>
  30. #include <amxmisc>
  31. #include <fun>
  32. #include <VexdUM>
  33. #include <VexdUM_stock>
  34.  
  35. #define SLOWMO_C4EXPLOSION 1
  36. #define SLOWMO_LASTKILL 2
  37. #define SLOWMO_NADEKILL 4
  38. #define SLOWMO_KNIFEKILL 8
  39. #define SLOWMO_HSKILL 16
  40. #define SLOWMO_SPECIALEFFECT 32
  41.  
  42. #define SLOWMO_RATE 0.2
  43.  
  44.  
  45. new g_slowmo[33]
  46. new g_maxplayers
  47. new g_bombPlanted
  48. new Float:g_bombOri[3]
  49. new bool:g_isDead[33]
  50. new g_exploSpr
  51.  
  52. getSlowMoFlags()
  53. {
  54. new flags[32]
  55. get_cvar_string("adv_slowmo", flags, 31)
  56. return read_flags(flags)
  57. }
  58.  
  59. public plugin_init()
  60. {
  61. register_plugin("Advanced Slow Motion", "0.1", "KRoTaL")
  62. register_cvar("adv_slowmo", "abcdef")
  63. register_event("ResetHUD", "resethud_event", "b")
  64. register_event("DeathMsg", "death_event", "a")
  65. register_event("Damage", "damage_event", "b")
  66. register_event("SendAudio","bombplanted_event","a","2&%!MRAD_BOMBPL")
  67. register_event("SendAudio", "end_round", "a", "2&%!MRAD_terwin", "2&%!MRAD_ctwin", "2&%!MRAD_rounddraw")
  68. register_event("TextMsg", "end_round", "a", "2&#Game_C", "2&#Game_w")
  69. g_maxplayers = get_maxplayers() + 1
  70. }
  71.  
  72. public plugin_precache()
  73. {
  74. g_exploSpr = precache_model("sprites/fexplo.spr")
  75. }
  76.  
  77. public client_connect(id)
  78. {
  79. g_slowmo[id] = 0
  80. g_isDead[id] = false
  81. }
  82.  
  83. public resethud_event(id)
  84. {
  85. g_slowmo[id] = 0
  86. g_isDead[id] = false
  87. }
  88.  
  89. public death_event()
  90. {
  91. new id = read_data(2)
  92. new wname[32]
  93. read_data(4, wname, 31)
  94. if(equal(wname, "grenade"))
  95. {
  96. if(getSlowMoFlags() & SLOWMO_NADEKILL)
  97. {
  98. set_task(0.1, "slowDown", id)
  99. set_user_gravity(id, 0.3)
  100. g_slowmo[id] = 1
  101. }
  102. }
  103. if(equal(wname, "knife"))
  104. {
  105. if(getSlowMoFlags() & SLOWMO_KNIFEKILL)
  106. {
  107. g_slowmo[id] = 1
  108. }
  109. }
  110. if(read_data(3) == 1)
  111. {
  112. if(getSlowMoFlags() & SLOWMO_HSKILL)
  113. {
  114. g_slowmo[id] = 1
  115. }
  116. }
  117. new players[32], inum
  118. get_players(players, inum, "ae", (get_user_team(id) == 1) ? "TERRORIST" : "CT")
  119. if(!inum)
  120. {
  121. if(getSlowMoFlags() & SLOWMO_LASTKILL)
  122. {
  123. g_slowmo[id] = 1
  124. }
  125. }
  126. }
  127.  
  128. public damage_event(id)
  129. {
  130. if(!is_user_alive(id))
  131. {
  132. if(g_bombPlanted && !g_isDead[id])
  133. {
  134. new ent = entity_get_edict(id, EV_ENT_dmg_inflictor)
  135. if(is_entity(ent))
  136. {
  137. new classname[32]
  138. entity_get_string(ent, EV_SZ_classname, classname, 31)
  139. new model[32]
  140. entity_get_string(ent, EV_SZ_model, model, 31)
  141. if(equal(classname, "grenade") && equal(model, "")
  142. && entity_get_int(ent, EV_INT_spawnflags) == 1 && entity_get_int(ent, EV_INT_effects) == 128)
  143. {
  144. if(getSlowMoFlags() & SLOWMO_C4EXPLOSION)
  145. {
  146. new Float:vel[3]
  147. entity_get_vector(id, EV_VEC_velocity, vel)
  148. set_task(0.1, "slowDown", id)
  149. set_user_gravity(id, 0.3)
  150. g_slowmo[id] = 1
  151. }
  152. g_isDead[id] = true
  153. }
  154. }
  155. }
  156. }
  157. }
  158.  
  159. public slowDown(id)
  160. {
  161. new Float:vel[3]
  162. entity_get_vector(id, EV_VEC_velocity, vel)
  163. vel[0] /= 3.0
  164. vel[1] /= 3.0
  165. vel[2] /= 2.0
  166. entity_set_vector(id, EV_VEC_velocity, vel)
  167. }
  168.  
  169. public bombplanted_event()
  170. {
  171. g_bombPlanted = 1
  172. new c4 = find_entity(-1, "grenade")
  173. while(c4 > 0)
  174. {
  175. new model[32]
  176. entity_get_string(c4, EV_SZ_model, model, 31)
  177. if(equal(model, "models/w_c4.mdl"))
  178. {
  179. entity_get_vector(c4, EV_VEC_origin, g_bombOri)
  180. return
  181. }
  182. c4 = find_entity(c4, "grenade")
  183. }
  184. }
  185.  
  186. public bombexploded_event()
  187. {
  188. if(getSlowMoFlags() & SLOWMO_C4EXPLOSION)
  189. {
  190. new ori[3]
  191. FVecIVec(g_bombOri, ori)
  192. message_begin(MSG_PVS, SVC_TEMPENTITY, ori)
  193. write_byte(3)
  194. write_coord(ori[0])
  195. write_coord(ori[1])
  196. write_coord(ori[2])
  197. write_short(g_exploSpr)
  198. write_byte(30)
  199. write_byte(1)
  200. write_byte(0)
  201. message_end()
  202. }
  203. }
  204.  
  205. public end_round()
  206. {
  207. set_task(2.0, "resetBombPlanted", 9798415)
  208. }
  209.  
  210. public resetBombPlanted()
  211. {
  212. g_bombPlanted = 0
  213. }
  214.  
  215. public server_frame()
  216. {
  217. for(new i = 1; i < g_maxplayers; i++)
  218. {
  219. if(g_slowmo[i] == 1)
  220. {
  221. if(getSlowMoFlags() & SLOWMO_SPECIALEFFECT)
  222. {
  223. new Float:fr = entity_get_float(i, EV_FL_framerate)
  224. fr = (fr > SLOWMO_RATE) ? (fr - 0.03) : SLOWMO_RATE
  225. entity_set_float(i, EV_FL_framerate, fr)
  226. }
  227. else
  228. {
  229. entity_set_float(i, EV_FL_framerate, SLOWMO_RATE)
  230. }
  231. }
  232. }
  233. return PLUGIN_CONTINUE
  234. }