HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*================================================================================
  2.  
  3. **********************************************************
  4. *********** [Zombie Plague Executioner 1.1.0] ************
  5. **********************************************************
  6.  
  7. ----------------------
  8. -*- Licensing Info -*-
  9. ----------------------
  10.  
  11. Zombie Plague Executioner
  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. This Zombie can attacks faster with knife as normal.
  45. Attack speed can be change by cvar.
  46.  
  47. ---------------------
  48. -*- Configuration -*-
  49. ---------------------
  50.  
  51. zp_executioner_pri 1 // Allow faster primary attack (slash) [0-disabled / 1-enabled]
  52. zp_executioner_pri_speed 0.33 // primary attack speed (0.5 = reduces attack speed by a half)
  53. zp_executioner_sec 1 // Allow faster secondary attack (stab) [0-disabled / 1-enabled]
  54. zp_executioner_sec_speed 0.33 // secondary attack speed (0.5 = reduces attack speed by a half)
  55. zp_executioner_nemesis 0 // Allow nemesis to faster attack [0-disabled / 1-enabled]
  56.  
  57. --------------------
  58. -*- Requirements -*-
  59. --------------------
  60.  
  61. * Mods: Counter-Strike 1.6 or Condition-Zero
  62. * AMXX: Version 1.8.0 or later
  63. * Module: fakemeta, hamsandwich
  64.  
  65. -----------------
  66. -*- Changelog -*-
  67. -----------------
  68.  
  69. * v1.0.0:
  70. - Initial release Privat (26th Jul 2010)
  71. - Initial release Alliedmodders (5th Feb 2011)
  72.  
  73. * v1.1.0: (11th Feb 2011)
  74. - Added: more cvars, split primary and secondary attack
  75.  
  76. =================================================================================*/
  77.  
  78. #include <amxmodx>
  79. #include <fakemeta>
  80.  
  81. #if AMXX_VERSION_NUM < 180
  82. #assert AMX Mod X v1.8.0 or later library required!
  83. #endif
  84.  
  85. #include <hamsandwich>
  86.  
  87. /*================================================================================
  88.  [Zombie Plague 5.0 Includes]
  89. =================================================================================*/
  90.  
  91. #include <zp50_class_zombie>
  92. #define LIBRARY_NEMESIS "zp50_class_nemesis"
  93. #include <zp50_class_nemesis>
  94.  
  95. /*================================================================================
  96.  [Constants, Offsets, Macros]
  97. =================================================================================*/
  98.  
  99. // Plugin Version
  100. new const PLUGIN_VERSION[] = "1.1.0 (zp50)"
  101.  
  102. // Executioner Zombie
  103. new const zclass_name[] = { "Felgyorsult Zombi" }
  104. new const zclass_info[] = { "Gyors tamadas" }
  105. new const zclass_model[][] = { "zombie_source" }
  106. new const zclass_clawmodel[][] = { "models/zombie_plague/v_knife_zombie.mdl" }
  107. const zclass_health = 2000
  108. const Float:zclass_speed = 1.0
  109. const Float:zclass_gravity = 1.0
  110. const Float:zclass_knockback = 1.0
  111.  
  112. // weapon const
  113. const OFFSET_WEAPONOWNER = 41
  114. const OFFSET_LINUX_WEAPONS = 4
  115. const m_flNextPrimaryAttack = 46
  116. const m_flNextSecondaryAttack = 47
  117.  
  118. /*================================================================================
  119.  [Global Variables]
  120. =================================================================================*/
  121.  
  122. // Player vars
  123. new g_bExecutioner[33] // is Executioner Zombie
  124.  
  125. // Game vars
  126. new g_iExecutionerIndex // index from the class
  127. new g_iMaxPlayers // max player counter
  128.  
  129. // Cvar Pointer
  130. new cvar_Primary, cvar_PrimarySpeed, cvar_Secondary, cvar_SecondarySpeed, cvar_Nemesis
  131.  
  132. public plugin_precache()
  133. {
  134. register_plugin("[ZP] Zombie Class : Executioner", PLUGIN_VERSION, "schmurgel1983")
  135.  
  136. new index
  137. g_iExecutionerIndex = zp_class_zombie_register(zclass_name, zclass_info, zclass_health, zclass_speed, zclass_gravity)
  138. zp_class_zombie_register_kb(g_iExecutionerIndex, zclass_knockback)
  139. for (index = 0; index < sizeof zclass_model; index++)
  140. zp_class_zombie_register_model(g_iExecutionerIndex, zclass_model[index])
  141. for (index = 0; index < sizeof zclass_clawmodel; index++)
  142. zp_class_zombie_register_claw(g_iExecutionerIndex, zclass_clawmodel[index])
  143. }
  144.  
  145. public plugin_init()
  146. {
  147. register_event("HLTV", "event_round_start", "a", "1=0", "2=0")
  148. register_event("DeathMsg", "event_player_death", "a")
  149.  
  150. RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwd_Knife_PriAtk_Post", 1)
  151. RegisterHam(Ham_Weapon_SecondaryAttack, "weapon_knife", "fwd_Knife_SecAtk_Post", 1)
  152.  
  153. cvar_Primary = register_cvar("zp_executioner_pri", "1")
  154. cvar_PrimarySpeed = register_cvar("zp_executioner_pri_speed", "0.33")
  155. cvar_Secondary = register_cvar("zp_executioner_sec", "1")
  156. cvar_SecondarySpeed = register_cvar("zp_executioner_sec_speed", "0.33")
  157. cvar_Nemesis = register_cvar("zp_executioner_nemesis", "0")
  158.  
  159. register_cvar("Executioner_version", PLUGIN_VERSION, FCVAR_SERVER|FCVAR_SPONLY)
  160. set_cvar_string("Executioner_version", PLUGIN_VERSION)
  161.  
  162. g_iMaxPlayers = get_maxplayers()
  163. }
  164.  
  165. public client_putinserver(id) g_bExecutioner[id] = false
  166.  
  167. public client_disconnected(id) g_bExecutioner[id] = false
  168.  
  169. public plugin_natives()
  170. {
  171. set_module_filter("module_filter")
  172. set_native_filter("native_filter")
  173. }
  174.  
  175. public module_filter(const module[])
  176. {
  177. if (equal(module, LIBRARY_NEMESIS))
  178. return PLUGIN_HANDLED;
  179.  
  180. return PLUGIN_CONTINUE;
  181. }
  182.  
  183. public native_filter(const name[], index, trap)
  184. {
  185. if (!trap)
  186. return PLUGIN_HANDLED;
  187.  
  188. return PLUGIN_CONTINUE;
  189. }
  190.  
  191. /*================================================================================
  192.  [Main Forwards]
  193. =================================================================================*/
  194.  
  195. public event_round_start()
  196. {
  197. for (new id = 1; id <= g_iMaxPlayers; id++)
  198. g_bExecutioner[id] = false
  199. }
  200.  
  201. public event_player_death() g_bExecutioner[read_data(2)] = false
  202.  
  203. public fwd_Knife_PriAtk_Post(ent)
  204. {
  205. if (!get_pcvar_num(cvar_Primary))
  206. return HAM_IGNORED;
  207.  
  208. static owner
  209. owner = ham_cs_get_weapon_ent_owner(ent)
  210.  
  211. if (!g_bExecutioner[owner])
  212. return HAM_IGNORED
  213.  
  214. static Float:Speed, Float:Primary, Float:Secondary
  215. Speed = get_pcvar_float(cvar_PrimarySpeed)
  216. Primary = get_pdata_float(ent, m_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS) * Speed
  217. Secondary = get_pdata_float(ent, m_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS) * Speed
  218.  
  219. if (Primary > 0.0 && Secondary > 0.0)
  220. {
  221. set_pdata_float(ent, m_flNextPrimaryAttack, Primary, OFFSET_LINUX_WEAPONS)
  222. set_pdata_float(ent, m_flNextSecondaryAttack, Secondary, OFFSET_LINUX_WEAPONS)
  223. }
  224.  
  225. return HAM_IGNORED;
  226. }
  227.  
  228. public fwd_Knife_SecAtk_Post(ent)
  229. {
  230. if (!get_pcvar_num(cvar_Secondary))
  231. return HAM_IGNORED;
  232.  
  233. static owner
  234. owner = ham_cs_get_weapon_ent_owner(ent)
  235.  
  236. if (!g_bExecutioner[owner])
  237. return HAM_IGNORED
  238.  
  239. static Float:Speed, Float:Primary, Float:Secondary
  240. Speed = get_pcvar_float(cvar_SecondarySpeed)
  241. Primary = get_pdata_float(ent, m_flNextPrimaryAttack, OFFSET_LINUX_WEAPONS) * Speed
  242. Secondary = get_pdata_float(ent, m_flNextSecondaryAttack, OFFSET_LINUX_WEAPONS) * Speed
  243.  
  244. if (Primary > 0.0 && Secondary > 0.0)
  245. {
  246. set_pdata_float(ent, m_flNextPrimaryAttack, Primary, OFFSET_LINUX_WEAPONS)
  247. set_pdata_float(ent, m_flNextSecondaryAttack, Secondary, OFFSET_LINUX_WEAPONS)
  248. }
  249.  
  250. return HAM_IGNORED;
  251. }
  252.  
  253. public zp_fw_core_infect_post(id, attacker)
  254. {
  255. if (zp_class_zombie_get_current(id) == g_iExecutionerIndex)
  256. {
  257. if (LibraryExists(LIBRARY_NEMESIS, LibType_Library) && zp_class_nemesis_get(id) && !get_pcvar_num(cvar_Nemesis)) return
  258.  
  259. g_bExecutioner[id] = true
  260. }
  261. }
  262.  
  263. public zp_fw_core_cure_post(id) g_bExecutioner[id] = false
  264.  
  265. /*================================================================================
  266.  [Stocks]
  267. =================================================================================*/
  268.  
  269. stock ham_cs_get_weapon_ent_owner(entity)
  270. {
  271. if (pev_valid(entity) != 2)
  272. return 0;
  273.  
  274. return get_pdata_cbase(entity, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS);
  275. }
  276.