Advertisement
encoree1996

Untitled

May 13th, 2015
409
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.53 KB | None | 0 0
  1. bool EdgeAntiAim ( IClientEntity *localPlayer, CUserCmd* cmd, float flWall, float flCornor )
  2. {
  3. static CTraceFilterWorldAndPropsOnly filter;
  4.  
  5. bool ret = false;
  6.  
  7. Vector localPosition = localPlayer->vecGetOrigin ( ) + localPlayer->GetViewOffset ( );
  8.  
  9. //////////////////////////
  10. static Vector viewforward, viewright, viewup, aimforward, aimright, aimup, qAimAngles, vForwardNorm, vRightNorm, vUpNorm;
  11. static float forward, right, up, fRand;
  12.  
  13. forward = cmd->forwardmove;
  14. right = cmd->sidemove;
  15. up = cmd->upmove;
  16.  
  17. qAimAngles.Init ( 0.0f, cmd->viewangles.Y, 0.0f );
  18. cMath.AngleVectors ( qAimAngles, &viewforward, &viewright, &viewup );
  19. //////////////////////////
  20.  
  21. for ( int y = 0; y < 360; y++ )
  22. {
  23. Vector tmp ( 10.0f, cmd->viewangles.Y, 0.0f );
  24. tmp.Y += y;
  25. tmp.NormalizeAngles ( );
  26.  
  27. Vector forward;
  28. cMath.AngleVectors ( tmp, &forward );
  29.  
  30. float length = ((16.0f + 3.0f) + ((16.0f + 3.0f) * sin ( DEG2RAD ( 10.0f ) ))) + 7.0f;
  31. forward *= length;
  32.  
  33. Ray_t ray;
  34. trace_t traceData;
  35.  
  36. ray.Init ( localPosition, (localPosition + forward) );
  37. pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &traceData );
  38.  
  39. if ( traceData.fraction != 1.0f )
  40. {
  41. Vector angles;
  42. Vector Negate = traceData.plane.normal;
  43.  
  44. Negate *= -1;
  45. cMath.VectorAngles ( Negate, angles );
  46.  
  47. tmp.Y = angles.Y;
  48. tmp.NormalizeAngles ( );
  49. trace_t leftTrace, rightTrace;
  50.  
  51. Vector left, right;
  52. cMath.AngleVectors ( tmp + Vector ( 0.0f, 30.0f, 0.0f ), &left );
  53. cMath.AngleVectors ( tmp - Vector ( 0.0f, 30.0f, 0.0f ), &right );
  54.  
  55. left *= (length + (length * sin ( DEG2RAD ( 30.0f ) )));
  56. right *= (length + (length * sin ( DEG2RAD ( 30.0f ) )));
  57.  
  58. ray.Init ( localPosition, (localPosition + left) );
  59. pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &leftTrace );
  60.  
  61. ray.Init ( localPosition, (localPosition + right) );
  62. pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &rightTrace );
  63.  
  64. if ( (leftTrace.fraction == 1.0f)
  65. && (rightTrace.fraction != 1.0f) )
  66. {
  67. tmp.Y -= flCornor;
  68. // LEFT
  69. } else if ( (leftTrace.fraction != 1.0f) && (rightTrace.fraction == 1.0f) )
  70. {
  71. tmp.Y += flCornor;
  72. // RIGHT
  73. }
  74.  
  75. cmd->viewangles.Y = tmp.Y;
  76. cmd->viewangles.Y -= flWall;
  77. ret = true;
  78. }
  79. }
  80.  
  81. qAimAngles.Init ( 0.0f, cmd->viewangles.Y, 0.0f );
  82.  
  83. cMath.AngleVectors ( qAimAngles, &aimforward, &aimright, &aimup );
  84.  
  85. cMath.Normalize ( viewforward, vForwardNorm );
  86. cMath.Normalize ( viewright, vRightNorm );
  87. cMath.Normalize ( viewup, vUpNorm );
  88.  
  89. cmd->forwardmove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimforward ) + cMath.DotProduct ( vRightNorm * right, aimforward ) + cMath.DotProduct ( vUpNorm * up, aimforward ));
  90. cmd->sidemove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimright ) + cMath.DotProduct ( vRightNorm * right, aimright ) + cMath.DotProduct ( vUpNorm * up, aimright ));
  91. cmd->upmove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimup ) + cMath.DotProduct ( vRightNorm * right, aimup ) + cMath.DotProduct ( vUpNorm * up, aimup ));
  92.  
  93. return ret;
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement