Guest User

Untitled

a guest
Sep 13th, 2017
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.10 KB | None | 0 0
  1. // gStart, gEnd here are grenade trajectory points
  2.  
  3. for (t = 0.0; t <= dtime; t += dt)
  4. {
  5.  
  6.     gEnd[0] = gStart[0] + GrenadeVelocity[0] * dt;
  7.     gEnd[1] = gStart[1] + GrenadeVelocity[1] * dt;
  8.    
  9.     new Float:gForce = 0.4 * float(gravity.IntValue);
  10.     new Float:NewVelocity = GrenadeVelocity[2] - gForce * dt;
  11.     new Float:AvgVelocity = (GrenadeVelocity[2] + NewVelocity) / 2.0;
  12.    
  13.     gEnd[2] = gStart[2] + AvgVelocity * dt;
  14.     GrenadeVelocity[2] = NewVelocity;
  15.    
  16.     new Float:mins[3] = {-2.0, -2.0, -2.0}, Float:maxs[3] = {2.0, 2.0, 2.0};
  17.  
  18.     new Handle:gRayTrace = TR_TraceHullEx(gStart, gEnd, mins, maxs, MASK_SHOT_HULL);
  19.    
  20.     if (TR_GetFraction(gRayTrace) != 1.0)
  21.     {
  22.         if (TR_GetEntityIndex(gRayTrace) == client && t == 0.0)
  23.         {
  24.             CloseHandle(gRayTrace);
  25.             gStart = gEnd;
  26.             continue;
  27.         }
  28.        
  29.         TR_GetEndPosition(gEnd, gRayTrace);
  30.        
  31.         new Float:NVector[3];
  32.         TR_GetPlaneNormal(gRayTrace, NVector);
  33.         new Float:Impulse = 2.0 * GetVectorDotProduct(NVector, GrenadeVelocity);
  34.         for (new i = 0; i < 3; i++)
  35.         {
  36.             GrenadeVelocity[i] -= Impulse * NVector[i];
  37.            
  38.             if (FloatAbs(GrenadeVelocity[i]) < 0.1)
  39.                 GrenadeVelocity[i] = 0.0;
  40.         }
  41.        
  42.         new Float:SurfaceElasticity = GetEntPropFloat(TR_GetEntityIndex(gRayTrace), Prop_Send, "m_flElasticity");
  43.         new Float:elasticity = 0.45 * SurfaceElasticity;
  44.  
  45.         ScaleVector(GrenadeVelocity, elasticity);
  46.        
  47.         new Float:ZVector[3] = { 0.0, 0.0, 1.0 };
  48.  
  49.         if(GetVectorDotProduct(NVector, ZVector) > 0.7) // old value from CS:Source
  50.        
  51.         {
  52.             if (StrEqual(cWeapon, "weapon_incgrenade", false) || StrEqual(cWeapon, "weapon_molotov", false))
  53.                 dtime = 0.0;
  54.         }
  55.     }
  56.     CloseHandle(gRayTrace);
  57.    
  58.     new Float:width = GetConVarFloat(sm_gtrajectory_size);
  59.     TE_SetupBeamPoints(gStart, gEnd, _Laser, 0, 0, 0, trajectory_show_time, width, width, 0, 0.0, trailcolor, 0);
  60.     TE_SendToAll(0.0);
  61.    
  62.     gStart = gEnd;
  63. }
Advertisement
Add Comment
Please, Sign In to add comment