Advertisement
Guest User

Untitled

a guest
May 27th, 2012
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.98 KB | None | 0 0
  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. **************************************************************************/
  148.  
  149. //Comment this out to totally disable the GIB code
  150. //This can help if maps are crashing from exceeding the precache limit
  151. #define GIBS_ENABLED
  152.  
  153. #include <amxmodx>
  154. #include <amxmisc>
  155. #include <fakemeta>
  156. #include <dodconst>
  157. #include <tfcconst>
  158. #include <tsconst>
  159.  
  160. //Auto-load the correct module if not loaded
  161. #pragma reqclass xstats
  162. #if !defined AMXMODX_NOAUTOLOAD
  163. #pragma defclasslib xstats csx
  164. #pragma defclasslib xstats dodx
  165. #pragma defclasslib xstats tfcx
  166. #pragma defclasslib xstats tsx
  167. #endif
  168.  
  169. #define MAX_PLAYERS 32
  170. #define MAX_HOSTAGES 16
  171.  
  172. #define GORE_HEADSHOT (1<<0) // "a"
  173. #define GORE_BLOOD (1<<1) // "b"
  174. #define GORE_BLEEDING (1<<2) // "c"
  175. #define GORE_GIB (1<<3) // "d"
  176. #define GORE_EXTRA (1<<4) // "e"
  177. #define GORE_EXTRA_HS (1<<5) // "f"
  178. #define GORE_HOSTAGES (1<<6) // "g"
  179.  
  180. #define BLOOD_COLOR_RED 247
  181. #define BLOOD_COLOR_YELLOW 195
  182. #define BLOOD_STREAM_RED 70
  183. #define BLOOD_STREAM_YELLOW 60
  184.  
  185. new gHealthIndex[MAX_PLAYERS+1]
  186. new Float:hostage_hp[MAX_HOSTAGES], hostages[MAX_HOSTAGES], host_num
  187.  
  188. #if defined GIBS_ENABLED
  189. new mdl_gib_flesh, mdl_gib_head, mdl_gib_legbone
  190. new mdl_gib_lung, mdl_gib_meat, mdl_gib_spine
  191. #endif
  192.  
  193. new spr_blood_drop, spr_blood_spray
  194.  
  195. #define BLOOD_SM_NUM 8
  196. #define BLOOD_LG_NUM 2
  197. new blood_small_red[BLOOD_SM_NUM], blood_large_red[BLOOD_LG_NUM]
  198. //new blood_small_yellow[BLOOD_SM_NUM], blood_large_yellow[BLOOD_LG_NUM]
  199.  
  200. new mod_name[32]//, bool:body_hidden[33]
  201. new pcvar_gore, pcvar_gore_exphp
  202.  
  203. //Offsets to place blood is more realistic hit location
  204. 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}}
  205.  
  206. // #####################################################################
  207. // ## Change which weapons cause GIB explosions on death HERE ##
  208. // #####################################################################
  209.  
  210. public gib_wpncheck(iWeapon)
  211. {
  212. //This section is used for CS/CZ
  213. if (cstrike_running()) {
  214. switch (iWeapon) {
  215. case CSW_P228 : return false
  216. case CSW_SCOUT : return false
  217. case CSW_HEGRENADE : return true
  218. case CSW_XM1014 : return false
  219. case CSW_C4 : return true
  220. case CSW_MAC10 : return false
  221. case CSW_AUG : return false
  222. case CSW_SMOKEGRENADE : return true
  223. case CSW_ELITE : return false
  224. case CSW_FIVESEVEN : return false
  225. case CSW_UMP45 : return false
  226. case CSW_SG550 : return false
  227. case CSW_GALIL : return false
  228. case CSW_FAMAS : return false
  229. case CSW_USP : return false
  230. case CSW_GLOCK18 : return false
  231. case CSW_AWP : return false
  232. case CSW_MP5NAVY : return false
  233. case CSW_M249 : return false
  234. case CSW_M3 : return false
  235. case CSW_M4A1 : return false
  236. case CSW_TMP : return false
  237. case CSW_G3SG1 : return false
  238. case CSW_FLASHBANG : return true
  239. case CSW_DEAGLE : return false
  240. case CSW_SG552 : return false
  241. case CSW_AK47 : return false
  242. case CSW_KNIFE : return false
  243. case CSW_P90 : return false
  244. }
  245. }
  246. //This section is used for DoD
  247. else if (equali(mod_name,"dod")) {
  248. switch (iWeapon) {
  249. case DODW_AMERKNIFE : return false
  250. case DODW_GERKNIFE : return false
  251. case DODW_COLT : return false
  252. case DODW_LUGER : return false
  253. case DODW_GARAND : return false
  254. case DODW_SCOPED_KAR : return false
  255. case DODW_THOMPSON : return false
  256. case DODW_STG44 : return false
  257. case DODW_SPRINGFIELD : return false
  258. case DODW_KAR : return false
  259. case DODW_BAR : return false
  260. case DODW_MP40 : return false
  261. case DODW_HANDGRENADE : return true
  262. case DODW_STICKGRENADE : return true
  263. case DODW_STICKGRENADE_EX : return true
  264. case DODW_HANDGRENADE_EX : return true
  265. case DODW_MG42 : return false
  266. case DODW_30_CAL : return false
  267. case DODW_SPADE : return false
  268. case DODW_M1_CARBINE : return false
  269. case DODW_MG34 : return false
  270. case DODW_GREASEGUN : return false
  271. case DODW_FG42 : return false
  272. case DODW_K43 : return false
  273. case DODW_ENFIELD : return false
  274. case DODW_STEN : return false
  275. case DODW_BREN : return false
  276. case DODW_WEBLEY : return false
  277. case DODW_BAZOOKA : return true
  278. case DODW_PANZERSCHRECK : return false
  279. case DODW_PIAT : return false
  280. case DODW_SCOPED_FG42 : return false
  281. case DODW_FOLDING_CARBINE : return false
  282. case DODW_KAR_BAYONET : return false
  283. case DODW_SCOPED_ENFIELD : return false
  284. case DODW_MILLS_BOMB : return true
  285. case DODW_BRITKNIFE : return false
  286. case DODW_GARAND_BUTT : return false
  287. case DODW_ENFIELD_BAYONET : return false
  288. case DODW_MORTAR : return false
  289. case DODW_K43_BUTT : return false
  290. }
  291. }
  292. //This section is used for TFC
  293. else if (equali(mod_name,"tfc")) {
  294. switch (iWeapon) {
  295. case TFC_WPN_NONE : return false
  296. case TFC_WPN_TIMER : return false
  297. case TFC_WPN_SENTRYGUN : return false
  298. case TFC_WPN_MEDIKIT : return false
  299. case TFC_WPN_SPANNER : return false
  300. case TFC_WPN_AXE : return false
  301. case TFC_WPN_SNIPERRIFLE : return false
  302. case TFC_WPN_AUTORIFLE : return false
  303. case TFC_WPN_SHOTGUN : return false
  304. case TFC_WPN_SUPERSHOTGUN : return false
  305. case TFC_WPN_NG : return false
  306. case TFC_WPN_SUPERNG : return false
  307. case TFC_WPN_GL : return false
  308. case TFC_WPN_FLAMETHROWER : return false
  309. case TFC_WPN_RPG : return true
  310. case TFC_WPN_IC : return false
  311. case TFC_WPN_FLAMES : return false
  312. case TFC_WPN_AC : return false
  313. case TFC_WPN_UNK18 : return false
  314. case TFC_WPN_UNK19 : return false
  315. case TFC_WPN_TRANQ : return false
  316. case TFC_WPN_RAILGUN : return false
  317. case TFC_WPN_PL : return false
  318. case TFC_WPN_KNIFE : return false
  319. case TFC_WPN_CALTROP : return false
  320. case TFC_WPN_CONCUSSIONGRENADE : return true
  321. case TFC_WPN_NORMALGRENADE : return true
  322. case TFC_WPN_NAILGRENADE : return true
  323. case TFC_WPN_MIRVGRENADE : return true
  324. case TFC_WPN_NAPALMGRENADE : return true
  325. case TFC_WPN_GASGRENADE : return false
  326. case TFC_WPN_EMPGRENADE : return false
  327. }
  328.  
  329. }
  330. //This section is used for TS
  331. else if (equali(mod_name,"ts")) {
  332. switch (iWeapon) {
  333. case TSW_GLOCK18 : return false
  334. case TSW_UNK1 : return false
  335. case TSW_UZI : return false
  336. case TSW_M3 : return false
  337. case TSW_M4A1 : return false
  338. case TSW_MP5SD : return false
  339. case TSW_MP5K : return false
  340. case TSW_ABERETTAS : return false
  341. case TSW_MK23 : return false
  342. case TSW_AMK23 : return false
  343. case TSW_USAS : return false
  344. case TSW_DEAGLE : return false
  345. case TSW_AK47 : return false
  346. case TSW_57 : return false
  347. case TSW_AUG : return false
  348. case TSW_AUZI : return false
  349. case TSW_TMP : return false
  350. case TSW_M82A1 : return false
  351. case TSW_MP7 : return false
  352. case TSW_SPAS : return false
  353. case TSW_GCOLTS : return false
  354. case TSW_GLOCK20 : return false
  355. case TSW_UMP : return false
  356. case TSW_M61GRENADE : return true
  357. case TSW_CKNIFE : return false
  358. case TSW_MOSSBERG : return false
  359. case TSW_M16A4 : return false
  360. case TSW_MK1 : return false
  361. case TSW_C4 : return true
  362. case TSW_A57 : return false
  363. case TSW_RBULL : return false
  364. case TSW_M60E3 : return false
  365. case TSW_SAWED_OFF : return true
  366. case TSW_KATANA : return false
  367. case TSW_SKNIFE : return false
  368. case TSW_KUNG_FU : return false
  369. case TSW_TKNIFE : return false
  370. }
  371. }
  372. //This section is used for ESF
  373. else if (equali(mod_name,"esf")) {
  374. //Always do GIB explosions on ESF
  375. return true
  376. }
  377. //This section is used for the "valve" mod
  378. else if (equali(mod_name,"valve")) {
  379. switch (iWeapon) {
  380. case HLW_NONE : return false
  381. case HLW_CROWBAR : return false
  382. case HLW_GLOCK : return false
  383. case HLW_PYTHON : return false
  384. case HLW_MP5 : return false
  385. case HLW_CHAINGUN : return false
  386. case HLW_CROSSBOW : return false
  387. case HLW_SHOTGUN : return false
  388. case HLW_RPG : return true
  389. case HLW_GAUSS : return false
  390. case HLW_EGON : return false
  391. case HLW_HORNETGUN : return false
  392. case HLW_HANDGRENADE : return true
  393. case HLW_TRIPMINE : return true
  394. case HLW_SATCHEL : return true
  395. case HLW_SNARK : return false
  396. }
  397. }
  398.  
  399. //Always false on Sven Co-op
  400. return false
  401. }
  402.  
  403. // #####################################################################
  404. // ## DO NOT EDIT BELOW HERE ##
  405. // #####################################################################
  406.  
  407. /************************************************************
  408. * PLUGIN FUNCTIONS
  409. ************************************************************/
  410.  
  411. public plugin_init()
  412. {
  413. register_plugin("Ultimate Gore","1.6","JTP10181")
  414.  
  415. get_modname(mod_name,31)
  416.  
  417. if (cstrike_running()) {
  418. register_logevent("event_roundstart", 2, "1=Round_Start")
  419. register_event("TextMsg","event_host_damage","b","2=#Injured_Hostage")
  420. register_event("TextMsg","event_host_killed","b","2=#Killed_Hostage")
  421. //register_message(122, "event_ClCorpse") //ClCorpse
  422. }
  423. else if (equali(mod_name,"dod")) {
  424. //register_message(126, "event_ClCorpse") //ClCorpse
  425. }
  426. else if (equali(mod_name,"esf")) {
  427. register_event("DeathMsg","event_death","a")
  428. register_event("Health","event_damage","b")
  429. }
  430. else if (equali(mod_name,"svencoop")) {
  431. register_event("Damage","event_damage","b","2!0")
  432. }
  433. else if (equali(mod_name,"valve") || equali(mod_name,"ns")) {
  434. register_event("DeathMsg","event_death","a")
  435. register_event("Damage","event_damage","b","2!0")
  436. }
  437.  
  438. register_event("ResetHUD","event_respawn","b")
  439.  
  440. pcvar_gore = register_cvar("amx_gore","abcd")
  441. pcvar_gore_exphp = register_cvar("amx_gore_exphp","160")
  442. set_task(1.5,"event_blood",100,"",0,"b")
  443.  
  444. // Blood decals
  445. if (equali(mod_name,"cstrike")) {
  446. blood_large_red = {204,205}
  447. blood_small_red = {190,191,192,193,194,195,196,197}
  448. }
  449. else if (equali(mod_name,"czero")) {
  450. blood_large_red = {216,217}
  451. blood_small_red = {202,203,204,205,206,207,208,209}
  452. }
  453. else if (equali(mod_name,"dod")) {
  454. blood_large_red = {217,218}
  455. blood_small_red = {203,204,205,206,207,208,209,210}
  456. }
  457. else if (equali(mod_name,"tfc")) {
  458. blood_large_red = {208,209}
  459. blood_small_red = {194,195,196,197,198,199,200,201}
  460. }
  461. else if (equali(mod_name,"ts")) {
  462. blood_large_red = {218,219}
  463. blood_small_red = {204,205,206,207,208,209,210,211}
  464. }
  465. else if (equali(mod_name,"svencoop")) {
  466. blood_large_red = {210,211}
  467. blood_small_red = {196,197,198,199,200,201,202,203}
  468. }
  469. //"valve" mod and others that use its decals.wad (ESF, NS)
  470. else {
  471. blood_large_red = {19,20}
  472. blood_small_red = {27,28,29,30,31,32,33,34}
  473. }
  474.  
  475. //Setup jtp10181 CVAR
  476. new cvarString[256], shortName[16]
  477. copy(shortName,15,"gore")
  478.  
  479. register_cvar("jtp10181","",FCVAR_SERVER|FCVAR_SPONLY)
  480. get_cvar_string("jtp10181",cvarString,255)
  481.  
  482. if (strlen(cvarString) == 0) {
  483. formatex(cvarString,255,shortName)
  484. set_cvar_string("jtp10181",cvarString)
  485. }
  486. else if (contain(cvarString,shortName) == -1) {
  487. format(cvarString,255,"%s,%s",cvarString, shortName)
  488. set_cvar_string("jtp10181",cvarString)
  489. }
  490. }
  491.  
  492. public plugin_natives()
  493. {
  494. set_module_filter("module_filter")
  495. set_native_filter("native_filter")
  496. }
  497.  
  498. public module_filter(const module[])
  499. {
  500. if (equali(module, "xstats")) {
  501. if (cstrike_running()) return PLUGIN_CONTINUE
  502. if (equali(mod_name,"dod")) return PLUGIN_CONTINUE
  503. if (equali(mod_name,"tfc")) return PLUGIN_CONTINUE
  504. if (equali(mod_name,"ts")) return PLUGIN_CONTINUE
  505.  
  506. return PLUGIN_HANDLED
  507. }
  508. return PLUGIN_CONTINUE
  509. }
  510.  
  511. public native_filter(const name[], index, trap)
  512. {
  513. if (!trap) return PLUGIN_HANDLED
  514.  
  515. return PLUGIN_CONTINUE
  516. }
  517.  
  518. public plugin_precache()
  519. {
  520. spr_blood_drop = precache_model("sprites/blood.spr")
  521. spr_blood_spray = precache_model("sprites/bloodspray.spr")
  522.  
  523. #if defined GIBS_ENABLED
  524. mdl_gib_flesh = precache_model("models/Fleshgibs.mdl")
  525. mdl_gib_meat = precache_model("models/GIB_B_Gib.mdl")
  526. mdl_gib_head = precache_model("models/GIB_Skull.mdl")
  527.  
  528. if (!equali(mod_name,"dod")) {
  529. mdl_gib_spine = precache_model("models/GIB_B_Bone.mdl")
  530. mdl_gib_lung = precache_model("models/GIB_Lung.mdl")
  531. mdl_gib_legbone = precache_model("models/GIB_Legbone.mdl")
  532. }
  533. #endif
  534. }
  535.  
  536. public plugin_cfg()
  537. {
  538. if (!cstrike_running()) return
  539.  
  540. new iEnt = -1
  541. host_num = 0
  542. while ((iEnt = engfunc(EngFunc_FindEntityByString, iEnt, "classname", "hostage_entity")) != 0) {
  543. hostages[host_num++] = iEnt
  544. if (host_num >= MAX_HOSTAGES) break
  545. }
  546. }
  547.  
  548. //Custom function to get origin with FM and return it as an integer
  549. public get_origin_int(index, origin[3])
  550. {
  551. new Float:FVec[3]
  552.  
  553. pev(index,pev_origin,FVec)
  554.  
  555. origin[0] = floatround(FVec[0])
  556. origin[1] = floatround(FVec[1])
  557. origin[2] = floatround(FVec[2])
  558.  
  559. return 1
  560. }
  561.  
  562. /************************************************************
  563. * EVENTS
  564. ************************************************************/
  565.  
  566. //For "valve", ESF, NS, SvenCoop
  567. public event_damage(iVictim)
  568. {
  569. if (iVictim <= 0 || iVictim > MAX_PLAYERS) return
  570.  
  571. new iWeapon, iHitPlace, iAgressor
  572. iAgressor = get_user_attacker(iVictim,iWeapon,iHitPlace)
  573.  
  574. //Sven Co-op does not seem to send Death messages so we will do this
  575. if (equali(mod_name,"svencoop")) {
  576. if (get_user_health(iVictim) <=0) {
  577. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  578. return
  579. }
  580. }
  581.  
  582. process_damage(iAgressor, iVictim, iHitPlace)
  583. }
  584.  
  585. //Forward for CS/CZ, DoD, TFC, TS
  586. public client_damage(attacker,victim,damage,wpnindex,hitplace)
  587. {
  588. if (victim <= 0 || victim > MAX_PLAYERS) return
  589. process_damage(attacker, victim, hitplace)
  590. }
  591.  
  592. //This will process the damage info for all mods
  593. process_damage(iAgressor, iVictim, iHitPlace)
  594. {
  595. new iFlags = get_gore_flags()
  596.  
  597. //Don't want to do this if the player just died
  598. new vHealth = get_user_health(iVictim)
  599. if (vHealth <= 0 || vHealth >= gHealthIndex[iVictim]) return
  600.  
  601. //server_print("************************* DAMAGE: %d %d %d %d", iVictim, iAgressor, vHealth, iHitPlace)
  602.  
  603. gHealthIndex[iVictim] = vHealth
  604.  
  605. //Check to make sure its a valid entity
  606. if (!pev_valid(iAgressor)) {
  607. iAgressor = iVictim
  608. iHitPlace = 0
  609. }
  610.  
  611. //Crash/error check
  612. if (!is_user_connected(iVictim)) return
  613. if (iHitPlace < 0 || iHitPlace > 7) iHitPlace = 0
  614.  
  615. if (iFlags&GORE_BLOOD) {
  616. new iOrigin[3], iOrigin2[3]
  617. get_origin_int(iVictim,iOrigin)
  618. get_origin_int(iAgressor,iOrigin2)
  619.  
  620. fx_blood(iOrigin,iOrigin2,iHitPlace)
  621. fx_blood_small(iOrigin,8)
  622. if (iFlags&GORE_EXTRA) {
  623. fx_blood(iOrigin,iOrigin2,iHitPlace)
  624. fx_blood(iOrigin,iOrigin2,iHitPlace)
  625. fx_blood(iOrigin,iOrigin2,iHitPlace)
  626. fx_blood_small(iOrigin,4)
  627. }
  628. }
  629. }
  630.  
  631. //Hostage Event for CS/CZ
  632. public event_host_damage(iAgressor)
  633. {
  634. new Float:vHeatlh, iVictim, iHitPlace = 0
  635. new iFlags = get_gore_flags()
  636. new hostid, Float:hosthp
  637.  
  638. if (!(iFlags&GORE_HOSTAGES)) return
  639.  
  640. //Find what hostage was injured
  641. for (new x = 0; x < host_num; x++) {
  642. hostid = hostages[x]
  643. hosthp = hostage_hp[x]
  644.  
  645. if (!pev_valid(hostid)) continue
  646. if (hosthp <= 0.0) continue
  647. pev(hostid, pev_health, vHeatlh)
  648.  
  649. if (vHeatlh > 0.0 && vHeatlh < hosthp) {
  650. iVictim = hostid
  651. }
  652.  
  653. hosthp = vHeatlh
  654. }
  655.  
  656. //No valid hostage entity found
  657. if (iVictim <= 0) return
  658.  
  659. //Check to make sure its a player
  660. if (!is_user_connected(iAgressor)) {
  661. iAgressor = iVictim
  662. }
  663.  
  664. if (iFlags&GORE_BLOOD) {
  665. new iOrigin[3], iOrigin2[3]
  666.  
  667. get_origin_int(iVictim, iOrigin)
  668. get_origin_int(iAgressor, iOrigin2)
  669.  
  670. //Add height to Hostage origin
  671. iOrigin[2] += 36
  672.  
  673. fx_blood(iOrigin,iOrigin2,iHitPlace)
  674. fx_blood_small(iOrigin,8)
  675. if (iFlags&GORE_EXTRA) {
  676. fx_blood(iOrigin,iOrigin2,iHitPlace)
  677. fx_blood(iOrigin,iOrigin2,iHitPlace)
  678. fx_blood(iOrigin,iOrigin2,iHitPlace)
  679. fx_blood_small(iOrigin,4)
  680. }
  681. }
  682. }
  683.  
  684. //For "valve", ESF, NS
  685. public event_death()
  686. {
  687. new iVictim = read_data(2)
  688. new iWeapon, iHitPlace
  689.  
  690. if (iVictim <= 0 || iVictim > MAX_PLAYERS) return
  691. new iAgressor = get_user_attacker(iVictim,iWeapon,iHitPlace)
  692.  
  693. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  694. }
  695.  
  696. //Forward for CS/CZ, DoD, TFC, TS
  697. public client_death(killer,victim,wpnindex,hitplace)
  698. {
  699. if (victim <= 0 || victim > MAX_PLAYERS) return
  700. process_death(killer, victim, wpnindex, hitplace)
  701. }
  702.  
  703. //This will process the death info for all mods
  704. process_death(iAgressor, iVictim, iWeapon, iHitPlace)
  705. {
  706. //server_print("************************* DEATH: %d %d %d %d", iVictim, iAgressor, iWeapon, iHitPlace)
  707.  
  708. new iOrigin[3], iOrigin2[3]
  709. new iFlags = get_gore_flags()
  710.  
  711. //Check to make sure its a valid entity
  712. if (!pev_valid(iAgressor)) {
  713. iAgressor = iVictim
  714. iWeapon = 0
  715. iHitPlace = 0
  716. }
  717.  
  718. if (!is_user_connected(iVictim)) return
  719.  
  720. get_origin_int(iVictim, iOrigin)
  721. get_origin_int(iAgressor, iOrigin2)
  722.  
  723. if (iFlags&GORE_HEADSHOT && iHitPlace == HIT_HEAD) {
  724. fx_headshot(iOrigin)
  725. }
  726.  
  727. #if defined GIBS_ENABLED
  728. if (iFlags&GORE_GIB && (gib_wpncheck(iWeapon) || gHealthIndex[iVictim] - get_user_health(iVictim) >= get_pcvar_num(pcvar_gore_exphp))) {
  729.  
  730. // Effects
  731. fx_invisible(iVictim)
  732. //body_hidden[iVictim] = true
  733.  
  734. fx_gib_explode(iOrigin,iOrigin2)
  735. fx_blood_large(iOrigin,4)
  736. fx_blood_small(iOrigin,4)
  737. }
  738. #endif
  739.  
  740. fx_blood_small(iOrigin,8)
  741.  
  742. if (iFlags&GORE_EXTRA && !equali(mod_name,"dod")) {
  743. fx_extra_blood(iOrigin)
  744. fx_blood_large(iOrigin,2)
  745. fx_blood_small(iOrigin,4)
  746. }
  747. }
  748.  
  749. //Hostage Event for CS/CZ
  750. public event_host_killed(iAgressor)
  751. {
  752. new Float:vHeatlh, HP_Loss, iVictim, iWeapon = 0, clip, ammo
  753. new iFlags = get_gore_flags()
  754. new hostid, Float:hosthp
  755.  
  756. if (!(iFlags&GORE_HOSTAGES)) return
  757.  
  758. //Find what hostage was killed
  759. for (new x = 0; x < host_num; x++) {
  760. hostid = hostages[x]
  761. hosthp = hostage_hp[x]
  762.  
  763. if (!pev_valid(hostid)) continue
  764. if (hosthp <= 0.0) continue
  765.  
  766. pev(hostid, pev_health, vHeatlh)
  767.  
  768. if (vHeatlh <= 0.0 && vHeatlh < hosthp) {
  769. iVictim = hostid
  770. HP_Loss = floatround(hosthp - vHeatlh)
  771. }
  772.  
  773. hosthp = vHeatlh
  774. }
  775.  
  776. //No valid hostage entity found
  777. if (iVictim <= 0) return
  778.  
  779. //Check to make sure its a player
  780. if (is_user_alive(iAgressor)) {
  781. iWeapon = get_user_weapon(iAgressor,clip,ammo)
  782. }
  783. else {
  784. iAgressor = iVictim
  785. }
  786.  
  787. new iOrigin[3], iOrigin2[3]
  788.  
  789. get_origin_int(iVictim, iOrigin)
  790. get_origin_int(iAgressor, iOrigin2)
  791.  
  792. //Add height to Hostage origin
  793. iOrigin[2] += 36
  794.  
  795. #if defined GIBS_ENABLED
  796. if (iFlags&GORE_GIB && (gib_wpncheck(iWeapon) || HP_Loss >= floatround(get_pcvar_float(pcvar_gore_exphp) * 0.6))) {
  797.  
  798. // Effects
  799. fx_invisible(iVictim)
  800. fx_gib_explode(iOrigin,iOrigin2)
  801. fx_blood_large(iOrigin,4)
  802. fx_blood_small(iOrigin,4)
  803. }
  804. #endif
  805.  
  806. fx_blood_small(iOrigin,8)
  807. if (iFlags&GORE_EXTRA) {
  808. fx_extra_blood(iOrigin)
  809. fx_blood_large(iOrigin,2)
  810. fx_blood_small(iOrigin,4)
  811. }
  812. }
  813.  
  814. public event_blood()
  815. {
  816. new iFlags = get_gore_flags()
  817. if (!(iFlags&GORE_BLEEDING)) return
  818.  
  819. new iPlayer, iPlayers[MAX_PLAYERS], iNumPlayers, iOrigin[3]
  820. get_players(iPlayers,iNumPlayers,"a")
  821. for (new i = 0; i < iNumPlayers; i++) {
  822. iPlayer = iPlayers[i]
  823. gHealthIndex[iPlayer] = get_user_health(iPlayer)
  824. if (gHealthIndex[iPlayer] < 20) {
  825. get_origin_int(iPlayer, iOrigin)
  826. fx_bleed(iOrigin)
  827. fx_blood_small(iOrigin,3)
  828. }
  829. }
  830.  
  831. if (!(iFlags&GORE_HOSTAGES)) return
  832.  
  833. //Hostage Bleeding
  834. if (cstrike_running()) {
  835. new iOrigin[3], hostid, Float:hosthp
  836. for (new x = 0; x < host_num; x++) {
  837. hostid = hostages[x]
  838. hosthp = hostage_hp[x]
  839. if (!pev_valid(hostid)) continue
  840. pev(hostid, pev_health, hosthp)
  841. if (hosthp > 0.0 && hosthp < 20.0) {
  842. get_origin_int(hostid, iOrigin)
  843. iOrigin[2] += 36.0
  844. fx_bleed(iOrigin)
  845. fx_blood_small(iOrigin,3)
  846. }
  847. }
  848. }
  849. }
  850.  
  851. public event_respawn(id)
  852. {
  853. if (is_user_alive(id)) {
  854. //Reset body_hidden flag
  855. //body_hidden[id] = false
  856. //Restore model visibility
  857. set_pev(id, pev_rendermode, kRenderNormal)
  858. //Save clients current Health
  859. gHealthIndex[id] = get_user_health(id)
  860. }
  861. }
  862.  
  863. public event_roundstart(id)
  864. {
  865. set_task(0.1,"roundstart_delay",100)
  866. }
  867.  
  868. public roundstart_delay()
  869. {
  870. for ( new id = 1; id <= MAX_PLAYERS; id++ ) {
  871. if (is_user_alive(id)) {
  872. //Reset body_hidden flag
  873. //body_hidden[id] = false
  874. //Save clients current Health
  875. gHealthIndex[id] = get_user_health(id)
  876. }
  877. }
  878.  
  879. if (cstrike_running()) {
  880. new hostid
  881. for (new x = 0; x < host_num; x++) {
  882. hostid = hostages[x]
  883. if (!pev_valid(hostid)) continue
  884. set_pev(hostid, pev_rendermode, kRenderNormal)
  885. pev(hostid, pev_health, hostage_hp[x])
  886. }
  887. }
  888. }
  889.  
  890. //Hides Corpses in CS / DoD
  891. public event_ClCorpse()
  892. {
  893. //If there is not 12 args something is wrong
  894. if (get_msg_args() != 12) return PLUGIN_CONTINUE
  895.  
  896. //Arg 12 is the player id the corpse is for
  897. new id = get_msg_arg_int(12)
  898.  
  899. //If the corpse should be hidden block this message
  900. if (body_hidden[id]) return PLUGIN_HANDLED
  901.  
  902. return PLUGIN_CONTINUE
  903. }
  904.  
  905. public get_gore_flags()
  906. {
  907. new sFlags[24]
  908. get_pcvar_string(pcvar_gore,sFlags,23)
  909. return read_flags(sFlags)
  910. }
  911.  
  912. /************************************************************
  913. * FX FUNCTIONS
  914. ************************************************************/
  915.  
  916. fx_invisible(id)
  917. {
  918. set_pev(id, pev_renderfx, kRenderFxNone)
  919. set_pev(id, pev_rendermode, kRenderTransAlpha)
  920. set_pev(id, pev_renderamt, 0.0)
  921. }
  922.  
  923. fx_blood(origin[3],origin2[3],HitPlace)
  924. {
  925. //Crash Checks
  926. if (HitPlace < 0 || HitPlace > 7) HitPlace = 0
  927. new rDistance = get_distance(origin,origin2) ? get_distance(origin,origin2) : 1
  928.  
  929. new rX = ((origin[0]-origin2[0]) * 300) / rDistance
  930. new rY = ((origin[1]-origin2[1]) * 300) / rDistance
  931. new rZ = ((origin[2]-origin2[2]) * 300) / rDistance
  932.  
  933. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  934. write_byte(TE_BLOODSTREAM)
  935. write_coord(origin[0]+Offset[HitPlace][0])
  936. write_coord(origin[1]+Offset[HitPlace][1])
  937. write_coord(origin[2]+Offset[HitPlace][2])
  938. write_coord(rX) // x
  939. write_coord(rY) // y
  940. write_coord(rZ) // z
  941. write_byte(BLOOD_STREAM_RED) // color
  942. write_byte(random_num(100,200)) // speed
  943. message_end()
  944. }
  945.  
  946. fx_bleed(origin[3])
  947. {
  948. // Blood spray
  949. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  950. write_byte(TE_BLOODSTREAM)
  951. write_coord(origin[0])
  952. write_coord(origin[1])
  953. write_coord(origin[2]+10)
  954. write_coord(random_num(-360,360)) // x
  955. write_coord(random_num(-360,360)) // y
  956. write_coord(-10) // z
  957. write_byte(BLOOD_STREAM_RED) // color
  958. write_byte(random_num(50,100)) // speed
  959. message_end()
  960. }
  961.  
  962. fx_blood_small(origin[3],num)
  963. {
  964. if (equali(mod_name,"esf")) return
  965.  
  966. // Write Small splash decal
  967. for (new j = 0; j < num; j++) {
  968. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  969. write_byte(TE_WORLDDECAL)
  970. write_coord(origin[0]+random_num(-100,100))
  971. write_coord(origin[1]+random_num(-100,100))
  972. write_coord(origin[2]-36)
  973. write_byte(blood_small_red[random_num(0,BLOOD_SM_NUM - 1)]) // index
  974. message_end()
  975. }
  976. }
  977.  
  978. fx_blood_large(origin[3],num)
  979. {
  980. if (equali(mod_name,"esf")) return
  981.  
  982. // Write Large splash decal
  983. for (new i = 0; i < num; i++) {
  984. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  985. write_byte(TE_WORLDDECAL)
  986. write_coord(origin[0]+random_num(-50,50))
  987. write_coord(origin[1]+random_num(-50,50))
  988. write_coord(origin[2]-36)
  989. write_byte(blood_large_red[random_num(0,BLOOD_LG_NUM - 1)]) // index
  990. message_end()
  991. }
  992. }
  993.  
  994. #if defined GIBS_ENABLED
  995. fx_gib_explode(origin[3],origin2[3])
  996. {
  997. new flesh[2]
  998. flesh[0] = mdl_gib_flesh
  999. flesh[1] = mdl_gib_meat
  1000. new mult, gibtime = 400 //40 seconds
  1001.  
  1002. if (equali(mod_name,"esf")) mult = 400
  1003. else if (equali(mod_name,"ts")) mult = 140
  1004. else mult = 80
  1005.  
  1006. new rDistance = get_distance(origin,origin2) ? get_distance(origin,origin2) : 1
  1007. new rX = ((origin[0]-origin2[0]) * mult) / rDistance
  1008. new rY = ((origin[1]-origin2[1]) * mult) / rDistance
  1009. new rZ = ((origin[2]-origin2[2]) * mult) / rDistance
  1010. new rXm = rX >= 0 ? 1 : -1
  1011. new rYm = rY >= 0 ? 1 : -1
  1012. new rZm = rZ >= 0 ? 1 : -1
  1013.  
  1014. // Gib explosions
  1015.  
  1016. // Head
  1017. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1018. write_byte(TE_MODEL)
  1019. write_coord(origin[0])
  1020. write_coord(origin[1])
  1021. write_coord(origin[2]+40)
  1022. write_coord(rX + (rXm * random_num(0,80)))
  1023. write_coord(rY + (rYm * random_num(0,80)))
  1024. write_coord(rZ + (rZm * random_num(80,200)))
  1025. write_angle(random_num(0,360))
  1026. write_short(mdl_gib_head)
  1027. write_byte(0) // bounce
  1028. write_byte(gibtime) // life
  1029. message_end()
  1030.  
  1031. // Parts
  1032. for(new i = 0; i < 4; i++) {
  1033. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1034. write_byte(TE_MODEL)
  1035. write_coord(origin[0])
  1036. write_coord(origin[1])
  1037. write_coord(origin[2])
  1038. write_coord(rX + (rXm * random_num(0,80)))
  1039. write_coord(rY + (rYm * random_num(0,80)))
  1040. write_coord(rZ + (rZm * random_num(80,200)))
  1041. write_angle(random_num(0,360))
  1042. write_short(flesh[random_num(0,1)])
  1043. write_byte(0) // bounce
  1044. write_byte(gibtime) // life
  1045. message_end()
  1046. }
  1047.  
  1048. if (!equali(mod_name,"dod")) {
  1049.  
  1050. // Spine
  1051. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1052. write_byte(TE_MODEL)
  1053. write_coord(origin[0])
  1054. write_coord(origin[1])
  1055. write_coord(origin[2]+30)
  1056. write_coord(rX + (rXm * random_num(0,80)))
  1057. write_coord(rY + (rYm * random_num(0,80)))
  1058. write_coord(rZ + (rZm * random_num(80,200)))
  1059. write_angle(random_num(0,360))
  1060. write_short(mdl_gib_spine)
  1061. write_byte(0) // bounce
  1062. write_byte(gibtime) // life
  1063. message_end()
  1064.  
  1065. // Lung
  1066. for(new i = 0; i <= 1; i++) {
  1067. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1068. write_byte(TE_MODEL)
  1069. write_coord(origin[0])
  1070. write_coord(origin[1])
  1071. write_coord(origin[2]+10)
  1072. write_coord(rX + (rXm * random_num(0,80)))
  1073. write_coord(rY + (rYm * random_num(0,80)))
  1074. write_coord(rZ + (rZm * random_num(80,200)))
  1075. write_angle(random_num(0,360))
  1076. write_short(mdl_gib_lung)
  1077. write_byte(0) // bounce
  1078. write_byte(gibtime) // life
  1079. message_end()
  1080. }
  1081.  
  1082. //Legs
  1083. for(new i = 0; i <= 1; i++) {
  1084. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1085. write_byte(TE_MODEL)
  1086. write_coord(origin[0])
  1087. write_coord(origin[1])
  1088. write_coord(origin[2]-10)
  1089. write_coord(rX + (rXm * random_num(0,80)))
  1090. write_coord(rY + (rYm * random_num(0,80)))
  1091. write_coord(rZ + (rZm * random_num(80,200)))
  1092. write_angle(random_num(0,360))
  1093. write_short(mdl_gib_legbone)
  1094. write_byte(0) // bounce
  1095. write_byte(gibtime) // life
  1096. message_end()
  1097. }
  1098. }
  1099.  
  1100. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1101. write_byte(TE_BLOODSPRITE)
  1102. write_coord(origin[0])
  1103. write_coord(origin[1])
  1104. write_coord(origin[2]+20)
  1105. write_short(spr_blood_spray)
  1106. write_short(spr_blood_drop)
  1107. write_byte(BLOOD_COLOR_RED) // color index
  1108. write_byte(10) // size
  1109. message_end()
  1110. }
  1111. #endif
  1112.  
  1113. fx_extra_blood(origin[3])
  1114. {
  1115. new x, y, z
  1116.  
  1117. for(new i = 0; i < 3; i++) {
  1118. x = random_num(-15,15)
  1119. y = random_num(-15,15)
  1120. z = random_num(-20,25)
  1121. for(new j = 0; j < 2; j++) {
  1122. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1123. write_byte(TE_BLOODSPRITE)
  1124. write_coord(origin[0]+(x*j))
  1125. write_coord(origin[1]+(y*j))
  1126. write_coord(origin[2]+(z*j))
  1127. write_short(spr_blood_spray)
  1128. write_short(spr_blood_drop)
  1129. write_byte(BLOOD_COLOR_RED) // color index
  1130. write_byte(15) // size
  1131. message_end()
  1132. }
  1133. }
  1134. }
  1135.  
  1136. fx_headshot(origin[3])
  1137. {
  1138. new iFlags = get_gore_flags()
  1139.  
  1140. new Sprays = 1
  1141.  
  1142. if (iFlags&GORE_EXTRA || iFlags&GORE_EXTRA_HS) {
  1143. if (equali(mod_name,"dod")) Sprays = 4
  1144. else Sprays = 8
  1145. }
  1146.  
  1147. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1148. write_byte(TE_BLOODSPRITE)
  1149. write_coord(origin[0])
  1150. write_coord(origin[1])
  1151. write_coord(origin[2]+40)
  1152. write_short(spr_blood_spray)
  1153. write_short(spr_blood_drop)
  1154. write_byte(BLOOD_COLOR_RED) // color index
  1155. write_byte(15) // size
  1156. message_end()
  1157.  
  1158. // Blood sprays
  1159. for (new i = 0; i < Sprays; i++) {
  1160. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1161. write_byte(TE_BLOODSTREAM)
  1162. write_coord(origin[0])
  1163. write_coord(origin[1])
  1164. write_coord(origin[2]+40)
  1165. write_coord(random_num(-30,30)) // x
  1166. write_coord(random_num(-30,30)) // y
  1167. write_coord(random_num(80,300)) // z
  1168. write_byte(BLOOD_STREAM_RED) // color
  1169. write_byte(random_num(100,200)) // speed
  1170. message_end()
  1171. }
  1172. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement