HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*================================================================================
  2.  
  3. ****************************************************
  4. *********** [Zombie Plague Blink 1.2.0] ************
  5. ****************************************************
  6.  
  7. ----------------------
  8. -*- Licensing Info -*-
  9. ----------------------
  10.  
  11. Zombie Plague Blink
  12. by schmurgel1983(@msn.com)
  13. Copyright (C) 2010-2011 Stefan "schmurgel1983" Focke
  14.  
  15. This program is free software: you can redistribute it and/or modify it
  16. under the terms of the GNU General Public License as published by the
  17. Free Software Foundation, either version 3 of the License, or (at your
  18. option) any later version.
  19.  
  20. This program is distributed in the hope that it will be useful, but
  21. WITHOUT ANY WARRANTY; without even the implied warranty of
  22. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
  23. Public License for more details.
  24.  
  25. You should have received a copy of the GNU General Public License along
  26. with this program. If not, see <http://www.gnu.org/licenses/>.
  27.  
  28. In addition, as a special exception, the author gives permission to
  29. link the code of this program with the Half-Life Game Engine ("HL
  30. Engine") and Modified Game Libraries ("MODs") developed by Valve,
  31. L.L.C ("Valve"). You must obey the GNU General Public License in all
  32. respects for all of the code used other than the HL Engine and MODs
  33. from Valve. If you modify this file, you may extend this exception
  34. to your version of the file, but you are not obligated to do so. If
  35. you do not wish to do so, delete this exception statement from your
  36. version.
  37.  
  38. No warranties of any kind. Use at your own risk.
  39.  
  40. -------------------
  41. -*- Description -*-
  42. -------------------
  43.  
  44. Teleport on high or low places are now for Zombies, after teleport
  45. u can't attack, and have a black screen so u don't see anything.
  46. The Teleport has the flashbang sound and special effects.
  47. A cooldown cvar controlled the blink so u don't can spam.
  48.  
  49. ---------------------
  50. -*- Configuration -*-
  51. ---------------------
  52.  
  53. zp_blink_cooldown 15.0 // Cooldown befor allow next blink
  54. zp_blink_no_atk_time 1.5 // how long can't attack after blink in seconds
  55. zp_blink_range 1234 // Maximum range from blink
  56. zp_blink_nemesis 0 // Allow nemesis to blink [0-disabled / 1-enabled]
  57. zp_blink_button 1 // wich button u push to blink [0-use / 1-reload]
  58. zp_blink_bots 1 // bots automatic blink [0-disabled / 1-enabled]
  59.  
  60. --------------------
  61. -*- Requirements -*-
  62. --------------------
  63.  
  64. * Mods: Counter-Strike 1.6 or Condition-Zero
  65. * AMXX: Version 1.8.0 or later
  66. * Module: fakemeta, hamsandwich
  67.  
  68. -----------------
  69. -*- Changelog -*-
  70. -----------------
  71.  
  72. * v1.0.0:
  73. - Initial release Privat (9th Aug 2010)
  74. - Initial release Alliedmodders (4th Feb 2011)
  75.  
  76. * v1.1.0: (5th Feb 2011)
  77. - Added: cvar to choose the teleport button,
  78. bots are use now Teleport too
  79.  
  80. * v1.2.0: (6th Feb 2011)
  81. - Added: cvar to controlled the "no attack time"
  82. after teleport
  83.  
  84. =================================================================================*/
  85.  
  86. #include <amxmodx>
  87. #include <fakemeta>
  88. #include <xs>
  89.  
  90. #if AMXX_VERSION_NUM < 180
  91. #assert AMX Mod X v1.8.0 or later library required!
  92. #endif
  93.  
  94. #include <hamsandwich>
  95.  
  96. /*================================================================================
  97.  [Zombie Plague 5.0 Includes]
  98. =================================================================================*/
  99.  
  100. #include <zp50_class_zombie>
  101. #define LIBRARY_NEMESIS "zp50_class_nemesis"
  102. #include <zp50_class_nemesis>
  103.  
  104. /*================================================================================
  105.  [Constants, Offsets, Macros]
  106. =================================================================================*/
  107.  
  108. // Plugin Version
  109. new const PLUGIN_VERSION[] = "1.2.0 (zp50)"
  110.  
  111. // Blick Zombie
  112. new const zclass_name[] = { "Teleport zombi" }
  113. new const zclass_info[] = { "Elet- Visszalokes+++ Teleport" }
  114. new const zclass_model[][] = { "zombie_source" }
  115. new const zclass_clawmodel[][] = { "models/zombie_plague/v_knife_zombie.mdl" }
  116. const zclass_health = 3000
  117. const Float:zclass_speed = 0.77
  118. const Float:zclass_gravity = 1.0
  119. const Float:zclass_knockback = 2.0
  120.  
  121. // Ham weapon const
  122. const OFFSET_WEAPONOWNER = 41
  123. const OFFSET_LINUX_WEAPONS = 4
  124.  
  125. // Flashbang sound
  126. new const SOUND_BLINK[] = { "weapons/flashbang-1.wav" }
  127.  
  128. // ScreenFade
  129. const UNIT_SEC = 0x1000 // 1 second
  130. const FFADE = 0x0000
  131.  
  132. /*================================================================================
  133.  [Global Variables]
  134. =================================================================================*/
  135.  
  136. // Player vars
  137. new g_bBlink[33] // is Blink Zombie
  138. new g_bAllowATK[33] // allow to attack
  139. new Float:g_flNextBlink[33] // last blink time
  140.  
  141. // Game vars
  142. new g_iBlinkIndex // index from the class
  143. new g_iMaxPlayers // max player counter
  144.  
  145. // Message IDs vars
  146. new g_msgSayText, g_msgScreenFade
  147.  
  148. // Sprites
  149. new g_iShockwave, g_iFlare
  150.  
  151. // Cvar pointers
  152. new cvar_Cooldown, cvar_Range, cvar_Nemesis,
  153. cvar_Button, cvar_Bots, cvar_NoAttack
  154.  
  155. /*================================================================================
  156.  [Precache and Init]
  157. =================================================================================*/
  158.  
  159. public plugin_precache()
  160. {
  161. register_plugin("[ZP] Zombie Class : Blink", PLUGIN_VERSION, "schmurgel1983")
  162.  
  163. new index
  164. g_iBlinkIndex = zp_class_zombie_register(zclass_name, zclass_info, zclass_health, zclass_speed, zclass_gravity)
  165. zp_class_zombie_register_kb(g_iBlinkIndex, zclass_knockback)
  166. for (index = 0; index < sizeof zclass_model; index++)
  167. zp_class_zombie_register_model(g_iBlinkIndex, zclass_model[index])
  168. for (index = 0; index < sizeof zclass_clawmodel; index++)
  169. zp_class_zombie_register_claw(g_iBlinkIndex, zclass_clawmodel[index])
  170.  
  171. g_iShockwave = precache_model( "sprites/shockwave.spr")
  172. g_iFlare = precache_model( "sprites/blueflare2.spr")
  173. }
  174.  
  175. public plugin_init()
  176. {
  177. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  178. register_event("DeathMsg", "event_player_death", "a")
  179.  
  180. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwd_Knife_Blink")
  181. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fwd_Knife_Blink")
  182.  
  183. register_forward(FM_CmdStart, "fwd_CmdStart")
  184.  
  185. g_msgSayText = get_user_msgid("SayText")
  186. g_msgScreenFade = get_user_msgid("ScreenFade")
  187.  
  188. cvar_Cooldown = register_cvar("zp_blink_cooldown", "15.0")
  189. cvar_NoAttack = register_cvar("zp_blink_no_atk_time", "1.5")
  190. cvar_Range = register_cvar("zp_blink_range", "1234")
  191. cvar_Nemesis = register_cvar("zp_blink_nemesis", "0")
  192. cvar_Button = register_cvar("zp_blink_button", "1")
  193. cvar_Bots = register_cvar("zp_blink_bots", "1")
  194.  
  195. register_cvar("Blink_Zombie_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  196. set_cvar_string("Blink_Zombie_version", PLUGIN_VERSION)
  197.  
  198. g_iMaxPlayers = get_maxplayers()
  199. }
  200.  
  201. public client_putinserver(id) reset_vars(id)
  202.  
  203. public client_disconnected(id) reset_vars(id)
  204.  
  205. public plugin_natives()
  206. {
  207. set_module_filter("module_filter")
  208. set_native_filter("native_filter")
  209. }
  210.  
  211. public module_filter(const module[])
  212. {
  213. if (equal(module, LIBRARY_NEMESIS))
  214. return PLUGIN_HANDLED;
  215.  
  216. return PLUGIN_CONTINUE;
  217. }
  218.  
  219. public native_filter(const name[], index, trap)
  220. {
  221. if (!trap)
  222. return PLUGIN_HANDLED;
  223.  
  224. return PLUGIN_CONTINUE;
  225. }
  226.  
  227. /*================================================================================
  228.  [Main Forwards]
  229. =================================================================================*/
  230.  
  231. public event_round_start()
  232. {
  233. for (new id = 1; id <= g_iMaxPlayers; id++)
  234. reset_vars(id)
  235. }
  236.  
  237. public event_player_death() reset_vars(read_data(2))
  238.  
  239. public fwd_Knife_Blink(ent)
  240. {
  241. static owner
  242. owner = ham_cs_get_weapon_ent_owner(ent)
  243.  
  244. if (!g_bBlink[owner] || g_bAllowATK[owner]) return HAM_IGNORED
  245.  
  246. return HAM_SUPERCEDE
  247. }
  248.  
  249. public fwd_CmdStart(id, handle)
  250. {
  251. if (!g_bBlink[id] || !is_user_alive(id) || get_gametime() < g_flNextBlink[id]) return
  252.  
  253. static button
  254. button = get_uc(handle, UC_Buttons)
  255. if (button & IN_USE && !get_pcvar_num(cvar_Button) || button & IN_RELOAD && get_pcvar_num(cvar_Button))
  256. {
  257. if (teleport(id))
  258. {
  259. emit_sound(id, CHAN_STATIC, SOUND_BLINK, 1.0, ATTN_NORM, 0, PITCH_NORM)
  260.  
  261. g_bAllowATK[id] = false
  262. g_flNextBlink[id] = get_gametime() + get_pcvar_float(cvar_Cooldown)
  263.  
  264. remove_task(id)
  265. set_task(get_pcvar_float(cvar_NoAttack), "allow_attack", id)
  266. set_task(get_pcvar_float(cvar_Cooldown), "show_blink", id)
  267. }
  268. else
  269. {
  270. g_flNextBlink[id] = get_gametime() + 1.0
  271.  
  272. colored_print(id, "^x04[ZP]^x01 Nem birsz oda teleportalni , celozz mashova !")
  273. }
  274. }
  275. }
  276.  
  277. public zp_fw_core_cure_post(id) reset_vars(id)
  278.  
  279. public zp_fw_core_infect_post(id, attacker)
  280. {
  281. if (zp_class_zombie_get_current(id) == g_iBlinkIndex)
  282. {
  283. if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && zp_class_nemesis_get(id) && !get_pcvar_num(cvar_Nemesis)) return
  284.  
  285. g_bBlink[id] = true
  286. g_bAllowATK[id] = true
  287. g_flNextBlink[id] = get_gametime()
  288.  
  289. show_blink(id)
  290. }
  291. }
  292.  
  293. /*================================================================================
  294.  [Other Functions]
  295. =================================================================================*/
  296.  
  297. public allow_attack(id)
  298. {
  299. if (!is_user_connected(id)) return
  300.  
  301. g_bAllowATK[id] = true
  302. }
  303.  
  304. reset_vars(id)
  305. {
  306. remove_task(id)
  307. g_bBlink[id] = false
  308. g_bAllowATK[id] = true
  309. }
  310.  
  311. public show_blink(id)
  312. {
  313. if (!is_user_connected(id) || !g_bBlink[id] || !is_user_alive(id)) return
  314.  
  315. if (!get_pcvar_num(cvar_Button))
  316. colored_print(id, "^x04[Teleport Zombie]^x01 Teleport kepesseg keszen all. Nyomja meg az E-gombot(+use)")
  317. else
  318. colored_print(id, "^x04[Teleport Zombie]^x01 Teleport kepesseg keszen all. Nyomja meg az E-gombot(+use)")
  319.  
  320. // Bot support
  321. if (is_user_bot(id) && get_pcvar_num(cvar_Bots))
  322. set_task(random_float(1.0, 5.0), "bot_will_teleport", id)
  323. }
  324.  
  325. public bot_will_teleport(id)
  326. {
  327. if (!is_user_connected(id) || !g_bBlink[id] || !is_user_alive(id) || !is_user_bot(id)) return
  328.  
  329. if (teleport(id))
  330. {
  331. emit_sound(id, CHAN_STATIC, SOUND_BLINK, 1.0, ATTN_NORM, 0, PITCH_NORM)
  332.  
  333. g_bAllowATK[id] = false
  334.  
  335. remove_task(id)
  336. set_task(get_pcvar_float(cvar_NoAttack), "allow_attack", id)
  337. set_task(get_pcvar_float(cvar_Cooldown), "show_blink", id)
  338. }
  339. else
  340. {
  341. set_task(random_float(1.0, 3.0), "bot_will_teleport", id)
  342. }
  343. }
  344.  
  345. bool:teleport(id)
  346. {
  347. new Float:vOrigin[3], Float:vNewOrigin[3],
  348. Float:vNormal[3], Float:vTraceDirection[3],
  349. Float:vTraceEnd[3]
  350.  
  351. pev(id, pev_origin, vOrigin)
  352.  
  353. velocity_by_aim(id, get_pcvar_num(cvar_Range), vTraceDirection)
  354. xs_vec_add(vTraceDirection, vOrigin, vTraceEnd)
  355.  
  356. engfunc(EngFunc_TraceLine, vOrigin, vTraceEnd, DONT_IGNORE_MONSTERS, id, 0)
  357.  
  358. new Float:flFraction
  359. get_tr2(0, TR_flFraction, flFraction)
  360. if (flFraction < 1.0)
  361. {
  362. get_tr2(0, TR_vecEndPos, vTraceEnd)
  363. get_tr2(0, TR_vecPlaneNormal, vNormal)
  364. }
  365.  
  366. xs_vec_mul_scalar(vNormal, 40.0, vNormal) // do not decrease the 40.0
  367. xs_vec_add(vTraceEnd, vNormal, vNewOrigin)
  368.  
  369. if (is_player_stuck(id, vNewOrigin))
  370. return false;
  371.  
  372. emit_sound(id, CHAN_STATIC, SOUND_BLINK, 1.0, ATTN_NORM, 0, PITCH_NORM)
  373. tele_effect(vOrigin)
  374.  
  375. engfunc(EngFunc_SetOrigin, id, vNewOrigin)
  376.  
  377. tele_effect(vNewOrigin)
  378. tele_effect2(vNewOrigin)
  379.  
  380. emessage_begin(MSG_ONE_UNRELIABLE, g_msgScreenFade, _, id)
  381. ewrite_short(floatround(UNIT_SEC*get_pcvar_float(cvar_NoAttack)))
  382. ewrite_short(floatround(UNIT_SEC*get_pcvar_float(cvar_NoAttack)))
  383. ewrite_short(FFADE)
  384. ewrite_byte(0)
  385. ewrite_byte(0)
  386. ewrite_byte(0)
  387. ewrite_byte(255)
  388. emessage_end()
  389.  
  390. return true;
  391. }
  392.  
  393. colored_print(target, const message[], any:...)
  394. {
  395. static buffer[512]
  396.  
  397. vformat(buffer, charsmax(buffer), message, 3)
  398.  
  399. message_begin(MSG_ONE, g_msgSayText, _, target)
  400. write_byte(target)
  401. write_string(buffer)
  402. message_end()
  403. }
  404.  
  405. /*================================================================================
  406.  [Stocks]
  407. =================================================================================*/
  408.  
  409. stock is_player_stuck(id, Float:originF[3])
  410. {
  411. engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  412.  
  413. if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  414. return true;
  415.  
  416. return false;
  417. }
  418.  
  419. stock ham_cs_get_weapon_ent_owner(entity)
  420. {
  421. if (pev_valid(entity) != 2)
  422. return 0;
  423.  
  424. return get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  425. }
  426.  
  427. stock tele_effect(const Float:torigin[3])
  428. {
  429. new origin[3]
  430. origin[0] = floatround(torigin[0])
  431. origin[1] = floatround(torigin[1])
  432. origin[2] = floatround(torigin[2])
  433.  
  434. message_begin(MSG_PAS, SVC_TEMPENTITY, origin)
  435. write_byte(TE_BEAMCYLINDER)
  436. write_coord(origin[0])
  437. write_coord(origin[1])
  438. write_coord(origin[2]+10)
  439. write_coord(origin[0])
  440. write_coord(origin[1])
  441. write_coord(origin[2]+60)
  442. write_short(g_iShockwave)
  443. write_byte(0)
  444. write_byte(0)
  445. write_byte(3)
  446. write_byte(60)
  447. write_byte(0)
  448. write_byte(255)
  449. write_byte(255)
  450. write_byte(255)
  451. write_byte(255)
  452. write_byte(0)
  453. message_end()
  454. }
  455.  
  456. stock tele_effect2(const Float:torigin[3])
  457. {
  458. new origin[3]
  459. origin[0] = floatround(torigin[0])
  460. origin[1] = floatround(torigin[1])
  461. origin[2] = floatround(torigin[2])
  462.  
  463. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  464. write_byte(TE_SPRITETRAIL)
  465. write_coord(origin[0])
  466. write_coord(origin[1])
  467. write_coord(origin[2]+40)
  468. write_coord(origin[0])
  469. write_coord(origin[1])
  470. write_coord(origin[2])
  471. write_short(g_iFlare)
  472. write_byte(30)
  473. write_byte(10)
  474. write_byte(1)
  475. write_byte(50)
  476. write_byte(10)
  477. message_end()
  478. }
  479.