HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. // Stock By: DarkGL | http://forums.alliedmods.net/showthread.php?t=176424
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5. #include <fakemeta>
  6. #include <xs>
  7.  
  8. #define PLUGIN "Granat Trail"
  9. #define AUTHOR "DarkGL"
  10. #define VERSION "1.0"
  11.  
  12. new laser;
  13.  
  14. public plugin_init()
  15. {
  16. register_plugin(PLUGIN, VERSION, AUTHOR)
  17. }
  18.  
  19. public plugin_precache(){
  20. laser = precache_model("sprites/laserbeam.spr")
  21. }
  22.  
  23. public client_PreThink( id ){
  24. if( is_user_alive( id ) ){
  25. new iWeapon = get_user_weapon( id );
  26.  
  27. if( iWeapon == CSW_HEGRENADE || iWeapon == CSW_SMOKEGRENADE || iWeapon == CSW_FLASHBANG){
  28. showGrenadeWay( id , iWeapon );
  29. }
  30. }
  31. }
  32.  
  33. stock showGrenadeWay ( id , weapon ){
  34. new Float:fGrenadeGrav = 1.0;
  35.  
  36. switch( weapon) {
  37. case CSW_HEGRENADE:
  38. fGrenadeGrav = 0.55;
  39. case CSW_FLASHBANG:
  40. fGrenadeGrav = 0.5;
  41. case CSW_SMOKEGRENADE:
  42. fGrenadeGrav = 0.5;
  43. }
  44. static pGrav;
  45.  
  46. if( !pGrav ) pGrav = get_cvar_pointer( "sv_gravity" );
  47.  
  48. new Float:fStartPos[ 3 ] , Float: fViewOfs[ 3 ] , Float: fVector[ 3 ] , Float: fVeloc [ 3 ] , Float: fAngles [ 3 ] , Float: fEndPos [ 3 ] , Float: fTmpVector [ 3 ] , pTr , Float: fFraction , Float: fNormal [ 3 ] , iCollision = 0 , Float: fVel;
  49. new Float:fGrav = get_pcvar_float( pGrav ) , pHit = 0;
  50.  
  51. const maxCollsion = 30;
  52. const Float: fConstAliveTime = 2.0;
  53. const Float: fConstLoops = 20.0;
  54. new Float: fAliveTime = 0.0;
  55. new Float: fStep = fConstAliveTime / fConstLoops;
  56.  
  57. pev( id , pev_origin , fStartPos );
  58. pev( id , pev_view_ofs , fViewOfs );
  59. pev( id , pev_velocity , fVeloc );
  60. pev( id , pev_v_angle , fAngles );
  61.  
  62. xs_vec_add( fStartPos , fViewOfs , fStartPos );
  63.  
  64. if (fAngles[0] < 0)
  65. fAngles[0] = -10.0 + fAngles[0] * ((90.0 - 10.0) / 90.0);
  66. else
  67. fAngles[0] = -10.0 + fAngles[0] * ((90.0 + 10.0) / 90.0);
  68.  
  69. fVel = (90.0 - fAngles[0]) * 6.0;
  70. if (fVel > 750.0)
  71. fVel = 750.0;
  72.  
  73. pev( id , pev_v_angle , fAngles );
  74.  
  75. angle_vector( fAngles , ANGLEVECTOR_FORWARD , fVector );
  76.  
  77. xs_vec_mul_scalar( fVector , 16.0 , fTmpVector );
  78.  
  79. xs_vec_add( fStartPos , fTmpVector , fStartPos );
  80.  
  81. xs_vec_mul_scalar( fVector , fVel , fVector );
  82.  
  83. xs_vec_add( fVector , fVeloc , fVector );
  84.  
  85.  
  86. for( ; fAliveTime < fConstAliveTime ; fAliveTime += fStep ){
  87.  
  88. xs_vec_copy( fStartPos , fEndPos);
  89. xs_vec_mul_scalar( fVector , fStep , fTmpVector );
  90. xs_vec_add( fEndPos , fTmpVector , fEndPos );
  91.  
  92. pTr = create_tr2();
  93.  
  94. engfunc(EngFunc_TraceLine, fStartPos, fEndPos, DONT_IGNORE_MONSTERS, id, pTr )
  95.  
  96. if( fAliveTime == 0.0 ){
  97. fStartPos [ 2 ] += 10.0;
  98. }
  99.  
  100. get_tr2( pTr , TR_flFraction , fFraction);
  101.  
  102. pHit = get_tr2( pTr , TR_pHit );
  103.  
  104. if( pHit != id && fFraction < 1.0 ){
  105. get_tr2( pTr , TR_vecEndPos , fEndPos );
  106.  
  107. get_tr2( pTr , TR_vecPlaneNormal , fNormal )
  108.  
  109. if( fNormal [ 2 ] > 0.9 && fVector [ 2 ] <= 0.0 && fVector [ 2 ] >= -fGrav / 0.20 ){
  110. return ;
  111. }
  112.  
  113. new Float: fScalar = xs_vec_dot( fVector, fNormal ) * 1.3;
  114.  
  115. fVector[0] = fVector[0] - fScalar * fNormal[0];
  116. fVector[1] = fVector[1] - fScalar * fNormal[1];
  117. fVector[2] = fVector[2] - fScalar * fNormal[2];
  118.  
  119. iCollision++;
  120.  
  121. if( iCollision > maxCollsion )
  122. break;
  123.  
  124. fAliveTime -= fStep * ( 1.0 - fFraction ) ;
  125. }
  126.  
  127. new iR , iG , iB;
  128.  
  129. switch( weapon ) {
  130. case CSW_HEGRENADE:{
  131. iR = 250;
  132. iG = 0;
  133. iB = 0;
  134. }
  135. case CSW_FLASHBANG:{
  136. iR = 0;
  137. iG = 0;
  138. iB = 250;
  139. }
  140. case CSW_SMOKEGRENADE:{
  141. iR = 0;
  142. iG = 250;
  143. iB = 0;
  144. }
  145. }
  146.  
  147. message_begin( MSG_ONE_UNRELIABLE , SVC_TEMPENTITY , { 0 , 0 , 0 } , id )
  148. write_byte(0)
  149. engfunc( EngFunc_WriteCoord , fStartPos [ 0 ] )
  150. engfunc( EngFunc_WriteCoord , fStartPos [ 1 ] )
  151. engfunc( EngFunc_WriteCoord , fStartPos [ 2 ] )
  152. engfunc( EngFunc_WriteCoord , fEndPos [ 0 ] )
  153. engfunc( EngFunc_WriteCoord , fEndPos [ 1 ] )
  154. engfunc( EngFunc_WriteCoord , fEndPos [ 2 ] )
  155. write_short(laser)
  156. write_byte(1)
  157. write_byte(1)
  158. write_byte(1)
  159. write_byte(15)
  160. write_byte(0)
  161. write_byte( iR )
  162. write_byte( iG )
  163. write_byte( iB )
  164. write_byte(210)
  165. write_byte(0)
  166. message_end()
  167.  
  168. xs_vec_copy( fEndPos , fStartPos );
  169.  
  170. fVector[ 2 ] -= floatmul( floatmul( fGrenadeGrav , fGrav ) , floatmul( fFraction , fStep ) );
  171.  
  172. free_tr2( pTr );
  173. }
  174. }