Exemple #1
0
        public static void Run()
        {
            Random random = new Random();

            while (true)
            {
                Thread.Sleep(1);

                if (!Convert.ToBoolean((long)Import.GetAsyncKeyState(Keys.LButton)) ||
                    Convert.ToBoolean((long)Import.GetAsyncKeyState(Keys.XButton1)) ||
                    !Verification.IsWindowFocused(PreparationProcess.Handle) ||
                    OffsetStruct.LocalPlayer.BaseStruct.Health < 1 ||
                    !ConfigStruct.Aimbot.Enabled)
                {
                    continue;
                }

                LoadCurrentWeaponStruct();

                if (ConfigStruct.CurrentWeapon.FOV == 0)
                {
                    continue;
                }

                var maxPlayers      = OffsetStruct.ClientState.BaseStruct.MaxPlayers;
                var entities        = Memory.ReadMemory((int)OffsetStruct.Base.Client + Offsets.dwEntityList, maxPlayers * 0x10);
                var possibleTargets = new Dictionary <float, Vector3>();

                for (int i = 0; i < maxPlayers; i++)
                {
                    var currentEntity       = Calcs.GetInt(entities, i * 0x10);
                    var currentEntityStruct = Memory.ReadMemory <OffsetStruct.Enemy_t>(currentEntity);

                    if (currentEntityStruct.Team == OffsetStruct.LocalPlayer.BaseStruct.Team ||
                        currentEntityStruct.Health < 1 ||
                        currentEntityStruct.Dormant ||
                        !currentEntityStruct.Spotted)
                    {
                        continue;
                    }

                    var bonePosition = Calcs.GetBonePos(currentEntity, ConfigStruct.CurrentWeapon.Hitbox);

                    if (bonePosition == Vector3.Zero)
                    {
                        continue;
                    }

                    var destination = Calcs.CalcAngle(OffsetStruct.LocalPlayer.BaseStruct.Position, bonePosition, OffsetStruct.LocalPlayer.BaseStruct.AimPunch, OffsetStruct.LocalPlayer.BaseStruct.VecView, 0f, 0f);

                    if (destination == Vector3.Zero)
                    {
                        continue;
                    }

                    var distance = Calcs.GetDistance3D(destination, OffsetStruct.ClientState.BaseStruct.ViewAngles);

                    if (distance > ConfigStruct.CurrentWeapon.FOV)
                    {
                        continue;
                    }

                    possibleTargets.Add(distance, destination);
                }

                if (!possibleTargets.Any())
                {
                    continue;
                }

                if (ConfigStruct.CurrentWeapon.DisableSpraylockAt != 0 && OffsetStruct.LocalPlayer.BaseStruct.AimPunch.X < (ConfigStruct.CurrentWeapon.DisableSpraylockAt * (-1)))
                {
                    continue;
                }

                var aimAngle = possibleTargets.OrderByDescending(x => x.Key).LastOrDefault().Value;

                var qDelta = aimAngle - OffsetStruct.ClientState.BaseStruct.ViewAngles;
                qDelta += new Vector3(qDelta.Y / 2.5f, qDelta.X / 2.5f, qDelta.Z);

                aimAngle = OffsetStruct.ClientState.BaseStruct.ViewAngles + qDelta;
                aimAngle = Calcs.NormalizeAngle(aimAngle);
                aimAngle = Calcs.ClampAngle(aimAngle);

                if (ConfigStruct.CurrentWeapon.Smooth > 0f)
                {
                    var randomizedSmooth = (float)Randomize(random, (ConfigStruct.CurrentWeapon.Smooth - 0.5f), (ConfigStruct.CurrentWeapon.Smooth + 0.5f));
                    aimAngle = Calcs.SmoothAim(OffsetStruct.ClientState.BaseStruct.ViewAngles, aimAngle, randomizedSmooth);
                }

                Memory.WriteMemory <Vector3>(OffsetStruct.ClientState.Base + Offsets.dwClientState_ViewAngles, aimAngle);
            }
        }