HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2. * -----------------------------------
  3. * -----[ZP] Zombie Class: Smoker-----
  4. * -----------------------------------
  5. * ------Author: 4eRT (aka pff)-------
  6. * -----------------------------------
  7. * About:
  8. * When Left4Dead came out i immediately thought about Zombie Class Smoker plugin.
  9. * More later(few days ago) I was playing on Superhero Server when i found Scorpion hero.
  10. * So it was the way to create this plugin.
  11. * -----------------------------------
  12. * Discription:
  13. * Smoker is another zombie class for zombie plague like Smoker in L4D.
  14. * He can drags humans by holding "V" or +USE like /\...yeah, like Smoker. If Smoker receives
  15. * 300 damage by human drag ends. If he falls or hurts more 25 dmg drag ends to.
  16. * Drag speed, max drags, cooldown, drag teammates, additional hooks, unable to move & damage to stop
  17. * may be customized by Cvars.
  18. * -----------------------------------
  19. * Credits:
  20. * yang - great thanks for his Scorpion superhero plugin where I borrow harpoon&drag code.
  21. * 5c0r-|3i0 - for his converted Smoker sounds.
  22. * Anggara_nothing - for rewritting Entvars_Set_Vector from Vexd_Utilities to engine. but not very useful :/
  23. * xPaw - really thx for help optimization plugin. For Entity_Set_Vector.
  24. * frk_14 - for his Smoker model.
  25. * -----------------------------------
  26. * Cvars:
  27. * zp_smoker_maxdrags 10 // how many times Smoker can drag player to himself? def=10
  28. * zp_smoker_dragspeed 160 // speed of dragging player to Smoker def=160
  29. * zp_smoker_cooldown 5 // time in sec before you can use drag again. def=5
  30. * zp_smoker_mates 0 // can Smoker drag teammates to? 1=yes 0=no def=0
  31. * zp_smoker_dmg2stop 300 // damage to stop dragging. set 0 to disable it. def=300
  32. * zp_smoker_extrahook 2 // additional hooks after Smoker infects smb. def=2
  33. * zp_smoker_unable_move 1 // 0=human & Smoker can move / 1=unable human to move when dragging / 2=unable Smoker to move / 3=unable both
  34. * zp_smoker_nemesis 0 // 0=Smoker can't drag players if he is Nemesis / 1=Smoker can. def=0
  35. * zp_smoker_survivor 1 // 0=Smoker can't drag Survivor / 1=Smoker can. def=1
  36. * -----------------------------------
  37. * Modules:
  38. * hamsandwich
  39. * fakemeta
  40. * engine
  41. * -----------------------------------
  42. * History:
  43. * 0.0b (14.04.09)
  44. * Most of code converted from sh_scorpion. Added 3 cvars.
  45. * 0.1b (15.04.09)
  46. * Added cooldown, autobind, damage to stop and its cvars.
  47. * Beta testing. First view works perfectly...<- It was wrong belief...>_<
  48. * 0.2b (17.04.09)
  49. * Entvars_Set_Vector now uses engine, not Vexd_Utilities.inc
  50. * 0.3b (19.04.09)
  51. * Fixed cooldown. Now it works more stably. Reduced minimum drag distance.
  52. * 0.3.1b (21.04.09)
  53. * Cooldown works more, more stably. After re-infecting Smoker can use drag
  54. * X times(cvar_maxdrags) if drags left when he was zombie last time.
  55. * Hope i've fixed dragging teammates. Please test it and say: does it work?
  56. * Added Smoker model(+modelT.mdl precacher).
  57. * 0.3.2b (28.04.09)
  58. * Changed Smoker model(lite+without T.mdl -> deleted T.mdl precacher)
  59. * Added 3rd option to zp_smoker_bind - bind on +USE
  60. * 1.0 (09.01.10)
  61. * Yeah. It's not beta now. :) Added autobind menu. Now player can choose: bind V +drag or hold +use to drag. Removed bind cvar.
  62. * Fixed cooldown. Fixed teammate drag. Added extra hook-cvar for infection.
  63. * 1.1 (09.01.10)
  64. * Added unmovable cvar. Added Nemesis and Survivor cvars.
  65. * 1.2 (12.01.10)
  66. * Code optimized. Fixed bugs.
  67. * 1.3 (17.01.10)
  68. * Code optimized.
  69. * -----------------------------------
  70. * PS:
  71. * It's my second useful plugin for amxx so...
  72. */
  73.  
  74. // magyarositas by FD GoD
  75.  
  76. #include <amxmodx>
  77. #include <zombieplague>
  78. #include <fakemeta>
  79. #include <hamsandwich>
  80. #include <engine>
  81.  
  82. #define PLUGIN "[ZP] Class Smoker"
  83. #define VERSION "1.3"
  84. #define AUTHOR "4eRT"
  85.  
  86. //Fo Katergoria, T model & Sprite sugarzas
  87. new g_zclass_smoker, g_Line
  88. new const generic_models[][] = { "models/player/zombie_smoker/zombie_smokerT.mdl" }
  89. //hangok
  90. new g_sndMiss[] = "zombie_plague/Smoker_TongueHit_miss.wav"
  91. new g_sndDrag[] = "zombie_plague/Smoker_TongueHit_drag.wav"
  92. //Some vars
  93. new g_hooked[33], g_hooksLeft[33], g_unable2move[33], g_ovr_dmg[33]
  94. new Float:g_lastHook[33]
  95. new bool: g_bind_use[33] = false, bool: g_bind_or_not[33] = false, bool: g_drag_i[33] = false
  96. //Cavrok
  97. new cvar_maxdrags, cvar_dragspeed, cvar_cooldown, cvar_dmg2stop, cvar_mates, cvar_extrahook, cvar_unb2move, cvar_nemesis, cvar_survivor
  98. //Menu gombok
  99. new keys = MENU_KEY_1|MENU_KEY_2|MENU_KEY_3
  100. //Smoker Tulajdonsagok
  101. new const zclass_name[] = { "Smoker" }
  102. new const zclass_info[] = { "Magahoz huzza a playert" }
  103. new const zclass_model[] = { "zombie_smoker" }
  104. new const zclass_clawmodel[] = { "v_knife_zombie.mdl" }
  105. const zclass_health = 1400
  106. const zclass_speed = 190
  107. const Float:zclass_gravity = 1.0
  108. const Float:zclass_knockback = 1.0
  109.  
  110. public plugin_init()
  111. {
  112. cvar_dragspeed = register_cvar("zp_smoker_dragspeed", "160")
  113. cvar_maxdrags = register_cvar("zp_smoker_maxdrags", "10")
  114. cvar_cooldown = register_cvar("zp_smoker_cooldown", "5")
  115. cvar_dmg2stop = register_cvar("zp_smoker_dmg2stop", "300")
  116. cvar_mates = register_cvar("zp_smoker_mates", "0")
  117. cvar_extrahook = register_cvar("zp_smoker_extrahook", "2")
  118. cvar_unb2move = register_cvar("zp_smoker_unable_move", "1")
  119. cvar_nemesis = register_cvar("zp_smoker_nemesis", "0")
  120. cvar_survivor = register_cvar("zp_smoker_survivor", "1")
  121. register_event("ResetHUD", "newSpawn", "b")
  122. register_event("DeathMsg", "smoker_death", "a")
  123. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  124. RegisterHam(Ham_TakeDamage, "player", "fw_TakeDamage")
  125. register_clcmd("+drag","drag_start", ADMIN_USER, "bind ^"key^" ^"+drag^"")
  126. register_clcmd("-drag","drag_end")
  127. register_menucmd(register_menuid("Do you want to bind V +drag?"), keys, "bind_v_key")
  128. }
  129. public plugin_precache()
  130. {
  131. register_plugin(PLUGIN, VERSION, AUTHOR)
  132. g_zclass_smoker = zp_register_zombie_class(zclass_name, zclass_info, zclass_model, zclass_clawmodel, zclass_health, zclass_speed, zclass_gravity, zclass_knockback)
  133. precache_sound(g_sndDrag)
  134. precache_sound(g_sndMiss)
  135. g_Line = precache_model("sprites/zbeam4.spr")
  136.  
  137. for (new i = 0; i < sizeof generic_models; i++)
  138. precache_model(generic_models[i])
  139. }
  140.  
  141. public zp_user_infected_post(id, infector)
  142. {
  143. if ((zp_get_user_zombie_class(infector) == g_zclass_smoker) && (get_pcvar_num(cvar_extrahook) > 0))
  144. {
  145. g_hooksLeft[infector] = g_hooksLeft[infector] + get_pcvar_num(cvar_extrahook)
  146. set_hudmessage(255, 0, 0, -1.0, 0.45, 0, 0.0, 3.0, 0.01, 0.01, -1)
  147. show_hudmessage(infector, "+%d drag%s!", get_pcvar_num(cvar_extrahook), (get_pcvar_num(cvar_extrahook) < 2) ? "" : "s")
  148. }
  149.  
  150. if (zp_get_user_zombie_class(id) == g_zclass_smoker)
  151. {
  152. g_hooksLeft[id] = get_pcvar_num(cvar_maxdrags)
  153.  
  154. if (!g_bind_or_not[id])
  155. {
  156. new menu[192]
  157. format(menu, 191, "Beakarod bindelni V +drag?^n^n1. Igen^n2. Nem^n3. Slukkolas +USE")
  158. show_menu(id, keys, menu)
  159. }
  160. }
  161. }
  162.  
  163. public newSpawn(id)
  164. {
  165. if (g_hooked[id])
  166. drag_end(id)
  167. }
  168.  
  169. public drag_start(id) // starts drag, checks if player is Smoker, checks cvars
  170. {
  171. if (zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_smoker) && !g_drag_i[id]) {
  172.  
  173. static Float:cdown
  174. cdown = get_pcvar_float(cvar_cooldown)
  175.  
  176. if (!is_user_alive(id)) {
  177. client_print(id, print_chat, "[ZP] Nem slukkolhatsz ha halott vagy!")
  178. return PLUGIN_HANDLED
  179. }
  180.  
  181. if (g_hooksLeft[id] <= 0) {
  182. client_print(id, print_chat, "[ZP] Nem slukkolhatsz tobbet!")
  183. return PLUGIN_HANDLED
  184. }
  185.  
  186. if (get_gametime() - g_lastHook[id] < cdown) {
  187. client_print(id, print_chat, "[ZP] Varj %.f0 masodpercet az ujra slukkolashoz!", get_pcvar_float(cvar_cooldown) - (get_gametime() - g_lastHook[id]))
  188. return PLUGIN_HANDLED
  189. }
  190.  
  191. new hooktarget, body
  192. get_user_aiming(id, hooktarget, body)
  193.  
  194. if (zp_get_user_nemesis(id) && get_pcvar_num(cvar_nemesis) == 0) {
  195. client_print(id, print_chat, "[ZP] Nem slukkolhatsz ha Nemesis vagy!")
  196. return PLUGIN_HANDLED
  197. }
  198.  
  199. if (is_user_alive(hooktarget)) {
  200. if (!zp_get_user_zombie(hooktarget))
  201. {
  202. if (zp_get_user_survivor(hooktarget) && get_pcvar_num(cvar_survivor) == 0) {
  203. client_print(id, print_chat, "[ZP] Nem slukkolhatod a Tulelot!")
  204. return PLUGIN_HANDLED
  205. }
  206.  
  207. g_hooked[id] = hooktarget
  208. emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
  209. }
  210. else
  211. {
  212. if (get_pcvar_num(cvar_mates) == 1)
  213. {
  214. g_hooked[id] = hooktarget
  215. emit_sound(hooktarget, CHAN_BODY, g_sndDrag, 1.0, ATTN_NORM, 0, PITCH_HIGH)
  216. }
  217. else
  218. {
  219. client_print(id, print_chat, "[ZP] Nem slukkolhatod a csapattarsaidat!")
  220. return PLUGIN_HANDLED
  221. }
  222. }
  223.  
  224. if (get_pcvar_float(cvar_dragspeed) <= 0.0)
  225. cvar_dragspeed = 1
  226.  
  227. new parm[2]
  228. parm[0] = id
  229. parm[1] = hooktarget
  230.  
  231. set_task(0.1, "smoker_reelin", id, parm, 2, "b")
  232. harpoon_target(parm)
  233.  
  234. g_hooksLeft[id]--
  235. client_print(id, print_chat, "[ZP] Nem slukkolhatsz embert meg: %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
  236. g_drag_i[id] = true
  237.  
  238. if(get_pcvar_num(cvar_unb2move) == 1)
  239. g_unable2move[hooktarget] = true
  240.  
  241. if(get_pcvar_num(cvar_unb2move) == 2)
  242. g_unable2move[id] = true
  243.  
  244. if(get_pcvar_num(cvar_unb2move) == 3)
  245. {
  246. g_unable2move[hooktarget] = true
  247. g_unable2move[id] = true
  248. }
  249. } else {
  250. g_hooked[id] = 33
  251. noTarget(id)
  252. emit_sound(hooktarget, CHAN_BODY, g_sndMiss, 1.0, ATTN_NORM, 0, PITCH_HIGH)
  253. g_drag_i[id] = true
  254. g_hooksLeft[id]--
  255. client_print(id, print_chat, "[ZP] Slukkolhatsz embert meg: %d time%s", g_hooksLeft[id], (g_hooksLeft[id] < 2) ? "" : "s")
  256. }
  257. }
  258. else
  259. return PLUGIN_HANDLED
  260.  
  261. return PLUGIN_CONTINUE
  262. }
  263.  
  264. public smoker_reelin(parm[]) // slukkolas ember
  265. {
  266. new id = parm[0]
  267. new victim = parm[1]
  268.  
  269. if (!g_hooked[id] || !is_user_alive(victim))
  270. {
  271. drag_end(id)
  272. return
  273. }
  274.  
  275. new Float:fl_Velocity[3]
  276. new idOrigin[3], vicOrigin[3]
  277.  
  278. get_user_origin(victim, vicOrigin)
  279. get_user_origin(id, idOrigin)
  280.  
  281. new distance = get_distance(idOrigin, vicOrigin)
  282.  
  283. if (distance > 1) {
  284. new Float:fl_Time = distance / get_pcvar_float(cvar_dragspeed)
  285.  
  286. fl_Velocity[0] = (idOrigin[0] - vicOrigin[0]) / fl_Time
  287. fl_Velocity[1] = (idOrigin[1] - vicOrigin[1]) / fl_Time
  288. fl_Velocity[2] = (idOrigin[2] - vicOrigin[2]) / fl_Time
  289. } else {
  290. fl_Velocity[0] = 0.0
  291. fl_Velocity[1] = 0.0
  292. fl_Velocity[2] = 0.0
  293. }
  294.  
  295. entity_set_vector(victim, EV_VEC_velocity, fl_Velocity) //<- rewritten. now uses engine
  296. }
  297.  
  298. public drag_end(id) // drags end function
  299. {
  300. g_hooked[id] = 0
  301. beam_remove(id)
  302. remove_task(id)
  303.  
  304. if (g_drag_i[id])
  305. g_lastHook[id] = get_gametime()
  306.  
  307. g_drag_i[id] = false
  308. g_unable2move[id] = false
  309. }
  310.  
  311. public smoker_death() // if smoker dies drag off
  312. {
  313. new id = read_data(2)
  314.  
  315. beam_remove(id)
  316.  
  317. if (g_hooked[id])
  318. drag_end(id)
  319. }
  320.  
  321. public fw_TakeDamage(victim, inflictor, attacker, Float:damage) // if take damage drag off
  322. {
  323. if (is_user_alive(attacker) && (get_pcvar_num(cvar_dmg2stop) > 0))
  324. {
  325. g_ovr_dmg[victim] = g_ovr_dmg[victim] + floatround(damage)
  326. if (g_ovr_dmg[victim] >= get_pcvar_num(cvar_dmg2stop))
  327. {
  328. g_ovr_dmg[victim] = 0
  329. drag_end(victim)
  330. return HAM_IGNORED;
  331. }
  332. }
  333.  
  334. return HAM_IGNORED;
  335. }
  336.  
  337. public fw_PlayerPreThink(id)
  338. {
  339. if (!is_user_alive(id))
  340. return FMRES_IGNORED
  341.  
  342. new button = get_user_button(id)
  343. new oldbutton = get_user_oldbutton(id)
  344.  
  345. if (g_bind_use[id] && zp_get_user_zombie(id) && (zp_get_user_zombie_class(id) == g_zclass_smoker))
  346. {
  347. if (!(oldbutton & IN_USE) && (button & IN_USE))
  348. drag_start(id)
  349.  
  350. if ((oldbutton & IN_USE) && !(button & IN_USE))
  351. drag_end(id)
  352. }
  353.  
  354. if (!g_drag_i[id]) {
  355. g_unable2move[id] = false
  356. }
  357.  
  358. if (g_unable2move[id] && get_pcvar_num(cvar_unb2move) > 0)
  359. {
  360. set_pev(id, pev_maxspeed, 1.0)
  361. }
  362.  
  363. return PLUGIN_CONTINUE
  364. }
  365.  
  366. public client_disconnect(id) // if client disconnects drag off
  367. {
  368. if (id <= 0 || id > 32)
  369. return
  370.  
  371. if (g_hooked[id])
  372. drag_end(id)
  373.  
  374. if(g_unable2move[id])
  375. g_unable2move[id] = false
  376. }
  377.  
  378. public harpoon_target(parm[]) // set beam (ex. tongue:) if target is player
  379. {
  380. new id = parm[0]
  381. new hooktarget = parm[1]
  382.  
  383. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  384. write_byte(8) // TE_BEAMENTS
  385. write_short(id)
  386. write_short(hooktarget)
  387. write_short(g_Line) // sprite index
  388. write_byte(0) // start frame
  389. write_byte(0) // framerate
  390. write_byte(200) // life
  391. write_byte(8) // width
  392. write_byte(1) // noise
  393. write_byte(155) // r, g, b
  394. write_byte(155) // r, g, b
  395. write_byte(55) // r, g, b
  396. write_byte(90) // brightness
  397. write_byte(10) // speed
  398. message_end()
  399. }
  400.  
  401. public bind_v_key(id, keys)
  402. {
  403. g_bind_or_not[id] = true
  404. switch(keys)
  405. {
  406. case 0:
  407. client_cmd(id, "bind v ^"+drag^"")
  408.  
  409. case 1:
  410. client_print(id, print_chat, "[ZP] Ahoz hogy slukkolhass (bind ^'^'gomb^'^' ^'^'+drag^'^') es tartsd nyomva")
  411.  
  412. case 2:
  413. g_bind_use[id] = true
  414.  
  415. default:
  416. g_bind_or_not[id] = false
  417. }
  418.  
  419. return PLUGIN_HANDLED
  420. }
  421.  
  422. public noTarget(id) // set beam if target isn't player
  423. {
  424. new endorigin[3]
  425.  
  426. get_user_origin(id, endorigin, 3)
  427.  
  428. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  429. write_byte( TE_BEAMENTPOINT ); // TE_BEAMENTPOINT
  430. write_short(id)
  431. write_coord(endorigin[0])
  432. write_coord(endorigin[1])
  433. write_coord(endorigin[2])
  434. write_short(g_Line) // sprite index
  435. write_byte(0) // start frame
  436. write_byte(0) // framerate
  437. write_byte(200) // life
  438. write_byte(8) // width
  439. write_byte(1) // noise
  440. write_byte(155) // r, g, b
  441. write_byte(155) // r, g, b
  442. write_byte(55) // r, g, b
  443. write_byte(75) // brightness
  444. write_byte(0) // speed
  445. message_end()
  446. }
  447.  
  448. public beam_remove(id) // remove beam
  449. {
  450. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  451. write_byte(99) //TE_KILLBEAM
  452. write_short(id) //entity
  453. message_end()
  454. }
  455. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  456. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
  457. */