Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- bool EdgeAntiAim ( IClientEntity *localPlayer, CUserCmd* cmd, float flWall, float flCornor )
- {
- static CTraceFilterWorldAndPropsOnly filter;
- bool ret = false;
- Vector localPosition = localPlayer->vecGetOrigin ( ) + localPlayer->GetViewOffset ( );
- //////////////////////////
- static Vector viewforward, viewright, viewup, aimforward, aimright, aimup, qAimAngles, vForwardNorm, vRightNorm, vUpNorm;
- static float forward, right, up, fRand;
- forward = cmd->forwardmove;
- right = cmd->sidemove;
- up = cmd->upmove;
- qAimAngles.Init ( 0.0f, cmd->viewangles.Y, 0.0f );
- cMath.AngleVectors ( qAimAngles, &viewforward, &viewright, &viewup );
- //////////////////////////
- for ( int y = 0; y < 360; y++ )
- {
- Vector tmp ( 10.0f, cmd->viewangles.Y, 0.0f );
- tmp.Y += y;
- tmp.NormalizeAngles ( );
- Vector forward;
- cMath.AngleVectors ( tmp, &forward );
- float length = ((16.0f + 3.0f) + ((16.0f + 3.0f) * sin ( DEG2RAD ( 10.0f ) ))) + 7.0f;
- forward *= length;
- Ray_t ray;
- trace_t traceData;
- ray.Init ( localPosition, (localPosition + forward) );
- pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &traceData );
- if ( traceData.fraction != 1.0f )
- {
- Vector angles;
- Vector Negate = traceData.plane.normal;
- Negate *= -1;
- cMath.VectorAngles ( Negate, angles );
- tmp.Y = angles.Y;
- tmp.NormalizeAngles ( );
- trace_t leftTrace, rightTrace;
- Vector left, right;
- cMath.AngleVectors ( tmp + Vector ( 0.0f, 30.0f, 0.0f ), &left );
- cMath.AngleVectors ( tmp - Vector ( 0.0f, 30.0f, 0.0f ), &right );
- left *= (length + (length * sin ( DEG2RAD ( 30.0f ) )));
- right *= (length + (length * sin ( DEG2RAD ( 30.0f ) )));
- ray.Init ( localPosition, (localPosition + left) );
- pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &leftTrace );
- ray.Init ( localPosition, (localPosition + right) );
- pEngineTrace->TraceRay ( ray, 0x200400B, ( CTraceFilter* )&filter, &rightTrace );
- if ( (leftTrace.fraction == 1.0f)
- && (rightTrace.fraction != 1.0f) )
- {
- tmp.Y -= flCornor;
- // LEFT
- } else if ( (leftTrace.fraction != 1.0f) && (rightTrace.fraction == 1.0f) )
- {
- tmp.Y += flCornor;
- // RIGHT
- }
- cmd->viewangles.Y = tmp.Y;
- cmd->viewangles.Y -= flWall;
- ret = true;
- }
- }
- qAimAngles.Init ( 0.0f, cmd->viewangles.Y, 0.0f );
- cMath.AngleVectors ( qAimAngles, &aimforward, &aimright, &aimup );
- cMath.Normalize ( viewforward, vForwardNorm );
- cMath.Normalize ( viewright, vRightNorm );
- cMath.Normalize ( viewup, vUpNorm );
- cmd->forwardmove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimforward ) + cMath.DotProduct ( vRightNorm * right, aimforward ) + cMath.DotProduct ( vUpNorm * up, aimforward ));
- cmd->sidemove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimright ) + cMath.DotProduct ( vRightNorm * right, aimright ) + cMath.DotProduct ( vUpNorm * up, aimright ));
- cmd->upmove = ( float )(cMath.DotProduct ( vForwardNorm * forward, aimup ) + cMath.DotProduct ( vRightNorm * right, aimup ) + cMath.DotProduct ( vUpNorm * up, aimup ));
- return ret;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement