Advertisement
useless28

Untitled

Apr 16th, 2019
447
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 4.47 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <engine>
  3. #include <fakemeta>
  4.  
  5. #define VERSION "1.1"
  6. #define SMOKE_SPRITE "sprites/gas_puff_0111.spr"
  7.  
  8. new const g_szClassname[] = "colored_smokenade";
  9.  
  10. new g_szSmokeSprites;
  11. new g_Cvar_Enabled;
  12.  
  13. public plugin_init( ) {
  14.     register_plugin( "Colored Smoke", VERSION, "xPaw" );
  15.    
  16.     register_cvar( "colored_smoke", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  17.     set_cvar_string( "colored_smoke", VERSION );
  18.    
  19.     g_Cvar_Enabled = register_cvar( "sv_colored_smoke", "1" );
  20.    
  21.     register_forward( FM_EmitSound, "FwdEmitSound" );
  22.     register_touch( g_szClassname, "worldspawn", "FwdTouch_FakeSmoke" );
  23.     register_think( g_szClassname, "FwdThink_FakeSmoke" );
  24. }
  25.  
  26. public plugin_precache( ) {
  27.     g_szSmokeSprites = precache_model( SMOKE_SPRITE );
  28.     precache_sound( "weapons/grenade_hit1.wav" );
  29.     force_unmodified(force_exactfile, {0,0,0},{0,0,0}, SMOKE_SPRITE)
  30. }
  31.  
  32. public FwdEmitSound( iOrigEnt, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch ) {
  33.     new iCvar = get_pcvar_num( g_Cvar_Enabled );
  34.     if( iCvar > 0 ) {
  35.         static const szSmokeSound[] = "weapons/sg_explode.wav";
  36.        
  37.         if( equal( szSample, szSmokeSound ) ) {
  38.             // cache origin, angles and model
  39.             new Float:vOrigin[ 3 ], Float:vAngles[ 3 ], szModel[ 64 ], iOwner;
  40.             iOwner = entity_get_edict( iOrigEnt, EV_ENT_owner );
  41.             entity_get_vector( iOrigEnt, EV_VEC_origin, vOrigin );
  42.             entity_get_vector( iOrigEnt, EV_VEC_angles, vAngles );
  43.             entity_get_string( iOrigEnt, EV_SZ_model, szModel, charsmax( szModel ) );
  44.            
  45.             // remove entity from world
  46.             entity_set_vector( iOrigEnt, EV_VEC_origin, Float:{ 9999.9, 9999.9, 9999.9 } );
  47.             entity_set_int( iOrigEnt, EV_INT_flags, FL_KILLME );
  48.            
  49.             // create new entity
  50.             new iEntity = create_entity( "info_target" );
  51.             if( iEntity > 0 ) {
  52.                 entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
  53.                
  54.                 entity_set_origin( iEntity, vOrigin );
  55.                 entity_set_vector( iEntity, EV_VEC_angles, vAngles );
  56.                
  57.                 entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_TOSS );
  58.                 entity_set_int( iEntity, EV_INT_solid, SOLID_BBOX );
  59.                
  60.                 entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 21.5 );
  61.                 entity_set_float( iEntity, EV_FL_gravity, 0.5 );
  62.                 entity_set_float( iEntity, EV_FL_friction, 0.8 );
  63.                
  64.                 entity_set_model( iEntity, szModel );
  65.                
  66.                 new Float:vVelocity[ 3 ];
  67.                 vVelocity[ 0 ] = random_float( -220.0, 220.0 );
  68.                 vVelocity[ 1 ] = random_float( -220.0, 220.0 );
  69.                 vVelocity[ 2 ] = random_float(  200.0, 300.0 );
  70.                 entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  71.                
  72.                 emit_sound( iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch );
  73.                
  74.                 // Create fake smoke
  75.                 new iSmoke;
  76.                 iSmoke = random_num( 0, 5 );
  77.                
  78.                 // Store the smoke number in entity, we will use it later
  79.                 entity_set_int( iEntity, EV_INT_iuser4, iSmoke );
  80.                
  81.                 message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  82.                 write_byte( TE_FIREFIELD );
  83.                 engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  84.                 engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  85.                 engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
  86.                 write_short( 75 );
  87.                 write_short( g_szSmokeSprites );
  88.                 write_byte( 50 );
  89.                 write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_PLANAR );
  90.                 write_byte( 1000 );
  91.                 message_end();
  92.             }
  93.         }
  94.     }
  95. }
  96.  
  97. public FwdTouch_FakeSmoke( iEntity, iWorld ) {
  98.     if( !is_valid_ent( iEntity ) )
  99.         return PLUGIN_CONTINUE;
  100.    
  101.     // Bounce sound
  102.     emit_sound( iEntity, CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM, 0, PITCH_NORM );
  103.    
  104.     new Float:vVelocity[ 3 ];
  105.     entity_get_vector( iEntity, EV_VEC_velocity, vVelocity );
  106.    
  107.     if( vVelocity[ 1 ] <= 0.0 && vVelocity[ 2 ] <= 0.0 ) {
  108.         new Float:vOrigin[ 3 ];
  109.         new iSmoke = entity_get_int( iEntity, EV_INT_iuser4 );
  110.         entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  111.        
  112.         // Make small smoke near grenade on ground
  113.         // message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  114.         // write_byte( TE_FIREFIELD );
  115.         // engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  116.         // engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  117.         // engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 10 );
  118.         // write_short( 2 );
  119.         // write_short( g_szSmokeSprites[ iSmoke ] );
  120.         // write_byte( 2 );
  121.         // write_byte( TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA );
  122.         // write_byte( 30 );
  123.         // message_end();
  124.     }
  125.    
  126.     return PLUGIN_CONTINUE;
  127. }
  128.  
  129. public FwdThink_FakeSmoke( iEntity ) {
  130.     if( !is_valid_ent( iEntity ) )
  131.         return PLUGIN_CONTINUE;
  132.    
  133.     remove_entity( iEntity );
  134.    
  135.     return PLUGIN_CONTINUE;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement