HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod X script.
  2. *
  3. * Ultimate Gore Enhancement (amx_gore_ultimate.sma)
  4. * Copyright (C) 2003-2004 mike_cao / fizzarum / jtp10181
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. *
  20. * In addition, as a special exception, the author gives permission to
  21. * link the code of this program with the Half-Life Game Engine ("HL
  22. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  23. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  24. * respects for all of the code used other than the HL Engine and MODs
  25. * from Valve. If you modify this file, you may extend this exception
  26. * to your version of the file, but you are not obligated to do so. If
  27. * you do not wish to do so, delete this exception statement from your
  28. * version.
  29. *
  30. ****************************************************************************
  31. *
  32. * Version 1.6 - 05/18/2008
  33. *
  34. * by jtp10181 <jtp@jtpage.net>
  35. * Homepage: http://www.jtpage.net
  36. *
  37. * Original code by:
  38. * by mike_cao <mike@mikecao.com> (plugin_gore)
  39. * fizzarum <tntmr2gg2@icqmail.com> (plugin_gore2)
  40. *
  41. ****************************************************************************
  42. *
  43. * This plugin adds gore effects. It is configured
  44. * with the cvar "amx_gore" using these flags:
  45. *
  46. * a - Headshot blood
  47. * b - Extra blood effects
  48. * c - Bleeding on low health
  49. * d - Gib explosion (Explosives and damage over "amx_gore_exphp")
  50. * e - Extra Gory Mode
  51. * f - Extra Headshot Gore Only (same as with flag "e")
  52. * g - Hostage Gore (CS/CZ Only)
  53. *
  54. * Default is: amx_gore "abcd"
  55. *
  56. * New CVAR: amx_gore_exphp (default 160)
  57. * The amount of health that must be lost upon death
  58. * for the player to "explode"
  59. *
  60. * Add the cvars to your amxx.cfg to change it and have it load every map
  61. *
  62. * *NOTE*: the decal indexes are pulled form the servers decals.wad If you
  63. * do not have the orginal decals.wad (for your mod) on the server the
  64. * decals may not appear as blood, but arrows, numbers, text, etc.
  65. *
  66. * v1.6 - JTP10181 - 07/09/06
  67. * - Added a single spray with normal headshot gore
  68. * - Added new flag for extra headshot gore only
  69. * - Added support for module auto loading
  70. * - Added support for SvenCoop
  71. * - Added minimal support for NS
  72. * - Finally found proper way to hide corpses in CS/CZ/DoD
  73. * - Fully ported to FakeMeta
  74. *
  75. * v1.5 - JTP10181 - 06/27/06
  76. * - Added support for ESF
  77. * - Added support for TS
  78. * - Added support for TFC
  79. * - Tweaked a lot of numbers
  80. * - Made gibs fly around more instead of in a big heap
  81. * - Added support for hostages in CS
  82. * - Switched all supporting mods to client_damage/death forwards
  83. *
  84. * v1.4 - JTP10181 - 06/16/06
  85. * - Switched to Pointer CVAR commands
  86. * - Updated to work on "valve" mod by request
  87. * - Finally finished support for DoD
  88. * - Reduced the insane ammount of blood spray with gibs & extra gore enabled
  89. *
  90. * v1.3.5 - JTP10181 - 03/05/06
  91. * - Fixed possible runtime errors if player disconnects during events
  92. *
  93. * v1.3.4 - JTP10181 - 10/25/05
  94. * - Added knife to the gib_wpncheck check
  95. * - Fixed bug where if all damage was from falling the player would not bleed
  96. *
  97. * v1.3.3 - JTP10181 - 09/25/04
  98. * - Made it really easy to change the weapons that cause explosion
  99. * - Minor code tweaks
  100. *
  101. * v1.3.2 - JTP10181 - 09/24/04
  102. * - Fixed code to work on AMXModX 0.20
  103. * - Added new CVAR to adjust the HP loss that triggers a GIB explosion
  104. * - Used task for body hiding so items wont end up underground
  105. *
  106. * v1.3.1 - JTP10181 - 06/02/04
  107. * - Fixed runtime error if victim is null on a damage or death event
  108. * Was happening in conjunction with superhero mod
  109. * Thanks to drummeridiot25 for testing it for me
  110. *
  111. * v1.3 - JTP
  112. * - Automatic mod detection, no more recompiling for CZERO.
  113. * - Decal indexes verified for CZ, they work perfectly.
  114. * - Started working on DoD support
  115. *
  116. * v1.2 - JTP
  117. * - Combined various gore plugins into one that has the best features
  118. * out of all of them.
  119. * - Plan to maintain this plugin if any issues/requests arrise.
  120. * - Added extra gory mode:
  121. * Classic headshot death with the sprays shooting up (from orginal plugin_gore)
  122. * More blood spraying on a gib explosion (from orginal plugin_gore)
  123. * Extra blood decals on damage and deaths
  124. * - Fixed divide by zero error in fx_blood and fx_gib_explode
  125. * - Minor tweaks here and there to some of the numbers
  126. * - Put in fix for CZERO decals from "euro" and "out" from AMX forums
  127. * - Fixed runtime error when the attacker was not able to be determinted.
  128. * get_user_origin was getting passed a "0" player index.
  129. *
  130. *
  131. * v1.03 - ( by fizzarum ) :
  132. * - Each hit now causes a blood stream depending on the positions of the
  133. * agressor and the victim.
  134. * - Reduce the previous headshot fx to a less extravagant thing
  135. * - The gib explosion now happens after a damage higher than 110 EVEN IF
  136. * the victim's head was hit
  137. * - A knife kill does not cause a gib explosion
  138. * - Minor changes on the bleeding effect, the position of the gibs
  139. *
  140. * Thanks:
  141. * - mike_cao for the orginal plugin
  142. * - fizzarum on plugin_gore2.sma (for AMX)
  143. * - euro and out (AMX forums) for posting decal numbers for CZero
  144. * - SidLuke (AMX forums) for his version for DoD,
  145. * I grabbed some of that code for my DoD support
  146. *
  147. * - Fordította: BBk
  148. **************************************************************************/
  149.  
  150. //Comment this out to totally disable the GIB code
  151. //This can help if maps are crashing from exceeding the precache limit
  152. #define GIBS_ENABLED
  153.  
  154. #include <amxmodx>
  155. #include <amxmisc>
  156. #include <fakemeta>
  157. #include <dodconst>
  158. #include <tfcconst>
  159. #include <tsconst>
  160.  
  161. //Auto-load the correct module if not loaded
  162. #pragma reqclass xstats
  163. #if !defined AMXMODX_NOAUTOLOAD
  164. #pragma defclasslib xstats csx
  165. #pragma defclasslib xstats dodx
  166. #pragma defclasslib xstats tfcx
  167. #pragma defclasslib xstats tsx
  168. #endif
  169.  
  170. #define MAX_PLAYERS 32
  171. #define MAX_HOSTAGES 16
  172.  
  173. #define GORE_HEADSHOT (1<<0) // "a"
  174. #define GORE_BLOOD (1<<1) // "b"
  175. #define GORE_BLEEDING (1<<2) // "c"
  176. #define GORE_GIB (1<<3) // "d"
  177. #define GORE_EXTRA (1<<4) // "e"
  178. #define GORE_EXTRA_HS (1<<5) // "f"
  179. #define GORE_HOSTAGES (1<<6) // "g"
  180.  
  181. #define BLOOD_COLOR_RED 247
  182. #define BLOOD_COLOR_YELLOW 195
  183. #define BLOOD_STREAM_RED 70
  184. #define BLOOD_STREAM_YELLOW 60
  185.  
  186. new gHealthIndex[MAX_PLAYERS+1]
  187. new Float:hostage_hp[MAX_HOSTAGES], hostages[MAX_HOSTAGES], host_num
  188.  
  189. #if defined GIBS_ENABLED
  190. new mdl_gib_flesh, mdl_gib_head, mdl_gib_legbone
  191. new mdl_gib_lung, mdl_gib_meat, mdl_gib_spine
  192. #endif
  193.  
  194. new spr_blood_drop, spr_blood_spray
  195.  
  196. #define BLOOD_SM_NUM 8
  197. #define BLOOD_LG_NUM 2
  198. new blood_small_red[BLOOD_SM_NUM], blood_large_red[BLOOD_LG_NUM]
  199. //new blood_small_yellow[BLOOD_SM_NUM], blood_large_yellow[BLOOD_LG_NUM]
  200.  
  201. new mod_name[32], bool:body_hidden[33]
  202. new pcvar_gore, pcvar_gore_exphp
  203.  
  204. //Offsets to place blood is more realistic hit location
  205. new Offset[8][3] = {{0,0,10},{0,0,30},{0,0,16},{0,0,10},{4,4,16},{-4,-4,16},{4,4,-12},{-4,-4,-12}}
  206.  
  207. // #####################################################################
  208. // ## Change which weapons cause GIB explosions on death HERE ##
  209. // #####################################################################
  210.  
  211. public gib_wpncheck(iWeapon)
  212. {
  213. //This section is used for CS/CZ
  214. if (cstrike_running()) {
  215. switch (iWeapon) {
  216. case CSW_P228 : return false
  217. case CSW_SCOUT : return false
  218. case CSW_HEGRENADE : return true
  219. case CSW_XM1014 : return false
  220. case CSW_C4 : return true
  221. case CSW_MAC10 : return false
  222. case CSW_AUG : return false
  223. case CSW_SMOKEGRENADE : return true
  224. case CSW_ELITE : return false
  225. case CSW_FIVESEVEN : return false
  226. case CSW_UMP45 : return false
  227. case CSW_SG550 : return false
  228. case CSW_GALIL : return false
  229. case CSW_FAMAS : return false
  230. case CSW_USP : return false
  231. case CSW_GLOCK18 : return false
  232. case CSW_AWP : return false
  233. case CSW_MP5NAVY : return false
  234. case CSW_M249 : return false
  235. case CSW_M3 : return false
  236. case CSW_M4A1 : return false
  237. case CSW_TMP : return false
  238. case CSW_G3SG1 : return false
  239. case CSW_FLASHBANG : return true
  240. case CSW_DEAGLE : return false
  241. case CSW_SG552 : return false
  242. case CSW_AK47 : return false
  243. case CSW_KNIFE : return false
  244. case CSW_P90 : return false
  245. }
  246. }
  247. //This section is used for DoD
  248. else if (equali(mod_name,"dod")) {
  249. switch (iWeapon) {
  250. case DODW_AMERKNIFE : return false
  251. case DODW_GERKNIFE : return false
  252. case DODW_COLT : return false
  253. case DODW_LUGER : return false
  254. case DODW_GARAND : return false
  255. case DODW_SCOPED_KAR : return false
  256. case DODW_THOMPSON : return false
  257. case DODW_STG44 : return false
  258. case DODW_SPRINGFIELD : return false
  259. case DODW_KAR : return false
  260. case DODW_BAR : return false
  261. case DODW_MP40 : return false
  262. case DODW_HANDGRENADE : return true
  263. case DODW_STICKGRENADE : return true
  264. case DODW_STICKGRENADE_EX : return true
  265. case DODW_HANDGRENADE_EX : return true
  266. case DODW_MG42 : return false
  267. case DODW_30_CAL : return false
  268. case DODW_SPADE : return false
  269. case DODW_M1_CARBINE : return false
  270. case DODW_MG34 : return false
  271. case DODW_GREASEGUN : return false
  272. case DODW_FG42 : return false
  273. case DODW_K43 : return false
  274. case DODW_ENFIELD : return false
  275. case DODW_STEN : return false
  276. case DODW_BREN : return false
  277. case DODW_WEBLEY : return false
  278. case DODW_BAZOOKA : return true
  279. case DODW_PANZERSCHRECK : return false
  280. case DODW_PIAT : return false
  281. case DODW_SCOPED_FG42 : return false
  282. case DODW_FOLDING_CARBINE : return false
  283. case DODW_KAR_BAYONET : return false
  284. case DODW_SCOPED_ENFIELD : return false
  285. case DODW_MILLS_BOMB : return true
  286. case DODW_BRITKNIFE : return false
  287. case DODW_GARAND_BUTT : return false
  288. case DODW_ENFIELD_BAYONET : return false
  289. case DODW_MORTAR : return false
  290. case DODW_K43_BUTT : return false
  291. }
  292. }
  293. //This section is used for TFC
  294. else if (equali(mod_name,"tfc")) {
  295. switch (iWeapon) {
  296. case TFC_WPN_NONE : return false
  297. case TFC_WPN_TIMER : return false
  298. case TFC_WPN_SENTRYGUN : return false
  299. case TFC_WPN_MEDIKIT : return false
  300. case TFC_WPN_SPANNER : return false
  301. case TFC_WPN_AXE : return false
  302. case TFC_WPN_SNIPERRIFLE : return false
  303. case TFC_WPN_AUTORIFLE : return false
  304. case TFC_WPN_SHOTGUN : return false
  305. case TFC_WPN_SUPERSHOTGUN : return false
  306. case TFC_WPN_NG : return false
  307. case TFC_WPN_SUPERNG : return false
  308. case TFC_WPN_GL : return false
  309. case TFC_WPN_FLAMETHROWER : return false
  310. case TFC_WPN_RPG : return true
  311. case TFC_WPN_IC : return false
  312. case TFC_WPN_FLAMES : return false
  313. case TFC_WPN_AC : return false
  314. case TFC_WPN_UNK18 : return false
  315. case TFC_WPN_UNK19 : return false
  316. case TFC_WPN_TRANQ : return false
  317. case TFC_WPN_RAILGUN : return false
  318. case TFC_WPN_PL : return false
  319. case TFC_WPN_KNIFE : return false
  320. case TFC_WPN_CALTROP : return false
  321. case TFC_WPN_CONCUSSIONGRENADE : return true
  322. case TFC_WPN_NORMALGRENADE : return true
  323. case TFC_WPN_NAILGRENADE : return true
  324. case TFC_WPN_MIRVGRENADE : return true
  325. case TFC_WPN_NAPALMGRENADE : return true
  326. case TFC_WPN_GASGRENADE : return false
  327. case TFC_WPN_EMPGRENADE : return false
  328. }
  329.  
  330. }
  331. //This section is used for TS
  332. else if (equali(mod_name,"ts")) {
  333. switch (iWeapon) {
  334. case TSW_GLOCK18 : return false
  335. case TSW_UNK1 : return false
  336. case TSW_UZI : return false
  337. case TSW_M3 : return false
  338. case TSW_M4A1 : return false
  339. case TSW_MP5SD : return false
  340. case TSW_MP5K : return false
  341. case TSW_ABERETTAS : return false
  342. case TSW_MK23 : return false
  343. case TSW_AMK23 : return false
  344. case TSW_USAS : return false
  345. case TSW_DEAGLE : return false
  346. case TSW_AK47 : return false
  347. case TSW_57 : return false
  348. case TSW_AUG : return false
  349. case TSW_AUZI : return false
  350. case TSW_TMP : return false
  351. case TSW_M82A1 : return false
  352. case TSW_MP7 : return false
  353. case TSW_SPAS : return false
  354. case TSW_GCOLTS : return false
  355. case TSW_GLOCK20 : return false
  356. case TSW_UMP : return false
  357. case TSW_M61GRENADE : return true
  358. case TSW_CKNIFE : return false
  359. case TSW_MOSSBERG : return false
  360. case TSW_M16A4 : return false
  361. case TSW_MK1 : return false
  362. case TSW_C4 : return true
  363. case TSW_A57 : return false
  364. case TSW_RBULL : return false
  365. case TSW_M60E3 : return false
  366. case TSW_SAWED_OFF : return true
  367. case TSW_KATANA : return false
  368. case TSW_SKNIFE : return false
  369. case TSW_KUNG_FU : return false
  370. case TSW_TKNIFE : return false
  371. }
  372. }
  373. //This section is used for ESF
  374. else if (equali(mod_name,"esf")) {
  375. //Always do GIB explosions on ESF
  376. return true
  377. }
  378. //This section is used for the "valve" mod
  379. else if (equali(mod_name,"valve")) {
  380. switch (iWeapon) {
  381. case HLW_NONE : return false
  382. case HLW_CROWBAR : return false
  383. case HLW_GLOCK : return false
  384. case HLW_PYTHON : return false
  385. case HLW_MP5 : return false
  386. case HLW_CHAINGUN : return false
  387. case HLW_CROSSBOW : return false
  388. case HLW_SHOTGUN : return false
  389. case HLW_RPG : return true
  390. case HLW_GAUSS : return false
  391. case HLW_EGON : return false
  392. case HLW_HORNETGUN : return false
  393. case HLW_HANDGRENADE : return true
  394. case HLW_TRIPMINE : return true
  395. case HLW_SATCHEL : return true
  396. case HLW_SNARK : return false
  397. }
  398. }
  399.  
  400. //Always false on Sven Co-op
  401. return false
  402. }
  403.  
  404. // #####################################################################
  405. // ## DO NOT EDIT BELOW HERE ##
  406. // #####################################################################
  407.  
  408. /************************************************************
  409. * PLUGIN FUNCTIONS
  410. ************************************************************/
  411.  
  412. public plugin_init()
  413. {
  414. register_plugin("Ultimate Gore","1.6","JTP10181")
  415.  
  416. get_modname(mod_name,31)
  417.  
  418. if (cstrike_running()) {
  419. register_logevent("event_roundstart", 2, "1=Round_Start")
  420. register_event("TextMsg","event_host_damage","b","2=#Injured_Hostage")
  421. register_event("TextMsg","event_host_killed","b","2=#Killed_Hostage")
  422. register_message(122, "event_ClCorpse") //ClCorpse
  423. }
  424. else if (equali(mod_name,"dod")) {
  425. register_message(126, "event_ClCorpse") //ClCorpse
  426. }
  427. else if (equali(mod_name,"esf")) {
  428. register_event("DeathMsg","event_death","a")
  429. register_event("Health","event_damage","b")
  430. }
  431. else if (equali(mod_name,"svencoop")) {
  432. register_event("Damage","event_damage","b","2!0")
  433. }
  434. else if (equali(mod_name,"valve") || equali(mod_name,"ns")) {
  435. register_event("DeathMsg","event_death","a")
  436. register_event("Damage","event_damage","b","2!0")
  437. }
  438.  
  439. register_event("ResetHUD","event_respawn","b")
  440.  
  441. pcvar_gore = register_cvar("amx_gore","abcd")
  442. pcvar_gore_exphp = register_cvar("amx_gore_exphp","160")
  443. set_task(1.5,"event_blood",100,"",0,"b")
  444.  
  445. // Blood decals
  446. if (equali(mod_name,"cstrike")) {
  447. blood_large_red = {204,205}
  448. blood_small_red = {190,191,192,193,194,195,196,197}
  449. }
  450. else if (equali(mod_name,"czero")) {
  451. blood_large_red = {216,217}
  452. blood_small_red = {202,203,204,205,206,207,208,209}
  453. }
  454. else if (equali(mod_name,"dod")) {
  455. blood_large_red = {217,218}
  456. blood_small_red = {203,204,205,206,207,208,209,210}
  457. }
  458. else if (equali(mod_name,"tfc")) {
  459. blood_large_red = {208,209}
  460. blood_small_red = {194,195,196,197,198,199,200,201}
  461. }
  462. else if (equali(mod_name,"ts")) {
  463. blood_large_red = {218,219}
  464. blood_small_red = {204,205,206,207,208,209,210,211}
  465. }
  466. else if (equali(mod_name,"svencoop")) {
  467. blood_large_red = {210,211}
  468. blood_small_red = {196,197,198,199,200,201,202,203}
  469. }
  470. //"valve" mod and others that use its decals.wad (ESF, NS)
  471. else {
  472. blood_large_red = {19,20}
  473. blood_small_red = {27,28,29,30,31,32,33,34}
  474. }
  475.  
  476. //Setup jtp10181 CVAR
  477. new cvarString[256], shortName[16]
  478. copy(shortName,15,"gore")
  479.  
  480. register_cvar("jtp10181","",FCVAR_SERVER|FCVAR_SPONLY)
  481. get_cvar_string("jtp10181",cvarString,255)
  482.  
  483. if (strlen(cvarString) == 0) {
  484. formatex(cvarString,255,shortName)
  485. set_cvar_string("jtp10181",cvarString)
  486. }
  487. else if (contain(cvarString,shortName) == -1) {
  488. format(cvarString,255,"%s,%s",cvarString, shortName)
  489. set_cvar_string("jtp10181",cvarString)
  490. }
  491. }
  492.  
  493. public plugin_natives()
  494. {
  495. set_module_filter("module_filter")
  496. set_native_filter("native_filter")
  497. }
  498.  
  499. public module_filter(const module[])
  500. {
  501. if (equali(module, "xstats")) {
  502. if (cstrike_running()) return PLUGIN_CONTINUE
  503. if (equali(mod_name,"dod")) return PLUGIN_CONTINUE
  504. if (equali(mod_name,"tfc")) return PLUGIN_CONTINUE
  505. if (equali(mod_name,"ts")) return PLUGIN_CONTINUE
  506.  
  507. return PLUGIN_HANDLED
  508. }
  509. return PLUGIN_CONTINUE
  510. }
  511.  
  512. public native_filter(const name[], index, trap)
  513. {
  514. if (!trap) return PLUGIN_HANDLED
  515.  
  516. return PLUGIN_CONTINUE
  517. }
  518.  
  519. public plugin_precache()
  520. {
  521. spr_blood_drop = precache_model("sprites/blood.spr")
  522. spr_blood_spray = precache_model("sprites/bloodspray.spr")
  523.  
  524. #if defined GIBS_ENABLED
  525. mdl_gib_flesh = precache_model("models/Fleshgibs.mdl")
  526. mdl_gib_meat = precache_model("models/GIB_B_Gib.mdl")
  527. mdl_gib_head = precache_model("models/GIB_Skull.mdl")
  528.  
  529. if (!equali(mod_name,"dod")) {
  530. mdl_gib_spine = precache_model("models/GIB_B_Bone.mdl")
  531. mdl_gib_lung = precache_model("models/GIB_Lung.mdl")
  532. mdl_gib_legbone = precache_model("models/GIB_Legbone.mdl")
  533. }
  534. #endif
  535. }
  536.  
  537. public plugin_cfg()
  538. {
  539. if (!cstrike_running()) return
  540.  
  541. new iEnt = -1
  542. host_num = 0
  543. while ((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "hostage_entity")) != 0) {
  544. hostages[host_num++] = iEnt
  545. if (host_num >= MAX_HOSTAGES) break
  546. }
  547. }
  548.  
  549. //Custom function to get origin with FM and return it as an integer
  550. public get_origin_int(index, origin[3])
  551. {
  552. new Float:FVec[3]
  553.  
  554. pev(index,pev_origin,FVec)
  555.  
  556. origin[0] = floatround(FVec[0])
  557. origin[1] = floatround(FVec[1])
  558. origin[2] = floatround(FVec[2])
  559.  
  560. return 1
  561. }
  562.  
  563. /************************************************************
  564. * EVENTS
  565. ************************************************************/
  566.  
  567. //For "valve", ESF, NS, SvenCoop
  568. public event_damage(iVictim)
  569. {
  570. if (iVictim <= 0 || iVictim > MAX_PLAYERS) return
  571.  
  572. new iWeapon, iHitPlace, iAgressor
  573. iAgressor = get_user_attacker(iVictim,iWeapon,iHitPlace)
  574.  
  575. //Sven Co-op does not seem to send Death messages so we will do this
  576. if (equali(mod_name,"svencoop")) {
  577. if (get_user_health(iVictim) <=0) {
  578. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  579. return
  580. }
  581. }
  582.  
  583. process_damage(iAgressor, iVictim, iHitPlace)
  584. }
  585.  
  586. //Forward for CS/CZ, DoD, TFC, TS
  587. public client_damage(attacker,victim,damage,wpnindex,hitplace)
  588. {
  589. if (victim <= 0 || victim > MAX_PLAYERS) return
  590. process_damage(attacker, victim, hitplace)
  591. }
  592.  
  593. //This will process the damage info for all mods
  594. process_damage(iAgressor, iVictim, iHitPlace)
  595. {
  596. new iFlags = get_gore_flags()
  597.  
  598. //Don't want to do this if the player just died
  599. new vHealth = get_user_health(iVictim)
  600. if (vHealth <= 0 || vHealth >= gHealthIndex[iVictim]) return
  601.  
  602. //server_print("************************* DAMAGE: %d %d %d %d", iVictim, iAgressor, vHealth, iHitPlace)
  603.  
  604. gHealthIndex[iVictim] = vHealth
  605.  
  606. //Check to make sure its a valid entity
  607. if (!pev_valid(iAgressor)) {
  608. iAgressor = iVictim
  609. iHitPlace = 0
  610. }
  611.  
  612. //Crash/error check
  613. if (!is_user_connected(iVictim)) return
  614. if (iHitPlace < 0 || iHitPlace > 7) iHitPlace = 0
  615.  
  616. if (iFlags&GORE_BLOOD) {
  617. new iOrigin[3], iOrigin2[3]
  618. get_origin_int(iVictim,iOrigin)
  619. get_origin_int(iAgressor,iOrigin2)
  620.  
  621. fx_blood(iOrigin,iOrigin2,iHitPlace)
  622. fx_blood_small(iOrigin,8)
  623. if (iFlags&GORE_EXTRA) {
  624. fx_blood(iOrigin,iOrigin2,iHitPlace)
  625. fx_blood(iOrigin,iOrigin2,iHitPlace)
  626. fx_blood(iOrigin,iOrigin2,iHitPlace)
  627. fx_blood_small(iOrigin,4)
  628. }
  629. }
  630. }
  631.  
  632. //Hostage Event for CS/CZ
  633. public event_host_damage(iAgressor)
  634. {
  635. new Float:vHeatlh, iVictim, iHitPlace = 0
  636. new iFlags = get_gore_flags()
  637. new hostid, Float:hosthp
  638.  
  639. if (!(iFlags&GORE_HOSTAGES)) return
  640.  
  641. //Find what hostage was injured
  642. for (new x = 0; x < host_num; x++) {
  643. hostid = hostages[x]
  644. hosthp = hostage_hp[x]
  645.  
  646. if (!pev_valid(hostid)) continue
  647. if (hosthp <= 0.0) continue
  648. pev(hostid, pev_health, vHeatlh)
  649.  
  650. if (vHeatlh > 0.0 && vHeatlh < hosthp) {
  651. iVictim = hostid
  652. }
  653.  
  654. hosthp = vHeatlh
  655. }
  656.  
  657. //No valid hostage entity found
  658. if (iVictim <= 0) return
  659.  
  660. //Check to make sure its a player
  661. if (!is_user_connected(iAgressor)) {
  662. iAgressor = iVictim
  663. }
  664.  
  665. if (iFlags&GORE_BLOOD) {
  666. new iOrigin[3], iOrigin2[3]
  667.  
  668. get_origin_int(iVictim, iOrigin)
  669. get_origin_int(iAgressor, iOrigin2)
  670.  
  671. //Add height to Hostage origin
  672. iOrigin[2] += 36
  673.  
  674. fx_blood(iOrigin,iOrigin2,iHitPlace)
  675. fx_blood_small(iOrigin,8)
  676. if (iFlags&GORE_EXTRA) {
  677. fx_blood(iOrigin,iOrigin2,iHitPlace)
  678. fx_blood(iOrigin,iOrigin2,iHitPlace)
  679. fx_blood(iOrigin,iOrigin2,iHitPlace)
  680. fx_blood_small(iOrigin,4)
  681. }
  682. }
  683. }
  684.  
  685. //For "valve", ESF, NS
  686. public event_death()
  687. {
  688. new iVictim = read_data(2)
  689. new iWeapon, iHitPlace
  690.  
  691. if (iVictim <= 0 || iVictim > MAX_PLAYERS) return
  692. new iAgressor = get_user_attacker(iVictim,iWeapon,iHitPlace)
  693.  
  694. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  695. }
  696.  
  697. //Forward for CS/CZ, DoD, TFC, TS
  698. public client_death(killer,victim,wpnindex,hitplace)
  699. {
  700. if (victim <= 0 || victim > MAX_PLAYERS) return
  701. process_death(killer, victim, wpnindex, hitplace)
  702. }
  703.  
  704. //This will process the death info for all mods
  705. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  706. {
  707. //server_print("************************* DEATH: %d %d %d %d", iVictim, iAgressor, iWeapon, iHitPlace)
  708.  
  709. new iOrigin[3], iOrigin2[3]
  710. new iFlags = get_gore_flags()
  711.  
  712. //Check to make sure its a valid entity
  713. if (!pev_valid(iAgressor)) {
  714. iAgressor = iVictim
  715. iWeapon = 0
  716. iHitPlace = 0
  717. }
  718.  
  719. if (!is_user_connected(iVictim)) return
  720.  
  721. get_origin_int(iVictim, iOrigin)
  722. get_origin_int(iAgressor, iOrigin2)
  723.  
  724. if (iFlags&GORE_HEADSHOT && iHitPlace == HIT_HEAD) {
  725. fx_headshot(iOrigin)
  726. }
  727.  
  728. #if defined GIBS_ENABLED
  729. if (iFlags&GORE_GIB && (gib_wpncheck(iWeapon) || gHealthIndex[iVictim] - get_user_health(iVictim) >= get_pcvar_num(pcvar_gore_exphp))) {
  730.  
  731. // Effects
  732. fx_invisible(iVictim)
  733. body_hidden[iVictim] = true
  734.  
  735. fx_gib_explode(iOrigin,iOrigin2)
  736. fx_blood_large(iOrigin,4)
  737. fx_blood_small(iOrigin,4)
  738. }
  739. #endif
  740.  
  741. fx_blood_small(iOrigin,8)
  742.  
  743. if (iFlags&GORE_EXTRA && !equali(mod_name,"dod")) {
  744. fx_extra_blood(iOrigin)
  745. fx_blood_large(iOrigin,2)
  746. fx_blood_small(iOrigin,4)
  747. }
  748. }
  749.  
  750. //Hostage Event for CS/CZ
  751. public event_host_killed(iAgressor)
  752. {
  753. new Float:vHeatlh, HP_Loss, iVictim, iWeapon = 0, clip, ammo
  754. new iFlags = get_gore_flags()
  755. new hostid, Float:hosthp
  756.  
  757. if (!(iFlags&GORE_HOSTAGES)) return
  758.  
  759. //Find what hostage was killed
  760. for (new x = 0; x < host_num; x++) {
  761. hostid = hostages[x]
  762. hosthp = hostage_hp[x]
  763.  
  764. if (!pev_valid(hostid)) continue
  765. if (hosthp <= 0.0) continue
  766.  
  767. pev(hostid, pev_health, vHeatlh)
  768.  
  769. if (vHeatlh <= 0.0 && vHeatlh < hosthp) {
  770. iVictim = hostid
  771. HP_Loss = floatround(hosthp - vHeatlh)
  772. }
  773.  
  774. hosthp = vHeatlh
  775. }
  776.  
  777. //No valid hostage entity found
  778. if (iVictim <= 0) return
  779.  
  780. //Check to make sure its a player
  781. if (is_user_alive(iAgressor)) {
  782. iWeapon = get_user_weapon(iAgressor,clip,ammo)
  783. }
  784. else {
  785. iAgressor = iVictim
  786. }
  787.  
  788. new iOrigin[3], iOrigin2[3]
  789.  
  790. get_origin_int(iVictim, iOrigin)
  791. get_origin_int(iAgressor, iOrigin2)
  792.  
  793. //Add height to Hostage origin
  794. iOrigin[2] += 36
  795.  
  796. #if defined GIBS_ENABLED
  797. if (iFlags&GORE_GIB && (gib_wpncheck(iWeapon) || HP_Loss >= floatround(get_pcvar_float(pcvar_gore_exphp) * 0.6))) {
  798.  
  799. // Effects
  800. fx_invisible(iVictim)
  801. fx_gib_explode(iOrigin,iOrigin2)
  802. fx_blood_large(iOrigin,4)
  803. fx_blood_small(iOrigin,4)
  804. }
  805. #endif
  806.  
  807. fx_blood_small(iOrigin,8)
  808. if (iFlags&GORE_EXTRA) {
  809. fx_extra_blood(iOrigin)
  810. fx_blood_large(iOrigin,2)
  811. fx_blood_small(iOrigin,4)
  812. }
  813. }
  814.  
  815. public event_blood()
  816. {
  817. new iFlags = get_gore_flags()
  818. if (!(iFlags&GORE_BLEEDING)) return
  819.  
  820. new iPlayer, iPlayers[MAX_PLAYERS], iNumPlayers, iOrigin[3]
  821. get_players(iPlayers,iNumPlayers,"a")
  822. for (new i = 0; i < iNumPlayers; i++) {
  823. iPlayer = iPlayers[i]
  824. gHealthIndex[iPlayer] = get_user_health(iPlayer)
  825. if (gHealthIndex[iPlayer] < 20) {
  826. get_origin_int(iPlayer, iOrigin)
  827. fx_bleed(iOrigin)
  828. fx_blood_small(iOrigin,3)
  829. }
  830. }
  831.  
  832. if (!(iFlags&GORE_HOSTAGES)) return
  833.  
  834. //Hostage Bleeding
  835. if (cstrike_running()) {
  836. new iOrigin[3], hostid, Float:hosthp
  837. for (new x = 0; x < host_num; x++) {
  838. hostid = hostages[x]
  839. hosthp = hostage_hp[x]
  840. if (!pev_valid(hostid)) continue
  841. pev(hostid, pev_health, hosthp)
  842. if (hosthp > 0.0 && hosthp < 20.0) {
  843. get_origin_int(hostid, iOrigin)
  844. iOrigin[2] += 36.0
  845. fx_bleed(iOrigin)
  846. fx_blood_small(iOrigin,3)
  847. }
  848. }
  849. }
  850. }
  851.  
  852. public event_respawn(id)
  853. {
  854. if (is_user_alive(id)) {
  855. //Reset body_hidden flag
  856. body_hidden[id] = false
  857. //Restore model visibility
  858. set_pev(id, pev_rendermode, kRenderNormal)
  859. //Save clients current Health
  860. gHealthIndex[id] = get_user_health(id)
  861. }
  862. }
  863.  
  864. public event_roundstart(id)
  865. {
  866. set_task(0.1,"roundstart_delay",100)
  867. }
  868.  
  869. public roundstart_delay()
  870. {
  871. for ( new id = 1; id <= MAX_PLAYERS; id++ ) {
  872. if (is_user_alive(id)) {
  873. //Reset body_hidden flag
  874. body_hidden[id] = false
  875. //Save clients current Health
  876. gHealthIndex[id] = get_user_health(id)
  877. }
  878. }
  879.  
  880. if (cstrike_running()) {
  881. new hostid
  882. for (new x = 0; x < host_num; x++) {
  883. hostid = hostages[x]
  884. if (!pev_valid(hostid)) continue
  885. set_pev(hostid, pev_rendermode, kRenderNormal)
  886. pev(hostid, pev_health, hostage_hp[x])
  887. }
  888. }
  889. }
  890.  
  891. //Hides Corpses in CS / DoD
  892. public event_ClCorpse()
  893. {
  894. //If there is not 12 args something is wrong
  895. if (get_msg_args() != 12) return PLUGIN_CONTINUE
  896.  
  897. //Arg 12 is the player id the corpse is for
  898. new id = get_msg_arg_int(12)
  899.  
  900. //If the corpse should be hidden block this message
  901. if (body_hidden[id]) return PLUGIN_HANDLED
  902.  
  903. return PLUGIN_CONTINUE
  904. }
  905.  
  906. public get_gore_flags()
  907. {
  908. new sFlags[24]
  909. get_pcvar_string(pcvar_gore,sFlags,23)
  910. return read_flags(sFlags)
  911. }
  912.  
  913. /************************************************************
  914. * FX FUNCTIONS
  915. ************************************************************/
  916.  
  917. fx_invisible(id)
  918. {
  919. set_pev(id, pev_renderfx, kRenderFxNone)
  920. set_pev(id, pev_rendermode, kRenderTransAlpha)
  921. set_pev(id, pev_renderamt, 0.0)
  922. }
  923.  
  924. fx_blood(origin[3],origin2[3],HitPlace)
  925. {
  926. //Crash Checks
  927. if (HitPlace < 0 || HitPlace > 7) HitPlace = 0
  928. new rDistance = get_distance(origin,origin2) ? get_distance(origin,origin2) : 1
  929.  
  930. new rX = ((origin[0]-origin2[0]) * 300) / rDistance
  931. new rY = ((origin[1]-origin2[1]) * 300) / rDistance
  932. new rZ = ((origin[2]-origin2[2]) * 300) / rDistance
  933.  
  934. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  935. write_byte(TE_BLOODSTREAM)
  936. write_coord(origin[0]+Offset[HitPlace][0])
  937. write_coord(origin[1]+Offset[HitPlace][1])
  938. write_coord(origin[2]+Offset[HitPlace][2])
  939. write_coord(rX) // x
  940. write_coord(rY) // y
  941. write_coord(rZ) // z
  942. write_byte(BLOOD_STREAM_RED) // color
  943. write_byte(random_num(100,200)) // speed
  944. message_end()
  945. }
  946.  
  947. fx_bleed(origin[3])
  948. {
  949. // Blood spray
  950. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  951. write_byte(TE_BLOODSTREAM)
  952. write_coord(origin[0])
  953. write_coord(origin[1])
  954. write_coord(origin[2]+10)
  955. write_coord(random_num(-360,360)) // x
  956. write_coord(random_num(-360,360)) // y
  957. write_coord(-10) // z
  958. write_byte(BLOOD_STREAM_RED) // color
  959. write_byte(random_num(50,100)) // speed
  960. message_end()
  961. }
  962.  
  963. fx_blood_small(origin[3],num)
  964. {
  965. if (equali(mod_name,"esf")) return
  966.  
  967. // Write Small splash decal
  968. for (new j = 0; j < num; j++) {
  969. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  970. write_byte(TE_WORLDDECAL)
  971. write_coord(origin[0]+random_num(-100,100))
  972. write_coord(origin[1]+random_num(-100,100))
  973. write_coord(origin[2]-36)
  974. write_byte(blood_small_red[random_num(0,BLOOD_SM_NUM - 1)]) // index
  975. message_end()
  976. }
  977. }
  978.  
  979. fx_blood_large(origin[3],num)
  980. {
  981. if (equali(mod_name,"esf")) return
  982.  
  983. // Write Large splash decal
  984. for (new i = 0; i < num; i++) {
  985. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  986. write_byte(TE_WORLDDECAL)
  987. write_coord(origin[0]+random_num(-50,50))
  988. write_coord(origin[1]+random_num(-50,50))
  989. write_coord(origin[2]-36)
  990. write_byte(blood_large_red[random_num(0,BLOOD_LG_NUM - 1)]) // index
  991. message_end()
  992. }
  993. }
  994.  
  995. #if defined GIBS_ENABLED
  996. fx_gib_explode(origin[3],origin2[3])
  997. {
  998. new flesh[2]
  999. flesh[0] = mdl_gib_flesh
  1000. flesh[1] = mdl_gib_meat
  1001. new mult, gibtime = 400 //40 seconds
  1002.  
  1003. if (equali(mod_name,"esf")) mult = 400
  1004. else if (equali(mod_name,"ts")) mult = 140
  1005. else mult = 80
  1006.  
  1007. new rDistance = get_distance(origin,origin2) ? get_distance(origin,origin2) : 1
  1008. new rX = ((origin[0]-origin2[0]) * mult) / rDistance
  1009. new rY = ((origin[1]-origin2[1]) * mult) / rDistance
  1010. new rZ = ((origin[2]-origin2[2]) * mult) / rDistance
  1011. new rXm = rX >= 0 ? 1 : -1
  1012. new rYm = rY >= 0 ? 1 : -1
  1013. new rZm = rZ >= 0 ? 1 : -1
  1014.  
  1015. // Gib explosions
  1016.  
  1017. // Head
  1018. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1019. write_byte(TE_MODEL)
  1020. write_coord(origin[0])
  1021. write_coord(origin[1])
  1022. write_coord(origin[2]+40)
  1023. write_coord(rX + (rXm * random_num(0,80)))
  1024. write_coord(rY + (rYm * random_num(0,80)))
  1025. write_coord(rZ + (rZm * random_num(80,200)))
  1026. write_angle(random_num(0,360))
  1027. write_short(mdl_gib_head)
  1028. write_byte(0) // bounce
  1029. write_byte(gibtime) // life
  1030. message_end()
  1031.  
  1032. // Parts
  1033. for(new i = 0; i < 4; i++) {
  1034. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1035. write_byte(TE_MODEL)
  1036. write_coord(origin[0])
  1037. write_coord(origin[1])
  1038. write_coord(origin[2])
  1039. write_coord(rX + (rXm * random_num(0,80)))
  1040. write_coord(rY + (rYm * random_num(0,80)))
  1041. write_coord(rZ + (rZm * random_num(80,200)))
  1042. write_angle(random_num(0,360))
  1043. write_short(flesh[random_num(0,1)])
  1044. write_byte(0) // bounce
  1045. write_byte(gibtime) // life
  1046. message_end()
  1047. }
  1048.  
  1049. if (!equali(mod_name,"dod")) {
  1050.  
  1051. // Spine
  1052. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1053. write_byte(TE_MODEL)
  1054. write_coord(origin[0])
  1055. write_coord(origin[1])
  1056. write_coord(origin[2]+30)
  1057. write_coord(rX + (rXm * random_num(0,80)))
  1058. write_coord(rY + (rYm * random_num(0,80)))
  1059. write_coord(rZ + (rZm * random_num(80,200)))
  1060. write_angle(random_num(0,360))
  1061. write_short(mdl_gib_spine)
  1062. write_byte(0) // bounce
  1063. write_byte(gibtime) // life
  1064. message_end()
  1065.  
  1066. // Lung
  1067. for(new i = 0; i <= 1; i++) {
  1068. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1069. write_byte(TE_MODEL)
  1070. write_coord(origin[0])
  1071. write_coord(origin[1])
  1072. write_coord(origin[2]+10)
  1073. write_coord(rX + (rXm * random_num(0,80)))
  1074. write_coord(rY + (rYm * random_num(0,80)))
  1075. write_coord(rZ + (rZm * random_num(80,200)))
  1076. write_angle(random_num(0,360))
  1077. write_short(mdl_gib_lung)
  1078. write_byte(0) // bounce
  1079. write_byte(gibtime) // life
  1080. message_end()
  1081. }
  1082.  
  1083. //Legs
  1084. for(new i = 0; i <= 1; i++) {
  1085. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1086. write_byte(TE_MODEL)
  1087. write_coord(origin[0])
  1088. write_coord(origin[1])
  1089. write_coord(origin[2]-10)
  1090. write_coord(rX + (rXm * random_num(0,80)))
  1091. write_coord(rY + (rYm * random_num(0,80)))
  1092. write_coord(rZ + (rZm * random_num(80,200)))
  1093. write_angle(random_num(0,360))
  1094. write_short(mdl_gib_legbone)
  1095. write_byte(0) // bounce
  1096. write_byte(gibtime) // life
  1097. message_end()
  1098. }
  1099. }
  1100.  
  1101. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1102. write_byte(TE_BLOODSPRITE)
  1103. write_coord(origin[0])
  1104. write_coord(origin[1])
  1105. write_coord(origin[2]+20)
  1106. write_short(spr_blood_spray)
  1107. write_short(spr_blood_drop)
  1108. write_byte(BLOOD_COLOR_RED) // color index
  1109. write_byte(10) // size
  1110. message_end()
  1111. }
  1112. #endif
  1113.  
  1114. fx_extra_blood(origin[3])
  1115. {
  1116. new x, y, z
  1117.  
  1118. for(new i = 0; i < 3; i++) {
  1119. x = random_num(-15,15)
  1120. y = random_num(-15,15)
  1121. z = random_num(-20,25)
  1122. for(new j = 0; j < 2; j++) {
  1123. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1124. write_byte(TE_BLOODSPRITE)
  1125. write_coord(origin[0]+(x*j))
  1126. write_coord(origin[1]+(y*j))
  1127. write_coord(origin[2]+(z*j))
  1128. write_short(spr_blood_spray)
  1129. write_short(spr_blood_drop)
  1130. write_byte(BLOOD_COLOR_RED) // color index
  1131. write_byte(15) // size
  1132. message_end()
  1133. }
  1134. }
  1135. }
  1136.  
  1137. fx_headshot(origin[3])
  1138. {
  1139. new iFlags = get_gore_flags()
  1140.  
  1141. new Sprays = 1
  1142.  
  1143. if (iFlags&GORE_EXTRA || iFlags&GORE_EXTRA_HS) {
  1144. if (equali(mod_name,"dod")) Sprays = 4
  1145. else Sprays = 8
  1146. }
  1147.  
  1148. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1149. write_byte(TE_BLOODSPRITE)
  1150. write_coord(origin[0])
  1151. write_coord(origin[1])
  1152. write_coord(origin[2]+40)
  1153. write_short(spr_blood_spray)
  1154. write_short(spr_blood_drop)
  1155. write_byte(BLOOD_COLOR_RED) // color index
  1156. write_byte(15) // size
  1157. message_end()
  1158.  
  1159. // Blood sprays
  1160. for (new i = 0; i < Sprays; i++) {
  1161. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1162. write_byte(TE_BLOODSTREAM)
  1163. write_coord(origin[0])
  1164. write_coord(origin[1])
  1165. write_coord(origin[2]+40)
  1166. write_coord(random_num(-30,30)) // x
  1167. write_coord(random_num(-30,30)) // y
  1168. write_coord(random_num(80,300)) // z
  1169. write_byte(BLOOD_STREAM_RED) // color
  1170. write_byte(random_num(100,200)) // speed
  1171. message_end()
  1172. }
  1173. }