HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /*
  2.   Fordította: BBk - Death of Legend
  3. */
  4.  
  5.  
  6. #include <amxmodx>
  7. #include <engine>
  8. #include <fakemeta>
  9.  
  10. #define VERSION "1.1"
  11.  
  12. new const g_szClassname[] = "colored_smokenade";
  13.  
  14. new g_szSmokeSprites[ 6 ];
  15. new g_Cvar_Enabled;
  16.  
  17. public plugin_init( ) {
  18. register_plugin( "Colored Smoke", VERSION, "xPaw" );
  19.  
  20. register_cvar( "colored_smoke", VERSION, FCVAR_SERVER | FCVAR_SPONLY );
  21. set_cvar_string( "colored_smoke", VERSION );
  22.  
  23. g_Cvar_Enabled = register_cvar( "sv_colored_smoke", "1" );
  24.  
  25. register_forward( FM_EmitSound, "FwdEmitSound" );
  26. register_touch( g_szClassname, "worldspawn", "FwdTouch_FakeSmoke" );
  27. register_think( g_szClassname, "FwdThink_FakeSmoke" );
  28. }
  29.  
  30. public plugin_precache( ) {
  31. g_szSmokeSprites[ 0 ] = precache_model( "sprites/gas_puff_01y.spr" );
  32. g_szSmokeSprites[ 1 ] = precache_model( "sprites/gas_puff_01r.spr" );
  33. g_szSmokeSprites[ 2 ] = precache_model( "sprites/gas_puff_01b.spr" );
  34. g_szSmokeSprites[ 3 ] = precache_model( "sprites/gas_puff_01g.spr" );
  35. g_szSmokeSprites[ 4 ] = precache_model( "sprites/gas_puff_01m.spr" );
  36. g_szSmokeSprites[ 5 ] = precache_model( "sprites/gas_puff_01o.spr" );
  37.  
  38. precache_sound( "weapons/grenade_hit1.wav" );
  39. }
  40.  
  41. public FwdEmitSound( iOrigEnt, iChannel, const szSample[], Float:fVol, Float:fAttn, iFlags, iPitch ) {
  42. new iCvar = get_pcvar_num( g_Cvar_Enabled );
  43. if( iCvar > 0 ) {
  44. static const szSmokeSound[] = "weapons/sg_explode.wav";
  45.  
  46. if( equal( szSample, szSmokeSound ) ) {
  47. // cache origin, angles and model
  48. new Float:vOrigin[ 3 ], Float:vAngles[ 3 ], szModel[ 64 ], iOwner;
  49. iOwner = entity_get_edict( iOrigEnt, EV_ENT_owner );
  50. entity_get_vector( iOrigEnt, EV_VEC_origin, vOrigin );
  51. entity_get_vector( iOrigEnt, EV_VEC_angles, vAngles );
  52. entity_get_string( iOrigEnt, EV_SZ_model, szModel, charsmax( szModel ) );
  53.  
  54. // remove entity from world
  55. entity_set_vector( iOrigEnt, EV_VEC_origin, Float:{ 9999.9, 9999.9, 9999.9 } );
  56. entity_set_int( iOrigEnt, EV_INT_flags, FL_KILLME );
  57.  
  58. // create new entity
  59. new iEntity = create_entity( "info_target" );
  60. if( iEntity > 0 ) {
  61. entity_set_string( iEntity, EV_SZ_classname, g_szClassname );
  62.  
  63. entity_set_origin( iEntity, vOrigin );
  64. entity_set_vector( iEntity, EV_VEC_angles, vAngles );
  65.  
  66. entity_set_int( iEntity, EV_INT_movetype, MOVETYPE_TOSS );
  67. entity_set_int( iEntity, EV_INT_solid, SOLID_BBOX );
  68.  
  69. entity_set_float( iEntity, EV_FL_nextthink, get_gametime( ) + 21.5 );
  70. entity_set_float( iEntity, EV_FL_gravity, 0.5 );
  71. entity_set_float( iEntity, EV_FL_friction, 0.8 );
  72.  
  73. entity_set_model( iEntity, szModel );
  74.  
  75. new Float:vVelocity[ 3 ];
  76. vVelocity[ 0 ] = random_float( -220.0, 220.0 );
  77. vVelocity[ 1 ] = random_float( -220.0, 220.0 );
  78. vVelocity[ 2 ] = random_float( 200.0, 300.0 );
  79. entity_set_vector( iEntity, EV_VEC_velocity, vVelocity );
  80.  
  81. emit_sound( iEntity, iChannel, szSample, fVol, fAttn, iFlags, iPitch );
  82.  
  83. // Create fake smoke
  84. new iSmoke;
  85.  
  86. if( iCvar == 2 )
  87. iSmoke = get_user_team( iOwner ); // csapatok indexelese, 1 - piros, 2 - kek, 3 - zold( spectator )
  88. else
  89. iSmoke = random_num( 0, 5 );
  90.  
  91. // Store the smoke number in entity, we will use it later
  92. entity_set_int( iEntity, EV_INT_iuser4, iSmoke );
  93.  
  94. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  95. write_byte( TE_FIREFIELD );
  96. engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  97. engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  98. engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
  99. write_short( 100 );
  100. write_short( g_szSmokeSprites[ iSmoke ] );
  101. write_byte( 100 );
  102. write_byte( TEFIRE_FLAG_ALPHA );
  103. write_byte( 1000 );
  104. message_end();
  105.  
  106. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  107. write_byte( TE_FIREFIELD );
  108. engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  109. engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  110. engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 50 );
  111. write_short( 150 );
  112. write_short( g_szSmokeSprites[ iSmoke ] );
  113. write_byte( 10 );
  114. write_byte( TEFIRE_FLAG_ALPHA | TEFIRE_FLAG_SOMEFLOAT );
  115. write_byte( 1000 );
  116. message_end( );
  117. }
  118. }
  119. }
  120. }
  121.  
  122. public FwdTouch_FakeSmoke( iEntity, iWorld ) {
  123. if( !is_valid_ent( iEntity ) )
  124. return PLUGIN_CONTINUE;
  125.  
  126. // Bounce sound
  127. emit_sound( iEntity, CHAN_VOICE, "weapons/grenade_hit1.wav", 0.25, ATTN_NORM, 0, PITCH_NORM );
  128.  
  129. new Float:vVelocity[ 3 ];
  130. entity_get_vector( iEntity, EV_VEC_velocity, vVelocity );
  131.  
  132. if( vVelocity[ 1 ] <= 0.0 && vVelocity[ 2 ] <= 0.0 ) {
  133. new Float:vOrigin[ 3 ];
  134. new iSmoke = entity_get_int( iEntity, EV_INT_iuser4 );
  135. entity_get_vector( iEntity, EV_VEC_origin, vOrigin );
  136.  
  137. // Make small smoke near grenade on ground
  138. message_begin( MSG_BROADCAST, SVC_TEMPENTITY );
  139. write_byte( TE_FIREFIELD );
  140. engfunc( EngFunc_WriteCoord, vOrigin[ 0 ] );
  141. engfunc( EngFunc_WriteCoord, vOrigin[ 1 ] );
  142. engfunc( EngFunc_WriteCoord, vOrigin[ 2 ] + 10 );
  143. write_short( 2 );
  144. write_short( g_szSmokeSprites[ iSmoke ] );
  145. write_byte( 2 );
  146. write_byte( TEFIRE_FLAG_ALLFLOAT | TEFIRE_FLAG_ALPHA );
  147. write_byte( 30 );
  148. message_end();
  149. }
  150.  
  151. return PLUGIN_CONTINUE;
  152. }
  153.  
  154. public FwdThink_FakeSmoke( iEntity ) {
  155. if( !is_valid_ent( iEntity ) )
  156. return PLUGIN_CONTINUE;
  157.  
  158. remove_entity( iEntity );
  159.  
  160. return PLUGIN_CONTINUE;
  161. }