Advertisement
Guest User

Untitled

a guest
Jan 28th, 2018
272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. int g_HaloSprite;
  5. int g_LaserBeam;
  6.  
  7. public void OnPluginStart()
  8. {
  9.     RegConsoleCmd( "sm_hitboxtest", Command_HitboxTest );
  10.     RegConsoleCmd( "sm_bboxtest", Command_BBoxTest );
  11. }
  12.  
  13. public void OnMapStart()
  14. {
  15.     g_HaloSprite = PrecacheModel( "materials/sprites/glow01.vmt" );
  16.     g_BlueLightning = PrecacheModel( "materials/sprites/laserbeam.vmt" );
  17. }
  18.  
  19. public Action Command_HitboxTest( int client, int args )
  20. {
  21.     float startpos[3];
  22.     GetClientEyePosition( client, startpos );
  23.     float angles[3];
  24.     GetClientEyeAngles( client, angles );
  25.    
  26.     TR_EnumerateEntities( startpos, angles, false, RayType_Infinite, HitPlayerHBox, client );
  27. }
  28.  
  29. public Action Command_BBoxTest( int client, int args )
  30. {
  31.     float startpos[3];
  32.     GetClientEyePosition( client, startpos );
  33.     float angles[3];
  34.     GetClientEyeAngles( client, angles );
  35.    
  36.     TR_EnumerateEntities( startpos, angles, false, RayType_Infinite, HitPlayerBBox, client );
  37. }
  38.  
  39. public bool HitPlayerBBox( int entity, int client )
  40. {
  41.     if( 0 < entity <= MaxClients && entity != client )
  42.     {
  43.         TR_ClipRayToEntity( MASK_PLAYERSOLID, entity );
  44.        
  45.         float pos[3];
  46.         TR_GetEndPosition( pos );
  47.        
  48.         PrintToChatAll( "Hit %N (%i)! Collided at (%.2f, %.2f, %.2f) | Fraction: %.2f", entity, entity, pos[0], pos[1], pos[2], TR_GetFraction() );
  49.        
  50.         float startpos[3];
  51.         GetClientEyePosition( client, startpos );
  52.        
  53.         TE_SetupBeamPoints( startpos, pos, g_BlueLightning, g_HaloSprite, 0, 0, 20.0, 1.0, 1.0, 0, 0.0, { 0, 255, 0, 255 }, 0 );
  54.         TE_SendToAll( 0.0 );
  55.        
  56.         return false;
  57.     }
  58.    
  59.     return true;
  60. }
  61.  
  62. public bool HitPlayerHBox( int entity, int client )
  63. {
  64.     if( 0 < entity <= MaxClients && entity != client )
  65.     {
  66.         TR_ClipRayToEntity( MASK_ALL, entity );
  67.        
  68.         float pos[3];
  69.         TR_GetEndPosition( pos );
  70.        
  71.         PrintToChatAll( "Hit %N (%i)! Collided at (%.2f, %.2f, %.2f) | Fraction: %.2f", entity, entity, pos[0], pos[1], pos[2], TR_GetFraction() );
  72.        
  73.         float startpos[3];
  74.         GetClientEyePosition( client, startpos );
  75.        
  76.         TE_SetupBeamPoints( startpos, pos, g_BlueLightning, g_HaloSprite, 0, 0, 20.0, 1.0, 1.0, 0, 0.0, { 255, 0, 0, 255 }, 0 );
  77.         TE_SendToAll( 0.0 );
  78.        
  79.         return false;
  80.     }
  81.    
  82.     return true;
  83. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement