/*
---------------------------------------------------------
# # # #=== ### ## #
# ## #=== # # # #
# # #=== ### ## #
---------------------------------------------------------
Gib Death 1.7
Plugin made by <VeCo>
Special thanks to:
- IMBA : for removing the death bodies.
- hateYou : for the optimization
- papyrus_kn : for the video of the plugin
- alan_el_more : for using Ham_Spawn instead of ResetHUD
- Nextra : for the optimization
- Arkshine : for fixing the bugs in version 1.7
If you modify the code, please DO NOT change the author!
---------------------------------------------------------
Contacts:
e-mail: veco.kn@gmail.com
skype: veco_kn
---------------------------------------------------------
Changes log:
-> v 1.0 = First release!
-> v 1.1 = Optimization.
-> v 1.2 = Fixed bug with spectators.
Fixed bug with some of materials.
Plugin needs fun module.
Added two new materials.
-> v 1.3 = Fixed part of code for removing
the death bodies.
Plugin doesn't needs engine module.
Added new material.
-> v 1.4 = Changed ResetHUD to Ham_Spawn.
Plugin needs hamsandwich module.
Removed fun module.
-> v 1.5 = Optimization.
Added new material.
-> v 1.6 = Added CVAR for changing the spread of the gibs.
Optimization.
Added new material.
-> v 1.7 = Fixed a lot of bugs.
Plugin doesn't need fakemeta module.
Plugin needs engine and fun modules.
---------------------------------------------------------
Don't forget to visit http://www.amxmodxbg.org :)
---------------------------------------------------------
*/
#include <amxmodx>
#include <fun>
#include <engine>
#include <hamsandwich>
enum GIBS
{
HGIBS = 1,
GGIBS,
WGIBS,
MGIBS,
CGIBS,
CEGIBS,
COGIBS,
RGIBS,
BGIBS,
GAGIBS,
BOGIBS,
PGIBS,
WGIBS
}
new gcvar,scvar,material[33],gibtypes[GIBS]
public plugin_precache()
{
gibtypes[HGIBS] = precache_model("models/hgibs.mdl")
gibtypes[GGIBS] = precache_model("models/glassgibs.mdl")
gibtypes[WGIBS] = precache_model("models/woodgibs.mdl")
gibtypes[MGIBS] = precache_model("models/metalplategibs.mdl")
gibtypes[CGIBS] = precache_model("models/cindergibs.mdl")
gibtypes[CEGIBS] = precache_model("models/ceilinggibs.mdl")
gibtypes[COGIBS] = precache_model("models/computergibs.mdl")
gibtypes[RGIBS] = precache_model("models/rockgibs.mdl")
gibtypes[BGIBS] = precache_model("models/bookgibs.mdl")
gibtypes[GAGIBS] = precache_model("models/garbagegibs.mdl")
gibtypes[BOGIBS] = precache_model("models/bonegibs.mdl")
gibtypes[PGIBS] = precache_model("models/cactusgibs.mdl")
gibtypes[WGIBS] = precache_model("models/webgibs.mdl")
}
public plugin_init() {
register_plugin("Gib Death", "1.7", "VeCo")
register_event("DeathMsg","hook_death","a")
RegisterHam(Ham_Spawn,"player","reset_vis",1)
gcvar = register_cvar("gib_type","0")
scvar = register_cvar("gib_spread","10")
register_cvar("gib_version", "1.7", FCVAR_SERVER|FCVAR_SPONLY)
set_msg_block( get_user_msgid( "ClCorpse" ), BLOCK_SET )
}
public hook_death()
{
new id = read_data(2)
set_user_rendering(id,kRenderFxNone,255,255,255,kRenderTransAlpha,0)
gib_death(id)
}
public gib_death(id)
{
new origin[3]
get_user_origin(id,origin)
message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
write_byte(TE_BREAKMODEL)
write_coord(origin[0])
write_coord(origin[1])
write_coord(origin[2] + 24)
write_coord(16)
write_coord(16)
write_coord(16)
write_coord(random_num(-50,50))
write_coord(random_num(-50,50))
write_coord(25)
write_byte(get_pcvar_num(scvar))
new gibvalue = clamp(get_pcvar_num(gcvar),0,13)
if(!gibvalue)
{
new rnum = random_num(1,13)
write_short(gibtypes[GIBS:rnum])
material[id] = rnum
} else {
write_short(gibtypes[GIBS:gibvalue])
material[id] = gibvalue
}
write_byte(14)
write_byte(30)
switch(material[id])
{
case 2: write_byte(0x01)
case 3: write_byte(0x08)
case 4,7: write_byte(0x02)
case 5,6,11: write_byte(0x04)
default: write_byte(0)
}
message_end()
}
public reset_vis(id)
{
if(!is_user_alive(id)) return
set_user_rendering(id,kRenderFxNone,255,255,255,kRenderNormal,0)
}