HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #define FCVAR_FLAGS (FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
  2.  
  3. new const NADE_TYPE_ZKILLBOMB = 7979
  4. new const Float:RADIUS = 240.0
  5.  
  6. new const sprite_grenade_trail[] = "sprites/laserbeam.spr"
  7.  
  8. new const sprite_grenade_ring[] = "sprites/shockwave.spr"
  9.  
  10. new const item_cost = 20
  11.  
  12. new const item_name[] = "Gyilkos Gra'na't"
  13.  
  14. new const recieving_sound[] = "items/9mmclip1.wav"
  15.  
  16. new const kill_sound[] = "zombie_plague/grenade_infect.wav"
  17.  
  18. new const info_notice[] = { "Sikeresen vettel egy Gyilkos Gra'na'tot!" }
  19.  
  20. new const info_notice2[] = { "Neked van 1 Gyilkos Gra'na'tod ! Hasznald Ember Ole'sre !" }
  21.  
  22. new const model_grenade_infect[] = "models/zombie_plague/v_kill_bomb.mdl"
  23.  
  24. #include <amxmodx>
  25. #include <hamsandwich>
  26. #include <cstrike>
  27. #include <fakemeta_util>
  28. #if defined EDITTED_VERSION
  29. #include <zombieplaguenew1.3>
  30. #else
  31. #include <zombieplague>
  32. #endif
  33.  
  34. // Variables
  35. new item_id
  36. new has_bomb[33]
  37. new cvar_fragsinfect, cvar_ammoinfect, cvar_humanbonushp , cvar_nemnade
  38. #if defined EDITTED_VERSION
  39. new cvar_assnade
  40. #endif
  41. new g_SyncMsg
  42. new g_trailSpr, g_exploSpr, g_msgScoreInfo, g_msgDeathMsg, g_msgAmmoPickup, g_msgSayText
  43.  
  44. /************************************************************\
  45. | [Plugin Initialization And Precache] |
  46. \************************************************************/
  47.  
  48. public plugin_init()
  49. {
  50. // Registrations
  51. register_plugin("[ZP] Kill Bomb For Zombies", "1.0", "@bdul!")
  52. RegisterHam(Ham_Think, "grenade", "fw_ThinkGrenade")
  53. RegisterHam(Ham_Killed, "player", "fw_PlayerKilled")
  54. register_forward(FM_SetModel, "fw_SetModel")
  55. register_message(get_user_msgid("CurWeapon"), "message_cur_weapon")
  56. register_message(g_msgAmmoPickup, "message_ammopickup")
  57. register_event ( "HLTV", "event_round_start", "a", "1=0", "2=0" );
  58.  
  59. // Cvars [You can edit these to you're liking]
  60. cvar_humanbonushp = register_cvar("zp_zkill_bomb_extra_hp","100")
  61. cvar_fragsinfect = register_cvar("zp_zkill_bomb_extra_frags","1")
  62. cvar_ammoinfect = register_cvar("zp_zkill_bomb_ammo_packs","1")
  63. cvar_nemnade = register_cvar("zp_zkill_bomb_nem","1")
  64. #if defined EDITTED_VERSION
  65. cvar_assnade = register_cvar("zp_zkill_bomb_assassin","1")
  66. #endif
  67.  
  68. // Add the cvar so we can detect it
  69. register_cvar ( "zp_zkill_bomb", "1.0", FCVAR_FLAGS )
  70.  
  71. // Messages needed for the plugin
  72. g_msgScoreInfo = get_user_msgid("ScoreInfo")
  73. g_msgDeathMsg = get_user_msgid("DeathMsg")
  74. g_msgAmmoPickup = get_user_msgid("AmmoPickup")
  75. g_msgSayText = get_user_msgid("SayText")
  76.  
  77. g_SyncMsg = CreateHudSyncObj()
  78. }
  79.  
  80. public plugin_precache()
  81. {
  82. // Sprites precache
  83. g_trailSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_trail)
  84. g_exploSpr = engfunc(EngFunc_PrecacheModel, sprite_grenade_ring)
  85.  
  86. // Model precache
  87. engfunc(EngFunc_PrecacheModel, model_grenade_infect)
  88.  
  89. // Sounds precache
  90. engfunc(EngFunc_PrecacheSound, recieving_sound)
  91. engfunc(EngFunc_PrecacheSound, kill_sound)
  92.  
  93. // Register it in the extra items
  94. item_id = zp_register_extra_item(item_name,item_cost,ZP_TEAM_ZOMBIE)
  95. }
  96.  
  97. /************************************************************\
  98. | [Main Forwards] |
  99. \************************************************************/
  100.  
  101. // New round started so reset the variable
  102. public event_round_start()
  103. {
  104. arrayset(has_bomb, false, 33)
  105. }
  106.  
  107. // Client disconnected so reset the variable
  108. public client_disconnect(id)
  109. {
  110. has_bomb[id] = 0
  111. }
  112.  
  113. // Someone was turned into nemesis
  114. public zp_user_infected_post(id, infector)
  115. {
  116. // Make sure it is a nemesis and the cvar is also on
  117. if (zp_get_user_nemesis(id) && (get_pcvar_num(cvar_nemnade) == 1))
  118. give_the_bomb(id) // Give him the bomb
  119.  
  120. #if defined EDITTED_VERSION
  121. // Make sure it is an assassin and the cvar is also on
  122. else if (zp_get_user_assassin(id) && (get_pcvar_num(cvar_assnade) == 1))
  123. give_the_bomb(id) // Give him the bomb
  124. #endif
  125. }
  126.  
  127. // Someone selected our extra item
  128. public zp_extra_item_selected(id, itemid)
  129. {
  130. // Make sure that the selected item is our item
  131. if(itemid == item_id)
  132. {
  133. // Give him the bomb
  134. give_the_bomb(id)
  135. }
  136. }
  137.  
  138. // The player turned back to a human
  139. public zp_user_humanized_post ( Player, Survivor )
  140. {
  141. // He doesn't haves the nade anymore
  142. if (has_bomb[Player])
  143. has_bomb[Player] = 0
  144. }
  145.  
  146. // Player got killed reset the variable
  147. public fw_PlayerKilled(victim, attacker, shouldgib)
  148. {
  149. has_bomb[victim] = 0
  150. }
  151.  
  152. public fw_ThinkGrenade(entity)
  153. {
  154. if(!pev_valid(entity))
  155. return HAM_IGNORED
  156.  
  157. static Float:dmgtime
  158. pev(entity, pev_dmgtime, dmgtime)
  159.  
  160. if (dmgtime > get_gametime())
  161. return HAM_IGNORED
  162.  
  163. if(pev(entity, pev_flTimeStepSound) == NADE_TYPE_ZKILLBOMB)
  164. {
  165. kill_explode(entity)
  166. return HAM_SUPERCEDE
  167. }
  168.  
  169. return HAM_IGNORED
  170. }
  171.  
  172. public fw_SetModel(entity, const model[])
  173. {
  174. static Float:dmgtime
  175. pev(entity, pev_dmgtime, dmgtime)
  176.  
  177. if (dmgtime == 0.0)
  178. return
  179.  
  180. if (equal(model[7], "w_sm", 4))
  181. {
  182. // Check whos is the owner of the nade
  183. new owner = pev(entity, pev_owner)
  184.  
  185. // Make sure only a zombie can own it
  186. if(zp_get_user_zombie(owner) && has_bomb[owner])
  187. {
  188. // Set the glow on the model
  189. fm_set_rendering(entity, kRenderFxGlowShell, 255, 128, 0, kRenderNormal, 16)
  190.  
  191. // Set the trail sprite
  192. message_begin(MSG_BROADCAST, SVC_TEMPENTITY)
  193. write_byte(TE_BEAMFOLLOW) // TE id
  194. write_short(entity) // entity
  195. write_short(g_trailSpr) // sprite
  196. write_byte(10) // life
  197. write_byte(10) // width
  198. write_byte(255) // r
  199. write_byte(128) // g
  200. write_byte(0) // b
  201. write_byte(200) // brightness
  202. message_end()
  203.  
  204. set_pev(entity, pev_flTimeStepSound, NADE_TYPE_ZKILLBOMB)
  205. }
  206. }
  207.  
  208. }
  209.  
  210. /************************************************************\
  211. | [Main funtions] |
  212. \************************************************************/
  213.  
  214. // Grenade has exploded
  215. public kill_explode(ent)
  216. {
  217. // Has the round started ?
  218. if (!zp_has_round_started()) return
  219.  
  220. // Get the Origin
  221. static Float:originF[3]
  222. pev(ent, pev_origin, originF)
  223.  
  224. // Create the blast
  225. create_blast(originF)
  226.  
  227. // Emit explosion sound
  228. engfunc(EngFunc_EmitSound, ent, CHAN_ITEM, kill_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  229.  
  230. // Get the attacker
  231. static attacker
  232. attacker = pev(ent, pev_owner)
  233. has_bomb[attacker] = 0
  234.  
  235. // Collisions
  236. static victim , deathmsg_block
  237.  
  238. // Get the current state of DeathMsg
  239. deathmsg_block = get_msg_block(g_msgDeathMsg)
  240.  
  241. // Set it to be blocked [Bug Fix]
  242. set_msg_block(g_msgDeathMsg, BLOCK_SET)
  243. victim = -1
  244.  
  245. #if defined EDITTED_VERSION
  246. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, RADIUS)) != 0)
  247. {
  248. // If dead, zombie, survivor or sniper then continue the loop
  249. if (!is_user_alive(victim) || zp_get_user_zombie(victim) || zp_get_user_survivor(victim)|| zp_get_user_sniper(victim))
  250. continue;
  251.  
  252. // Send the Death message
  253. SendDeathMsg(attacker, victim)
  254.  
  255. // Update the frags
  256. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect), 1, 1)
  257.  
  258. // Kill the victim
  259. user_kill(victim, 0)
  260.  
  261. // Set the attackers ammo packs
  262. zp_set_user_ammo_packs(attacker,zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_ammoinfect))
  263.  
  264. // Set the attackers health
  265. fm_set_user_health(attacker, pev(attacker, pev_health)+get_pcvar_num(cvar_humanbonushp))
  266. }
  267. #else
  268. while ((victim = engfunc(EngFunc_FindEntityInSphere, victim, originF, RADIUS)) != 0)
  269. {
  270. // If dead, zombie, survivor then continue the loop
  271. if (!is_user_alive(victim) || zp_get_user_zombie(victim) || zp_get_user_survivor(victim))
  272. continue;
  273.  
  274. // Send the Death message
  275. SendDeathMsg(attacker, victim)
  276.  
  277. // Update the frags
  278. UpdateFrags(attacker, victim, get_pcvar_num(cvar_fragsinfect), 1, 1)
  279.  
  280. // Kill the victim
  281. user_kill(victim, 0)
  282.  
  283. // Set the attackers ammo packs
  284. zp_set_user_ammo_packs(attacker,zp_get_user_ammo_packs(attacker) + get_pcvar_num(cvar_ammoinfect))
  285.  
  286. // Set the attackers health
  287. fm_set_user_health(attacker, pev(attacker, pev_health)+get_pcvar_num(cvar_humanbonushp))
  288. }
  289. #endif
  290.  
  291. // Set the previous blocking state
  292. set_msg_block(g_msgDeathMsg, deathmsg_block)
  293.  
  294. // Get the rid of the grenade
  295. engfunc(EngFunc_RemoveEntity, ent)
  296. }
  297.  
  298. // This function creates the rings when the grenade explodes
  299. public create_blast(const Float:originF[3])
  300. {
  301. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  302. write_byte(TE_BEAMCYLINDER) // TE id
  303. engfunc(EngFunc_WriteCoord, originF[0]) // x
  304. engfunc(EngFunc_WriteCoord, originF[1]) // y
  305. engfunc(EngFunc_WriteCoord, originF[2]) // z
  306. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  307. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  308. engfunc(EngFunc_WriteCoord, originF[2]+385.0) // z axis
  309. write_short(g_exploSpr) // sprite
  310. write_byte(0) // startframe
  311. write_byte(0) // framerate
  312. write_byte(4) // life
  313. write_byte(60) // width
  314. write_byte(0) // noise
  315. write_byte(255) // red
  316. write_byte(128) // green
  317. write_byte(0) // blue
  318. write_byte(200) // brightness
  319. write_byte(0) // speed
  320. message_end()
  321.  
  322. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  323. write_byte(TE_BEAMCYLINDER) // TE id
  324. engfunc(EngFunc_WriteCoord, originF[0]) // x
  325. engfunc(EngFunc_WriteCoord, originF[1]) // y
  326. engfunc(EngFunc_WriteCoord, originF[2]) // z
  327. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  328. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  329. engfunc(EngFunc_WriteCoord, originF[2]+470.0) // z axis
  330. write_short(g_exploSpr) // sprite
  331. write_byte(0) // startframe
  332. write_byte(0) // framerate
  333. write_byte(4) // life
  334. write_byte(60) // width
  335. write_byte(0) // noise
  336. write_byte(255) // red
  337. write_byte(164) // green
  338. write_byte(0) // blue
  339. write_byte(200) // brightness
  340. write_byte(0) // speed
  341. message_end()
  342.  
  343. engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, originF, 0)
  344. write_byte(TE_BEAMCYLINDER) // TE id
  345. engfunc(EngFunc_WriteCoord, originF[0]) // x
  346. engfunc(EngFunc_WriteCoord, originF[1]) // y
  347. engfunc(EngFunc_WriteCoord, originF[2]) // z
  348. engfunc(EngFunc_WriteCoord, originF[0]) // x axis
  349. engfunc(EngFunc_WriteCoord, originF[1]) // y axis
  350. engfunc(EngFunc_WriteCoord, originF[2]+555.0) // z axis
  351. write_short(g_exploSpr) // sprite
  352. write_byte(0) // startframe
  353. write_byte(0) // framerate
  354. write_byte(4) // life
  355. write_byte(60) // width
  356. write_byte(0) // noise
  357. write_byte(255) // red
  358. write_byte(200) // green
  359. write_byte(0) // blue
  360. write_byte(200) // brightness
  361. write_byte(0) // speed
  362. message_end()
  363. }
  364.  
  365. // Updates the frags of the attacker
  366. public UpdateFrags(attacker, victim, frags, deaths, scoreboard)
  367. {
  368. // Set the frags
  369. set_pev(attacker, pev_frags, float(pev(attacker, pev_frags) + frags))
  370.  
  371. // Set the deaths
  372. fm_set_user_deaths(victim, fm_get_user_deaths(victim) + deaths)
  373.  
  374. // Update scoreboard
  375. if (scoreboard)
  376. {
  377. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  378. write_byte(attacker) // id
  379. write_short(pev(attacker, pev_frags)) // frags
  380. write_short(fm_get_user_deaths(attacker)) // deaths
  381. write_short(0) // class?
  382. write_short(fm_get_user_team(attacker)) // team
  383. message_end()
  384.  
  385. message_begin(MSG_BROADCAST, g_msgScoreInfo)
  386. write_byte(victim) // id
  387. write_short(pev(victim, pev_frags)) // frags
  388. write_short(fm_get_user_deaths(victim)) // deaths
  389. write_short(0) // class?
  390. write_short(fm_get_user_team(victim)) // team
  391. message_end()
  392. }
  393. }
  394.  
  395. // Send the death message
  396. public SendDeathMsg(attacker, victim)
  397. {
  398. message_begin(MSG_BROADCAST, g_msgDeathMsg)
  399. write_byte(attacker) // killer
  400. write_byte(victim) // victim
  401. write_byte(0) // headshot flag
  402. write_string("infection") // killer's weapon
  403. message_end()
  404. }
  405.  
  406. // Replace models
  407. public replace_models(id)
  408. {
  409. if (!is_user_alive(id))
  410. return
  411.  
  412. if(get_user_weapon(id) == CSW_SMOKEGRENADE && has_bomb[id])
  413. {
  414. set_pev(id, pev_viewmodel2, model_grenade_infect)
  415.  
  416. }
  417. }
  418.  
  419. public message_cur_weapon(msg_id, msg_dest, msg_entity)
  420. {
  421. replace_models(msg_entity)
  422. }
  423.  
  424. give_the_bomb(id)
  425. {
  426. // Now he haves the bomb!
  427. has_bomb[id] = 1
  428.  
  429. #if defined EDITTED_VERSION
  430. // Make sure that the person is not an Assassin or Nemesis
  431. if (!zp_get_user_nemesis(id) && !zp_get_user_assassin(id))
  432. // Notify him
  433. zp_colored_print(id, "|g|[ZP]|y| %s", info_notice)
  434. #else // Person is using a normal ZP 4.3
  435. // Make sure that the person is not a Nemesis
  436. if (!zp_get_user_nemesis(id))
  437. // Notify him
  438. zp_colored_print(id, "|g|[ZP]|y| %s", info_notice)
  439. #endif
  440.  
  441. #if defined EDITTED_VERSION
  442. // If the person is Nemesis or Assassin notify him through HUD message
  443. if (zp_get_user_nemesis(id) || zp_get_user_assassin(id))
  444. {
  445. set_hudmessage(250, 120, 5, -1.0, 0.25, 2, 2.0, 10.0)
  446. ShowSyncHudMsg(id, g_SyncMsg,"%s", info_notice2)
  447. }
  448. #else // Person is using a normal ZP 4.3
  449. // If the person is Nemesis notify him through HUD message
  450. if (zp_get_user_nemesis(id))
  451. {
  452. set_hudmessage(250, 120, 5, -1.0, 0.25, 2, 2.0, 10.0)
  453. ShowSyncHudMsg(id, g_SyncMsg,"%s", info_notice2)
  454. }
  455. #endif
  456.  
  457. // Already own one
  458. if (user_has_weapon(id, CSW_SMOKEGRENADE))
  459. {
  460. // Increase BP ammo on it instead
  461. cs_set_user_bpammo(id, CSW_SMOKEGRENADE, cs_get_user_bpammo(id, CSW_SMOKEGRENADE) + 1)
  462.  
  463. // Flash the ammo in hud
  464. message_begin(MSG_ONE_UNRELIABLE, g_msgAmmoPickup, _, id)
  465. write_byte(CSW_SMOKEGRENADE)
  466. write_byte(1)
  467. message_end()
  468.  
  469. // Play Clip Purchase Sound
  470. engfunc(EngFunc_EmitSound, id, CHAN_ITEM, recieving_sound, 1.0, ATTN_NORM, 0, PITCH_NORM)
  471. }
  472. else
  473. // Give weapon to the player
  474. fm_give_item(id, "weapon_smokegrenade")
  475. }
  476.  
  477. /************************************************************\
  478. | [Stock funtions] |
  479. \************************************************************/
  480.  
  481. stock fm_set_user_deaths(id, value)
  482. {
  483. set_pdata_int(id, 444, value, 5)
  484. }
  485.  
  486. stock fm_get_user_deaths(id)
  487. {
  488. return get_pdata_int(id, 444, 5)
  489. }
  490.  
  491.  
  492. stock fm_get_user_team(id)
  493. {
  494. return get_pdata_int(id, 114, 5)
  495. }
  496.  
  497. // Prints chat in colours [ BY meTaLiCroSS ]
  498. stock zp_colored_print(const id, const input[], any:...)
  499. {
  500. new iCount = 1, iPlayers[32]
  501.  
  502. static szMsg[191]
  503. vformat(szMsg, charsmax(szMsg), input, 3)
  504.  
  505. replace_all(szMsg, 190, "|g|", "^4") // green txt
  506. replace_all(szMsg, 190, "|y|", "^1") // orange txt
  507. replace_all(szMsg, 190, "|ctr|", "^3") // team txt
  508. replace_all(szMsg, 190, "|w|", "^0") // team txt
  509.  
  510. if(id) iPlayers[0] = id
  511. else get_players(iPlayers, iCount, "ch")
  512.  
  513. for (new i = 0; i < iCount; i++)
  514. {
  515. if (is_user_connected(iPlayers[i]))
  516. {
  517. message_begin(MSG_ONE_UNRELIABLE, g_msgSayText, _, iPlayers[i])
  518. write_byte(iPlayers[i])
  519. write_string(szMsg)
  520. message_end()
  521. }
  522. }
  523. }