HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <amxmodx>
  2. #include <fakemeta>
  3. #include <zombieplague>
  4.  
  5. #define PLUGIN "NST Zombie Class Heal"
  6. #define VERSION "1.0"
  7. #define AUTHOR "NST"
  8.  
  9. new const zclass_name[] = "Saman Zombie"
  10. new const zclass_info[] = "G -> Csapat Gyogyítas"
  11. new const zclass_model[] = "heal_zombi_sserver"
  12. new const zclass_clawmodel[] = "v_knife_heal_zombi.mdl"
  13. const zclass_health = 3200
  14. const zclass_speed = 280
  15. const Float:zclass_gravity = 0.8
  16. const Float:zclass_knockback = 1.5
  17.  
  18. new idclass
  19. new const zombie_sound_heal[] = "zombie_plague/zombi_heal.wav"
  20. new const zombie_sound_healteam[] = "zombie_plague/td_heal.wav"
  21.  
  22. const Float:heal_timewait = 10.0
  23. const Float:heal_dmg = 0.3
  24. const heal_dmg_team = 500
  25. new idsprites_heal
  26.  
  27. new g_heal_wait[33]
  28. new g_msgDamage, g_msgScreenFade, g_msgSayText
  29.  
  30. new g_maxplayers
  31. new g_roundend
  32.  
  33. enum (+= 100)
  34. {
  35. TASK_WAIT_HEAL = 2000,
  36. TASK_BOT_USE_SKILL
  37. }
  38.  
  39. #define ID_WAIT_HEAL (taskid - TASK_WAIT_HEAL)
  40. #define ID_BOT_USE_SKILL (taskid - TASK_BOT_USE_SKILL)
  41.  
  42. public plugin_precache()
  43. {
  44. precache_sound(zombie_sound_heal)
  45. precache_sound(zombie_sound_healteam)
  46.  
  47. idsprites_heal = precache_model("sprites/zb_restore_health.spr")
  48.  
  49. idclass = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  50. }
  51.  
  52. public plugin_init()
  53. {
  54. register_plugin(PLUGIN, VERSION, AUTHOR)
  55.  
  56. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  57. register_event("DeathMsg", "Death", "a")
  58. register_logevent("logevent_round_end", 2, "1=Round_End")
  59.  
  60. register_clcmd("drop", "cmd_heal")
  61.  
  62. g_msgDamage = get_user_msgid("Damage")
  63. g_msgScreenFade = get_user_msgid("ScreenFade")
  64. g_msgSayText = get_user_msgid("SayText")
  65. g_maxplayers = get_maxplayers()
  66. }
  67.  
  68. public client_putinserver(id)
  69. {
  70. reset_value_player(id)
  71. }
  72.  
  73. public client_disconnect(id)
  74. {
  75. reset_value_player(id)
  76. }
  77.  
  78. public event_round_start()
  79. {
  80. g_roundend = 0
  81.  
  82. for (new id=1; id<=g_maxplayers; id++)
  83. {
  84. if (!is_user_connected(id)) continue;
  85.  
  86. reset_value_player(id)
  87. }
  88. }
  89.  
  90. public logevent_round_end()
  91. {
  92. g_roundend = 1
  93. }
  94.  
  95. public Death()
  96. {
  97. new victim = read_data(2)
  98. reset_value_player(victim)
  99. }
  100.  
  101. public zp_user_infected_post(id)
  102. {
  103. reset_value_player(id)
  104.  
  105. if(zp_get_user_nemesis(id)) return;
  106.  
  107. if(zp_get_user_zombie_class(id) == idclass)
  108. {
  109. if(is_user_bot(id))
  110. {
  111. set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  112. return
  113. }
  114.  
  115. zp_colored_print(id, "^x04[ZP]^x01 Saman Zombie vagy. Kepesseged:^x04 Gyogyitas^x01. Hasznalata:^x04 %.1f ^x01masodpercenkent.", heal_timewait)
  116. }
  117. }
  118.  
  119. public zp_user_humanized_post(id)
  120. {
  121. reset_value_player(id)
  122. }
  123.  
  124. public cmd_heal(id)
  125. {
  126. if (g_roundend) return PLUGIN_CONTINUE
  127.  
  128. if (!is_user_alive(id) || !zp_get_user_zombie(id) || zp_get_user_nemesis(id)) return PLUGIN_CONTINUE
  129.  
  130. if (zp_get_user_zombie_class(id) == idclass && !g_heal_wait[id])
  131. {
  132. new start_health = zp_get_zombie_maxhealth(id)
  133. if (get_user_health(id)>=start_health) return PLUGIN_CONTINUE
  134.  
  135. g_heal_wait[id] = 1
  136.  
  137. new Float:health, Float:heath_up, health_set
  138. health = float(get_user_health(id))
  139.  
  140. heath_up = health*heal_dmg
  141. health_set = floatround(health) + max(heal_dmg_team, floatround(heath_up))
  142. health_set = min(start_health, health_set)
  143. fm_set_user_health(id, health_set)
  144.  
  145. UpdateHealthZombieTeam(id)
  146. PlaySound(id, zombie_sound_heal)
  147. EffectRestoreHealth(id)
  148.  
  149. set_task(heal_timewait, "RemoveWaitSmoke", id+TASK_WAIT_HEAL)
  150.  
  151. return PLUGIN_HANDLED
  152. }
  153.  
  154. return PLUGIN_CONTINUE
  155. }
  156.  
  157. public bot_use_skill(taskid)
  158. {
  159. new id = ID_BOT_USE_SKILL
  160.  
  161. if (!is_user_alive(id)) return;
  162.  
  163. cmd_heal(id)
  164.  
  165. set_task(random_float(5.0,15.0), "bot_use_skill", id+TASK_BOT_USE_SKILL)
  166. }
  167.  
  168. public RemoveWaitSmoke(taskid)
  169. {
  170. new id = ID_WAIT_HEAL
  171.  
  172. g_heal_wait[id] = 0
  173.  
  174. zp_colored_print(id, "^x04[ZP]^x01 Újra használhatod a^x04 'Gyógyítás'^x01 képességed.")
  175. }
  176.  
  177. UpdateHealthZombieTeam(id)
  178. {
  179. for (new i = 1; i <= g_maxplayers; i++)
  180. {
  181. if (!is_user_alive(i) || zp_get_user_nemesis(i)) return;
  182.  
  183. if (zp_get_user_zombie(i) && i != id)
  184. {
  185. new current_health = get_user_health(i)
  186. new start_health = zp_get_zombie_maxhealth(i)
  187. if (current_health < start_health)
  188. {
  189. new health_new
  190. health_new = min(start_health, (current_health+heal_dmg_team))
  191. fm_set_user_health(i, health_new)
  192. EffectRestoreHealth(i)
  193. PlaySound(i, zombie_sound_healteam)
  194. }
  195. }
  196. }
  197. }
  198.  
  199. PlaySound(id, const sound[])
  200. {
  201. client_cmd(id, "spk ^"%s^"", sound)
  202. }
  203.  
  204. fm_set_user_health(id, health)
  205. {
  206. (health > 0) ? set_pev(id, pev_health, float(health)) : dllfunc(DLLFunc_ClientKill, id);
  207. }
  208.  
  209. EffectRestoreHealth(id)
  210. {
  211. if (!is_user_alive(id)) return;
  212.  
  213. static origin[3]
  214. get_user_origin(id, origin)
  215.  
  216. message_begin(MSG_PVS, SVC_TEMPENTITY, origin)
  217. write_byte(TE_SPRITE)
  218. write_coord(origin[0])
  219. write_coord(origin[1])
  220. write_coord(origin[2]+30)
  221. write_short(idsprites_heal)
  222. write_byte(5)
  223. write_byte(192)
  224. message_end()
  225.  
  226. message_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade , _, id)
  227. write_short(1<<10)
  228. write_short(1<<10)
  229. write_short(0x0000)
  230. write_byte(255)
  231. write_byte(0)
  232. write_byte(0)
  233. write_byte(75)
  234. message_end()
  235.  
  236. message_begin(MSG_ONE_UNRELIABLE, g_msgDamage, _, id)
  237. write_byte(0)
  238. write_byte(0)
  239. write_long(DMG_NERVEGAS)
  240. write_coord(0)
  241. write_coord(0)
  242. write_coord(0)
  243. message_end()
  244. }
  245.  
  246. reset_value_player(id)
  247. {
  248. g_heal_wait[id] = 0
  249.  
  250. remove_task(id+TASK_WAIT_HEAL)
  251. remove_task(id+TASK_BOT_USE_SKILL)
  252. }
  253.  
  254. zp_colored_print(target, const message[], any:...)
  255. {
  256. static buffer[512], i, argscount
  257. argscount = numargs()
  258.  
  259. if (!target)
  260. {
  261. static player
  262. for (player = 1; player <= g_maxplayers; player++)
  263. {
  264. if (!is_user_connected(player))
  265. continue;
  266.  
  267. static changed[5], changedcount
  268. changedcount = 0
  269.  
  270. for (i = 2; i < argscount; i++)
  271. {
  272. if (getarg(i) == LANG_PLAYER)
  273. {
  274. setarg(i, 0, player)
  275. changed[changedcount] = i
  276. changedcount++
  277. }
  278. }
  279.  
  280. vformat(buffer, charsmax(buffer), message, 3)
  281.  
  282. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, player)
  283. write_byte(player)
  284. write_string(buffer)
  285. message_end()
  286.  
  287. for (i = 0; i < changedcount; i++)
  288. setarg(changed[i], 0, LANG_PLAYER)
  289. }
  290. }
  291. else
  292. {
  293. vformat(buffer, charsmax(buffer), message, 3)
  294.  
  295. message_begin(MSG_ONE, g_msgSayText, _, target)
  296. write_byte(target)
  297. write_string(buffer)
  298. message_end()
  299. }
  300. }
  301. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  302. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  303. */
  304.