23/12/2019, 01:47 AM
primero que nada buen plugin bonito efecto
cuando le tiro la granada al que es de mi mismo equipo lo congela como hago para que no pase ?
cuando le tiro la granada al que es de mi mismo equipo lo congela como hago para que no pase ?
Código PHP:
#include <amxmodx>
#include <fakemeta>
#include <engine>
#include <hamsandwich>
/* =================================================================================
* [ Global ]
* ================================================================================= */
#define PLAYER_ARRAY 33
#define IsPlayer(%0) ( 1 <= %0 <= 32 )
#define GetPlayerBit(%0,%1) ( IsPlayer(%1) && ( %0 & ( 1 << ( %1 & 31 ) ) ) )
#define SetPlayerBit(%0,%1) ( IsPlayer(%1) && ( %0 |= ( 1 << ( %1 & 31 ) ) ) )
#define ClearPlayerBit(%0,%1) ( IsPlayer(%1) && ( %0 &= ~( 1 << ( %1 & 31 ) ) ) )
#define HasRoundStarted() ( g_flLastRoundEnd + 5.0 < get_gametime( ) )
#define IsEnemy(%0,%1) ( get_user_team( %0 ) != get_user_team( %1 ) )
#define IsPlayerCrouching(%0) ( entity_get_int( %0, EV_INT_flags ) & FL_DUCKING )
const FROSTNADE_ID = 8878;
const TASK_REMOVE_FREEZE = 4096;
new const g_szUnfreezeSound[ ] = "frostnade/impalelaunch1.wav";
new const g_szFreezeSound[ ] = "frostnade/impalehit.wav";
new const g_szFrostNovaSound[ ] = "frostnade/frostnova.wav";
new const g_szNovaModel[ ] = "models/frostnade/nova.mdl";
new const g_szInfoTarget[ ] = "info_target";
new const g_szNovaClassname[ ] = "Nova";
new g_iIsConnected;
new g_iIsAlive;
new g_iIsFrozen;
new g_iBlueflare;
new g_iBeam;
new g_iScreenFade;
new g_iMaxPlayers;
new Float:g_flPlayerVelocity[ PLAYER_ARRAY ][ 3 ];
new Float:g_flLastRoundEnd;
/* =================================================================================
* [ Plugin forwards ]
* ================================================================================= */
public plugin_precache( )
{
precache_sound( g_szUnfreezeSound );
precache_sound( g_szFreezeSound );
precache_sound( g_szFrostNovaSound );
precache_model( g_szNovaModel );
g_iBeam = precache_model( "sprites/frostnade/beam.spr" );
g_iBlueflare = precache_model( "sprites/frostnade/blueflare.spr" );
}
public plugin_init( )
{
register_plugin( "FrostNade", "1.0", "Manu" );
register_forward( FM_SetModel, "OnSetModel_Pre", false );
RegisterHam( Ham_Think, "grenade", "OnGrenadeThink_Pre", false );
RegisterHam( Ham_Killed, "player", "OnPlayerKilled_Pre", false );
RegisterHam( Ham_Spawn, "player", "OnPlayerSpawn_Post", true );
register_logevent( "OnRoundEnd", 2, "1=Round_End" );
g_iMaxPlayers = get_maxplayers( );
g_iScreenFade = get_user_msgid( "ScreenFade" );
}
/* =================================================================================
* [ Events ]
* ================================================================================= */
public OnRoundEnd( )
{
for ( new iPlayer = 1 ; iPlayer <= g_iMaxPlayers ; iPlayer++ )
{
if ( !GetPlayerBit( g_iIsFrozen, iPlayer ) )
{
continue;
}
UnfreezePlayer( iPlayer );
}
g_flLastRoundEnd = get_gametime( );
RemoveEntityByClassname( g_szNovaClassname );
}
/* =================================================================================
* [ Grenade section ]
* ================================================================================= */
public OnSetModel_Pre( iEnt, szModel[ ] )
{
if ( !HasRoundStarted( ) || ( strlen( szModel ) < 9 ) )
{
return FMRES_IGNORED;
}
if ( ( szModel[ 7 ] != 'w' ) || ( szModel[ 8 ] != '_' ) || ( szModel[ 9 ] != 's' ) )
{
return FMRES_IGNORED;
}
if ( entity_get_float( iEnt, EV_FL_dmgtime ) == 0.0 )
{
return FMRES_IGNORED;
}
entity_set_int( iEnt, EV_INT_flTimeStepSound, FROSTNADE_ID );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMFOLLOW );
write_short( iEnt );
write_short( g_iBeam );
write_byte( 25 );
write_byte( 3 );
write_byte( 0 );
write_byte( 50 );
write_byte( 250 );
write_byte( 200 );
message_end( );
set_rendering( iEnt, kRenderFxGlowShell, 0, 50, 250, kRenderNormal, 16 );
return FMRES_IGNORED;
}
public OnGrenadeThink_Pre( iEnt )
{
if ( !HasRoundStarted( ) )
{
return HAM_IGNORED;
}
if ( entity_get_float( iEnt, EV_FL_dmgtime ) > get_gametime( ) )
{
return HAM_IGNORED;
}
if ( entity_get_int( iEnt, EV_INT_flTimeStepSound ) != FROSTNADE_ID )
{
return HAM_IGNORED;
}
FrostExplode( iEnt );
return HAM_SUPERCEDE;
}
/* =================================================================================
* [ Player events ]
* ================================================================================= */
public OnPlayerSpawn_Post( iId )
{
if ( !is_user_alive( iId ) )
{
return HAM_IGNORED;
}
SetPlayerBit( g_iIsAlive, iId );
return HAM_IGNORED;
}
public OnPlayerKilled_Pre( iVictim, iAttacker, iShouldgib )
{
ClearPlayerBit( g_iIsAlive, iVictim );
if ( !GetPlayerBit( g_iIsFrozen, iVictim ) )
{
return HAM_IGNORED;
}
UnfreezePlayer( iVictim );
RemoveEntityByOwner( iVictim, g_szNovaClassname );
remove_task( iVictim + TASK_REMOVE_FREEZE );
return HAM_IGNORED;
}
public OnTaskRemoveFreeze( iTask )
{
new iId = ( iTask - TASK_REMOVE_FREEZE );
if ( GetPlayerBit( g_iIsFrozen, iId ) )
{
UnfreezePlayer( iId );
}
}
/* =================================================================================
* [ Client connection ]
* ================================================================================= */
public client_putinserver( iId )
{
SetPlayerBit( g_iIsConnected, iId );
}
public client_disconnect( iId )
{
if ( task_exists( iId + TASK_REMOVE_FREEZE ) )
{
remove_task( iId + TASK_REMOVE_FREEZE );
}
ClearPlayerBit( g_iIsConnected, iId );
ClearPlayerBit( g_iIsAlive, iId );
ClearPlayerBit( g_iIsFrozen, iId );
}
/* =================================================================================
* [ Frostnade modules ]
* ================================================================================= */
FrostExplode( const iEnt )
{
new iOwner = entity_get_edict( iEnt, EV_ENT_owner );
if ( !GetPlayerBit( g_iIsConnected, iOwner ) )
{
return;
}
new Float:flOrigin[ 3 ];
entity_get_vector( iEnt, EV_VEC_origin, flOrigin );
CreateFrostEffect( flOrigin );
emit_sound( iEnt, CHAN_BODY, g_szFrostNovaSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
new iVictim;
while ( ( iVictim = find_ent_in_sphere( iVictim, flOrigin, 250.0 ) ) > 0 )
{
if ( iVictim == iOwner )
{
continue;
}
if ( !GetPlayerBit( g_iIsAlive, iVictim ) || GetPlayerBit( g_iIsFrozen, iVictim ) )
{
continue;
}
FreezePlayer( iVictim );
set_task( 4.0, "OnTaskRemoveFreeze", iVictim + TASK_REMOVE_FREEZE );
}
remove_entity( iEnt );
}
FreezePlayer( const iId )
{
SetPlayerBit( g_iIsFrozen, iId );
entity_get_vector( iId, EV_VEC_velocity, g_flPlayerVelocity[ iId ] );
entity_set_vector( iId, EV_VEC_velocity, Float:{ 0.0, 0.0, 0.0 } );
entity_set_int( iId, EV_INT_flags, entity_get_int( iId, EV_INT_flags ) | FL_FROZEN );
emit_sound( iId, CHAN_BODY, g_szFreezeSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
set_rendering( iId, kRenderFxGlowShell, 0, 60, 240, kRenderNormal, 80 );
SendScreenFade( iId, { 1, 60, 240 }, 4, 1, 0x0000, 40 );
CreateNova( iId );
}
UnfreezePlayer( const iId )
{
ClearPlayerBit( g_iIsFrozen, iId );
entity_set_int( iId, EV_INT_flags, entity_get_int( iId, EV_INT_flags ) & ~FL_FROZEN );
entity_set_vector( iId, EV_VEC_velocity, g_flPlayerVelocity[ iId ] );
emit_sound( iId, CHAN_BODY, g_szUnfreezeSound, VOL_NORM, ATTN_NORM, 0, PITCH_NORM );
set_rendering( iId );
}
CreateFrostEffect( const Float:flOrigin[ 3 ] )
{
new iOrigin[ 3 ];
FVecIVec( flOrigin, iOrigin );
for ( new i = 1 ; i < 4 ; i++ )
{
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_BEAMCYLINDER );
write_coord( iOrigin[ 0 ] );
write_coord( iOrigin[ 1 ] );
write_coord( iOrigin[ 2 ] );
write_coord( iOrigin[ 0 ] );
write_coord( iOrigin[ 1 ] );
write_coord( iOrigin[ 2 ] + ( i * 111 ) );
write_short( g_iBeam );
write_byte( 1 );
write_byte( 1 );
write_byte( 5 );
write_byte( 100 );
write_byte( 0 );
write_byte( 0 );
write_byte( 50 );
write_byte( 250 );
write_byte( 200 );
write_byte( 0 );
message_end( );
}
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_SPRITETRAIL );
write_coord( iOrigin[ 0 ] );
write_coord( iOrigin[ 1 ] );
write_coord( iOrigin[ 2 ] );
write_coord( iOrigin[ 0 ] );
write_coord( iOrigin[ 1 ] );
write_coord( iOrigin[ 2 ] );
write_short( g_iBlueflare );
write_byte( 100 );
write_byte( 1 );
write_byte( 2 );
write_byte( 50 );
write_byte( 50 );
message_end( );
message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
write_byte( TE_DLIGHT );
write_coord( iOrigin[ 0 ] );
write_coord( iOrigin[ 1 ] );
write_coord( iOrigin[ 2 ] );
write_byte( 48 );
write_byte( 0 );
write_byte( 50 );
write_byte( 255 );
write_byte( 10 );
write_byte( 50 );
message_end( );
}
CreateNova( const iId )
{
new iEnt = create_entity( g_szInfoTarget );
if ( !is_valid_ent( iEnt ) )
{
return 0;
}
new Float:flOrigin[ 3 ];
entity_set_string( iEnt, EV_SZ_classname, g_szNovaClassname );
entity_set_size( iEnt, Float:{ -4.0, -4.0, -4.0 }, Float:{ 4.0, 4.0, 4.0 } );
entity_set_model( iEnt, g_szNovaModel );
entity_set_int( iEnt, EV_INT_solid, SOLID_NOT );
entity_set_int( iEnt, EV_INT_movetype, MOVETYPE_FLY );
entity_get_vector( iId, EV_VEC_origin, flOrigin );
IsPlayerCrouching( iId ) ?
( flOrigin[ 2 ] -= 18.0 ) :
( flOrigin[ 2 ] -= 36.0 );
entity_set_vector( iEnt, EV_VEC_origin, flOrigin );
entity_set_edict( iEnt, EV_ENT_owner, iId );
entity_set_int( iEnt, EV_INT_flags, entity_get_int( iEnt, EV_INT_flags ) | FL_KILLME );
entity_set_float( iEnt, EV_FL_takedamage, DAMAGE_NO );
entity_set_float( iEnt, EV_FL_nextthink, get_gametime( ) + 4.0 );
return 1;
}
/* =================================================================================
* [ Common modules ]
* ================================================================================= */
RemoveEntityByClassname( const szClassname[ ] )
{
new iEnt = -1;
while ( ( iEnt = find_ent_by_class( iEnt, szClassname ) ) > 0 )
{
remove_entity( iEnt );
}
}
RemoveEntityByOwner( const iOwner, const szClassname[ ] )
{
new iEnt = -1;
while ( ( iEnt = find_ent_by_owner( iEnt, szClassname, iOwner ) ) > 0 )
{
remove_entity( iEnt );
}
}
SendScreenFade( const iPlayer, const iRGB[ 3 ], const iDuration, const iHoldTime, const iFlag, const iAlpha )
{
message_begin( MSG_ONE_UNRELIABLE, g_iScreenFade, _, iPlayer );
write_short( ( 1<<12 ) * iDuration );
write_short( ( 1<<12 ) * iHoldTime );
write_short( iFlag );
write_byte( iRGB[ 0 ] );
write_byte( iRGB[ 1 ] );
write_byte( iRGB[ 2 ] );
write_byte( iAlpha );
message_end( );
}