FlacoBey

Untitled

Jan 6th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.74 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3.  
  4. #define TRACE_START     1.0
  5. #define TRACE_LENGTH    80.0
  6. #define LASER_COLOR_D   "38 251 42"
  7. #define LASER_WIDTH     0.6
  8.  
  9. #define MODEL_MINE      "models/w_models/weapons/w_eq_pipebomb.mdl"
  10. #define MODEL_BEAM      "materials/sprites/laserbeam.vmt"
  11.  
  12. public OnPluginStart()
  13. {
  14.     HookEvent("grenade_bounce", EventGrenadeB);
  15. }
  16.  
  17. public OnMapStart()
  18. {
  19.     PrecacheModel("materials/sprites/laserbeam.vmt");          
  20. }
  21.  
  22. public EventGrenadeB(Event event, const char[] name, bool dontBroadcast)
  23. {
  24.     new client = GetClientOfUserId(event.GetInt("userid"));
  25.     new grenade = GetGrenade(client);
  26.    
  27.     PlaceMine(client);
  28.     AcceptEntityInput(grenade, "Kill" );
  29. }
  30.  
  31.  
  32. GetGrenade(iClient)
  33. {
  34.     decl String:sClass[32] = {"pipe_bomb_projectile"};
  35.     for(new i = 0, iGrenade = -1; i < sizeof(sClass); i++)
  36.     {
  37.         while((iGrenade = FindEntityByClassname(iGrenade, sClass[i])) != -1)
  38.         {
  39.             if(GetEntPropEnt(iGrenade, Prop_Send, "m_hThrower") == iClient)
  40.             return iGrenade;
  41.         }
  42.     }
  43.     return 0;
  44. }
  45.  
  46. public PlaceMine(client)
  47. {
  48.     new grenade_main = GetGrenade(client);
  49.    
  50.     new Float:startent[3], Float:angle[3], Float:end[3];
  51.     GetClientEyeAngles(client, angle);
  52.     GetAngleVectors(angle, end, NULL_VECTOR, NULL_VECTOR);
  53.     NormalizeVector(end, end);
  54.  
  55.     GetEntPropVector(grenade_main, Prop_Send, "m_vecOrigin", startent);
  56.    
  57.     // offset start by near point
  58.     for( new i = 0; i < 3; i++ )
  59.         startent[i] += end[i] * TRACE_START;
  60.    
  61.     for( new i = 0; i < 3; i++ )
  62.         end[i] = startent[i] + end[i] * TRACE_LENGTH;
  63.    
  64.     TR_TraceRayFilter( startent, end, CONTENTS_SOLID|CONTENTS_WINDOW, RayType_EndPoint, TraceFilter_All, 0 );
  65.    
  66.     if( TR_DidHit( INVALID_HANDLE ) )
  67.     {
  68.         TR_GetEndPosition( end, INVALID_HANDLE );
  69.     }
  70.     new Float:position[3];
  71.     TR_TraceRayFilter(position, angle, CONTENTS_SOLID, RayType_Infinite, TraceFilter_All, 0);
  72.     CreateLaser(startent, end)
  73.    
  74. }
  75.  
  76. public CreateLaser(Float:start[3], Float:end[3])
  77. {
  78.     new ent = CreateEntityByName("env_beam");
  79.     if (ent != -1)
  80.     {
  81.         decl String:color[16];
  82.        
  83.         color = LASER_COLOR_D;
  84.  
  85.         TeleportEntity(ent, start, NULL_VECTOR, NULL_VECTOR);
  86.         SetEntityModel(ent, MODEL_BEAM);
  87.         SetEntPropVector(ent, Prop_Data, "m_vecEndPos", end);
  88.         DispatchKeyValue(ent, "rendercolor", color );
  89.         DispatchKeyValue(ent, "renderamt", "80");
  90.         DispatchKeyValue(ent, "decalname", "Bigshot");
  91.         DispatchKeyValue(ent, "life", "0");
  92.         DispatchKeyValue(ent, "TouchType", "0");
  93.         DispatchSpawn(ent);
  94.         SetEntPropFloat(ent, Prop_Data, "m_fWidth", LASER_WIDTH);
  95.         SetEntPropFloat(ent, Prop_Data, "m_fEndWidth", LASER_WIDTH);
  96.         ActivateEntity(ent);
  97.         AcceptEntityInput(ent, "TurnOn");
  98.     }
  99.  
  100.     return ent;
  101. }
  102.  
  103. public bool:TraceFilter_All( entity, contentsMask )
  104. {
  105.     return false;
  106. }
Advertisement
Add Comment
Please, Sign In to add comment