#include < amxmodx >
#include < fakemeta >
#include < fakemeta_util >
#include < hamsandwich >
#define PLUGIN "New HE Grenade Effects"
#define VERSION "1.3"
#define AUTHOR "aNNak1N"
new const g_szFireGib[ ] = "sprites/firegib.spr";
new const g_szExplosionFire[ ] = "sprites/fireexplosion.spr";
new const g_szFireWorks[ ] = "sprites/fireworks_sprite2.spr";
new const g_szFireWorks2[ ] = "sprites/fireworks_sprite1.spr";
new FwFireGib, FwExplosionFire, FwTrail, FwExplode;
new g_iCvarChangeMode;
//constantele pentru stock
const m_fBombStatus = 96;
const m_usEvent = 114;
const fBombPlanted = 1 << 8;
const fExploEvent = 1 << 0;
const fSmokeEvent = 1 << 1;
public plugin_init( ) {
register_plugin( PLUGIN, VERSION, AUTHOR );
register_forward( FM_SetModel, "fw_SetWmodel", 1 );
RegisterHam( Ham_Think, "grenade", "ham_grenade_think", 0 );
g_iCvarChangeMode = register_cvar( "he_change_mode", "1" );
}
public plugin_precache( ) {
FwFireGib = precache_model( g_szFireGib );
FwExplosionFire = precache_model( g_szExplosionFire );
FwTrail = precache_model( g_szFireWorks );
FwExplode = precache_model( g_szFireWorks2 );
}
public fw_SetWmodel( ent, model[ ] ) {
if( !fm_is_ent_grenade( ent ) )
return FMRES_IGNORED;
set_pev( ent, pev_bInDuck, 1 );
return FMRES_IGNORED;
}
bool: fm_is_ent_grenade( entity ) {
new classname[ 9 ];
pev( entity, pev_classname, classname, 8 );
if( !equal( classname, "grenade" ) )
return false;
new bits = get_pdata_int( entity, 114 );
if( bits & ( 1<<0 ) )
return true;
return false;
}
public ham_grenade_think( ent ) {
if( !pev( ent, pev_bInDuck ) )
return FMRES_IGNORED;
new Float:dmgtime;
pev( ent, pev_dmgtime, dmgtime );
if( dmgtime > get_gametime( ) )
return FMRES_IGNORED;
HEGrenadeFwEffects( ent );
return FMRES_OVERRIDE;
}
public HEGrenadeFwEffects( entity ) {
if( grenade_type( entity ) == CSW_HEGRENADE ) //daca entitatea este grenada HE, atunci arata efectele
{
switch( get_pcvar_num( g_iCvarChangeMode ) ) {
case 0: {
new Float:fOrigin[ 3 ];
pev( entity, pev_origin, fOrigin );
// Medium ring
engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0 );
write_byte( TE_BEAMCYLINDER );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 470.0 ); // z axis + radius
write_short( FwExplosionFire );
write_byte( 0 ); // startframe
write_byte( 0 ); // framerate
write_byte( 4 ); // life
write_byte( 60 ); // width
write_byte( 0 ); // noise
write_byte( 255 ); // red
write_byte( 127 ); // green
write_byte( 80 ); // blue
write_byte( 200 ); // brightness
write_byte( 0 ); // speed
message_end( );
// Largest ring
engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0 );
write_byte( TE_BEAMCYLINDER );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 555.0 ); // z axis
write_short( FwExplosionFire );
write_byte( 0 ); // startframe
write_byte( 0 ); // framerate
write_byte( 4 ); // life
write_byte( 60 ); // width
write_byte( 0 ); // noise
write_byte( 255 ); // red
write_byte( 127 ); // green
write_byte( 80 ); // blue
write_byte( 200 ); // brightness
write_byte( 0 ); // speed
message_end( );
// Luz Dinamica
engfunc( EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, fOrigin, 0 )
write_byte( TE_DLIGHT ) // TE id
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] ) // x
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] ) // y
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] ) // z
write_byte( 50 ); // radio
write_byte( 255 ); // red
write_byte( 127 ); // green
write_byte( 80 ); // blue
write_byte( 30 ); // vida en 0.1, 30 = 3 segundos
write_byte( 30 ); // velocidad de decaimiento
message_end( );
engfunc( EngFunc_MessageBegin, MSG_BROADCAST, SVC_TEMPENTITY, fOrigin, 0);
write_byte( TE_EXPLOSION );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] ); // x axis
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] ); // y axis
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 75 ); // z axis
write_short( FwExplosionFire );
write_byte( 17 );
write_byte( 15 );
write_byte( TE_EXPLFLAG_NOSOUND );
message_end( );
engfunc( EngFunc_MessageBegin, MSG_BROADCAST,SVC_TEMPENTITY, fOrigin, 0 );
write_byte( TE_SPRITETRAIL ); // TE ID
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] ); // x axis
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] ); // y axis
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 40 ); // z axis
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] ); // x axis
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] ); // y axis
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] ); // z axis
write_short( FwFireGib ); // Sprite Index
write_byte( 30 ); // Count
write_byte( 10 ); // Life
write_byte( 2 ); // Scale
write_byte( 50 ); // Velocity Along Vector
write_byte( 10 ); // Rendomness of Velocity
message_end( );
}
case 1: {
new Float:fOrigin[ 3 ];
pev( entity, pev_origin, fOrigin );
engfunc( EngFunc_MessageBegin, MSG_PAS, SVC_TEMPENTITY, fOrigin, 0 );
write_byte( TE_WORLDDECAL );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] );
write_byte( engfunc( EngFunc_DecalIndex,"{scorch3" ) );
message_end( );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_EXPLOSION );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 60.0 );
write_short( FwTrail );
write_byte( 10 );
write_byte( 15 );
write_byte( 0 );
message_end( );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_SPRITE );
engfunc( EngFunc_WriteCoord, fOrigin[ 0 ] + random_float( -5.0, 5.0 ) );
engfunc( EngFunc_WriteCoord, fOrigin[ 1 ] + random_float( -5.0, 5.0 ) );
engfunc( EngFunc_WriteCoord, fOrigin[ 2 ] + 200.0 );
write_short( FwExplode );
write_byte( 15 );
write_byte( 200 );
message_end( );
}
}
}
}
//stocul de verificare a grenazilor
stock grenade_type( const index, const checkClassName = 0 ) {
static classname[ 9 ];
if( checkClassName ) {
pev( index, pev_classname, classname, 8 )
if ( !equal( classname, "grenade") ) {
return 0;
}
}
if( get_pdata_int( index, m_fBombStatus ) & fBombPlanted ) {
return 0;
}
static bits; bits = get_pdata_int( index, m_usEvent );
if( bits & fExploEvent ) {
return CSW_HEGRENADE;
}
else if( !bits ) {
return CSW_FLASHBANG;
}
else if( bits & fSmokeEvent ) {
return CSW_SMOKEGRENADE;
}
return 0;
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/