Beispiel #1
0
 public void DrawLineBresenham(int x0, int y0, int x1, int y1, double3 color, Func <double3, double3, double3> blendFunc = null)
 {
     if (Math3.ClampLine(ref x0, ref y0, ref x1, ref y1, Size.width, Size.height))
     {
         DrawLineBresenhamClamped(x0, y0, x1, y1, color, blendFunc);
     }
 }
        CycleDir GetPerspectiveTriangleOrder(double3 [] pts)
        {
            for (int i = 0; i < pts.Length; i++)
            {
                double z = pts [i].z <= 0 ? 1e-5 : pts [i].z;
                pts [i].xy /= z;
            }

            double signedArea = Math3.SignedArea2(pts [0].xy, pts [1].xy, pts [2].xy);

            return(signedArea >= 0 ? CycleDir.Ccw : CycleDir.Cw);
        }
Beispiel #3
0
        private bool CheckBoneDistance(Player plr, LocalPlayer local, Config.TriggerbotWeaponConfig cfg)
        {
            var localPos  = local.ViewPosition;
            var targetPos = plr.GetBonePosition(cfg.Bone);
            var angle     = Math3.CalcAngle(localPos, targetPos);
            var fov       = Math3.AngleBetweenVec2(CheatMain.clientState.ViewAngles, angle);
            var dist      = Vector3.Distance(localPos, targetPos);

            if (cfg.DynamicFov)
            {
                fov = Math3.GetDistanceFov((float)fov, (float)dist) * 1.4f;
            }

            if (fov <= cfg.Fov)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #4
0
        public void DrawTriangle(double2 [] pts, double3 color, Func <double3, double3, double3> blendFunc = null)
        {
            int             bottomIdx, midIdx, topIdx, separateIdx, coincidentIdx;
            Classify3Result res = Math3.Classify3(new [] { pts [0].y, pts [1].y, pts [2].y },
                                                  out topIdx, out midIdx, out bottomIdx, out separateIdx, out coincidentIdx);

            if (res == Classify3Result.AllCoincident)
            {
                int x = ( int )Math.Round(pts [0].x, MidpointRounding.AwayFromZero);
                int y = ( int )Math.Round(pts [0].y, MidpointRounding.AwayFromZero);
                Values [x, y] = blendFunc == null ? color : blendFunc(Values [x, y], color);

                return;
            }
            else if (res == Classify3Result.HasCoincidence)
            {
                double2 separatePoint   = pts [separateIdx];
                double2 midPoint        = pts [midIdx];
                double2 coincidentPoint = pts [coincidentIdx];

                DrawXAlignedTriangle(separatePoint, midPoint.x, coincidentPoint.x, midPoint.y, color, true, blendFunc);
            }
            else
            {
                double2 topPoint    = pts [topIdx];
                double2 midPoint    = pts [midIdx];
                double2 bottomPoint = pts [bottomIdx];
                double  dx          = topPoint.x - bottomPoint.x;
                double  dy          = topPoint.y - bottomPoint.y;
                double  ik          = dx / dy;
                double  x2          = ik * (midPoint.y - bottomPoint.y) + bottomPoint.x;

                DrawXAlignedTriangle(bottomPoint, midPoint.x, x2, midPoint.y, color, true, blendFunc);
                DrawXAlignedTriangle(topPoint, midPoint.x, x2, midPoint.y, color, false, blendFunc);
            }
        }
        public Player FindFovPlayer(LocalPlayer lPlayer, Player[] players, Vector2 view, out double fov, bool FFA = false, int bone = 8)
        {
            var    lPos       = lPlayer.ViewPosition;
            double bestFov    = float.MaxValue;
            Player bestTarget = null;

            foreach (var p in players)
            {
                if (!FFA && p.Team == lPlayer.Team)
                {
                    continue;
                }
                var pos    = p.GetBonePosition(bone);
                var target = Math3.CalcAngle(lPos, pos);
                var angle  = Math3.AngleBetweenVec2(view, target);
                if (angle < bestFov)
                {
                    bestFov    = angle;
                    bestTarget = p;
                }
            }
            fov = bestFov;
            return(bestTarget);
        }
Beispiel #6
0
        public static void DrawTexturedTriangle(this HdrBuffer image, double3 [] pts, double2 [] t,
                                                Sampler2d sampler, double tpp)
        {
            int             bottomIdx, midIdx, topIdx, separateIdx, coincidentIdx;
            Classify3Result res = Math3.Classify3(new [] { pts [0].y, pts [1].y, pts [2].y },
                                                  out topIdx, out midIdx, out bottomIdx, out separateIdx, out coincidentIdx);

            if (res == Classify3Result.AllCoincident)
            {
                int x = ( int )Math.Round(pts [0].x, MidpointRounding.AwayFromZero);
                int y = ( int )Math.Round(pts [0].y, MidpointRounding.AwayFromZero);
                image.Values [x, y] = sampler.GetColor(t [0]);

                return;
            }
            else if (res == Classify3Result.HasCoincidence)
            {
                double3 separatePoint   = pts [separateIdx];
                double3 midPoint        = pts [midIdx];
                double3 coincidentPoint = pts [coincidentIdx];
                double2 separateT       = t [separateIdx];
                double2 midT            = t [midIdx];
                double2 coincidentT     = t [coincidentIdx];

                image.DrawXAlignedTexturedTriangle(separatePoint, midPoint.x, coincidentPoint.x, midPoint.y,
                                                   midPoint.z, coincidentPoint.z,
                                                   separateT, midT, coincidentT,
                                                   sampler, tpp);
                //image.DrawXAlignedHollowTriangle ( separatePoint, midPoint.x, coincidentPoint.x, midPoint.y, double3.UnitY );
            }
            else
            {
                double3 topPoint    = pts [topIdx];
                double3 midPoint    = pts [midIdx];
                double3 bottomPoint = pts [bottomIdx];
                double  k           = (midPoint.y - bottomPoint.y) / (topPoint.y - bottomPoint.y);
                double  x2          = k.Lerp(bottomPoint.x, topPoint.x);

                double2 topT        = t [topIdx];
                double2 midT        = t [midIdx];
                double2 bottomT     = t [bottomIdx];
                double  zInv        = k.Lerp(1 / bottomPoint.z, 1 / topPoint.z);
                double  z2          = 1 / zInv;
                double2 coincidentT = k.ZLerp(bottomT, topT, bottomPoint.z, topPoint.z, zInv);

                image.DrawXAlignedTexturedTriangle(bottomPoint, midPoint.x, x2, midPoint.y,
                                                   midPoint.z, z2,
                                                   bottomT, midT, coincidentT,
                                                   sampler, tpp);
                image.DrawXAlignedTexturedTriangle(topPoint, midPoint.x, x2, midPoint.y,
                                                   midPoint.z, z2,
                                                   topT, midT, coincidentT,
                                                   sampler, tpp);

                //image.DrawXAlignedHollowTriangle ( bottomPoint, midPoint.x, x2, midPoint.y, double3.UnitX );
                //image.DrawXAlignedHollowTriangle ( topPoint, midPoint.x, x2, midPoint.y, double3.UnitX );

                //double3 white = new double3 ( 1, 1, 1 );
                //Func <double3, double3, double3> blendFunc = ( bg, fg ) => bg == white ? double3.UnitX : ( bg == double3.UnitY ? double3.UnitZ : double3.UnitY );

                //image.DrawYSteppingLine ( bottomPoint, new double2 ( midPoint.x, midPoint.y ), double3.UnitX, true, false, blendFunc );
                //image.DrawYSteppingLine ( bottomPoint, new double2 ( x2, midPoint.y ), double3.UnitX, false, false, blendFunc );
                //image.DrawYSteppingLine ( topPoint, new double2 ( midPoint.x, midPoint.y ), double3.UnitX, true, true, blendFunc );
                //image.DrawYSteppingLine ( topPoint, new double2 ( x2, midPoint.y ), double3.UnitX, false, true, blendFunc );
            }
        }
        public void RenderRays(double3 xAxis, double3 yAxis, double3 topLeft, double3 bottomLeft)
        {
            int     numRays = NumRaysToDraw.HasValue ? NumRaysToDraw.Value : ViewportSize.height;
            int     maxRays = Math.Max(numRays, ViewportSize.height);
            double3 startP, step;

            if (Orientation == SectionOrientation.Horizontal)
            {
                double    hFovX     = (AlwaysTakeVerticalFov ? Camera.FovY : Camera.FovX) / 2;
                double4x4 rotY      = double4x4.RotY(hFovX);
                double4x4 rotMinusY = double4x4.RotY(-hFovX);
                double3   left      = Camera.ViewInvMatrix.Transform(rotMinusY.Transform(double3.UnitZ));
                double3   right     = Camera.ViewInvMatrix.Transform(rotY.Transform(double3.UnitZ));
                step   = (right - left) * (1.0 / maxRays);
                startP = left + step * 0.5;
            }
            else
            {
                double    hFovY     = Camera.FovY / 2;
                double4x4 rotX      = double4x4.RotX(hFovY);
                double4x4 rotMinusX = double4x4.RotX(-hFovY);
                double3   top       = Camera.ViewInvMatrix.Transform(rotMinusX.Transform(double3.UnitZ));
                double3   bottom    = Camera.ViewInvMatrix.Transform(rotX.Transform(double3.UnitZ));
                step   = (bottom - top) * (1.0 / maxRays);
                startP = top + step * 0.5;
            }

            Scene.TraceCallback = tr => {
                double  sx  = ViewportSize.width / SectionSize.width;
                double  sy  = ViewportSize.height / SectionSize.height;
                double3 pV0 = tr.Ray.p - topLeft;
                double3 pV1 = tr.NearestIntersect.P - topLeft;
                int     x0  = ( int )Math.Round(sx * (pV0 & xAxis));
                int     y0  = ( int )Math.Round(sy * (pV0 & yAxis));
                int     x1  = ( int )Math.Round(sx * (pV1 & xAxis));
                int     y1  = ( int )Math.Round(sy * (pV1 & yAxis));

                if (Math3.ClampLine(ref x0, ref y0, ref x1, ref y1, ViewportSize.width, ViewportSize.height))
                {
                    image.DrawLineBresenhamClamped(x0, y0, x1, y1, tr.Color);
                    //image.Values [x0, y0] = 1 - tr.Color;
                    image.Values [x1, y1] = new double3(1, 1, 0);
                }
            };

            if (numRays == 1)
            {
                double3 p = startP + step * maxRays * 0.5;
                Ray     r = new Ray(Camera.Pos, p.Normalized);
                Scene.Trace(r, new TraceData(InitTraceData));
            }
            else
            {
                ParallelOptions parallelOpts = new ParallelOptions();
                parallelOpts.MaxDegreeOfParallelism = MaxDegreeOfParallelism.HasValue ? MaxDegreeOfParallelism.Value : Environment.ProcessorCount;
                double xInc = ( double )maxRays / (numRays - 1);

                Parallel.For(0, numRays, parallelOpts, x => {
                    double3 p = startP + step * x * xInc;
                    Ray r     = new Ray(Camera.Pos, p.Normalized);
                    Scene.Trace(r, new TraceData(InitTraceData));
                });
            }
        }
        private Player AimbotLerpCrossUpdate()
        {
            if (Config.AimbotBasic.Key != 0 && GetAsyncKeyState((Keys)Config.AimbotBasic.Key) >= 0)
            {
                return(null);
            }

            var localPlayer = CheatMain.client.GetLocalPlayer();

            if (localPlayer.Dead)
            {
                return(null);
            }

            var entityList = CheatMain.client.GetEntityList();
            var plrWeapon  = entityList.FindWeaponByID(localPlayer.ActiveWeaponID - 1);
            var cfgId      = Array.IndexOf(Config.TriggerbotWeaponConfig.TriggerbotWeapons, (int)plrWeapon.WeaponID);

            if (cfgId == -1)
            {
                return(null);
            }

            var cfg = Config.AimbotBasic.WeaponsCfg[cfgId];

            if (!cfg.Enabled)
            {
                return(null);
            }

            if (Enum.IsDefined(typeof(Snipers), (int)plrWeapon.WeaponID) &&
                !localPlayer.Scoped)
            {
                return(null);
            }

            var crosshairPlr = entityList.FindPlayerByID(localPlayer.CrosshairID - 1);

            if (crosshairPlr == null)
            {
                return(null);
            }

            if (crosshairPlr.ClassId != ClassIDs.CCSPlayer)
            {
                return(null);
            }

            if (!Config.AimbotBasic.FFA && crosshairPlr.Team == localPlayer.Team)
            {
                return(null);
            }

            if (enemyFoundTicks < Config.AimbotBasic.DelayBefore)
            {
                return(crosshairPlr);
            }

            var view   = CheatMain.clientState.ViewAngles;
            var target = crosshairPlr.GetBonePosition(8);
            var pos    = localPlayer.ViewPosition;
            var dist   = Vector3.Distance(pos, target);

            var targetView = Math3.CalcAngle(pos, target);
            //var targetFov = Math3.AngleBetweenVec2(view, targetView);
            var punch = localPlayer.PunchAngles;

            CheatMain.clientState.ViewAngles = Math3.Slerp(view, targetView - 2f * cfg.Rcs * punch, cfg.Smooth * .1f);

            return(crosshairPlr);
        }
        private Player RcsUpdate()
        {
            if (Config.AimbotBasic.Key != 0 && GetAsyncKeyState((Keys)Config.AimbotBasic.Key) >= 0)
            {
                return(null);
            }

            var localPlayer = CheatMain.client.GetLocalPlayer();

            if (localPlayer.Dead)
            {
                return(null);
            }

            var entityList = CheatMain.client.GetEntityList();
            var plrWeapon  = entityList.FindWeaponByID(localPlayer.ActiveWeaponID - 1);
            var cfgId      = Array.IndexOf(Config.TriggerbotWeaponConfig.TriggerbotWeapons, (int)plrWeapon.WeaponID);

            if (cfgId == -1)
            {
                return(null);
            }

            var cfg = Config.AimbotBasic.WeaponsCfg[cfgId];

            if (!cfg.Enabled)
            {
                return(null);
            }

            if (Enum.IsDefined(typeof(Snipers), (int)plrWeapon.WeaponID))
            {
                return(null);
            }

            var    view    = CheatMain.clientState.ViewAngles;
            var    players = entityList.FindVisiblePlayers(localPlayer);
            double fov;
            var    targetPlr = entityList.FindFovPlayer(localPlayer, players, view - 2f * lastPunchAngles, out fov, Config.AimbotBasic.FFA, cfg.Bone);

            if (targetPlr == null)
            {
                return(null);
            }

            if (enemyFoundTicks < Config.AimbotBasic.DelayBefore)
            {
                return(targetPlr);
            }
            var target = targetPlr.GetBonePosition(8);
            var pos    = localPlayer.ViewPosition;
            var dist   = Vector3.Distance(pos, target);

            var targetView = Math3.CalcAngle(pos, target);
            var punch      = localPlayer.PunchAngles;

            if (cfg.DynamicFov)
            {
                fov = Math3.GetDistanceFov((float)fov, (float)dist) * 1.4f;
            }

            if (fov <= cfg.Fov && punch != lastPunchAngles)
            {
                CheatMain.clientState.ViewAngles = view - 2f * punch + 2f * lastPunchAngles;
            }

            lastPunchAngles = punch;
            return(targetPlr);
        }