public void Update()
        {
            List<Tuple<int, CSPlayer>> players = new List<Tuple<int, CSPlayer>>();
            List<Tuple<int, BaseEntity>> entities = new List<Tuple<int, BaseEntity>>();
            List<Tuple<int, Weapon>> weapons = new List<Tuple<int, Weapon>>();

            dwLocalPlayer = WithOverlay.MemUtils.Read<int>((IntPtr)(clientDllBase + CSGOOffsets.Misc.LocalPlayer));
            dwIGameResources = WithOverlay.MemUtils.Read<int>((IntPtr)(clientDllBase + CSGOOffsets.GameResources.Base));

            State = (SignOnState)WithOverlay.MemUtils.Read<int>((IntPtr)(dwClientState + CSGOOffsets.ClientState.m_dwInGame));
            if (State != SignOnState.SIGNONSTATE_FULL)
                return;

            ViewMatrix = WithOverlay.MemUtils.ReadMatrix((IntPtr)dwViewMatrix, 4, 4);
            ViewAngles = WithOverlay.MemUtils.Read<Vector3>((IntPtr)(dwClientState + CSGOOffsets.ClientState.m_dwViewAngles));
            NewViewAngles = ViewAngles;
            RCSHandled = false;

            #region Read entities
            byte[] data = new byte[16 * 8192];
            WithOverlay.MemUtils.Read((IntPtr)(dwEntityList), out data, data.Length);

            for (int i = 0; i < data.Length / 16; i++)
            {
                int address = BitConverter.ToInt32(data, 16 * i);
                if (address != 0)
                {
                    BaseEntity ent = new BaseEntity(address);
                    if (!ent.IsValid())
                        continue;
                    if (ent.IsPlayer())
                        players.Add(new Tuple<int, CSPlayer>(i, new CSPlayer(ent)));
                    else if (ent.IsWeapon())
                        weapons.Add(new Tuple<int, Weapon>(i, new Weapon(ent)));
                    else
                        entities.Add(new Tuple<int, BaseEntity>(i, ent));
                }
            }

            Players = players.ToArray();
            Entities = entities.ToArray();
            Weapons = weapons.ToArray();
            #endregion

            #region LocalPlayer and Target
            if (players.Exists(x => x.Item2.Address == dwLocalPlayer))
            {
                LocalPlayer = new CSLocalPlayer(players.First(x => x.Item2.Address == dwLocalPlayer).Item2);
                LocalPlayerWeapon = LocalPlayer.GetActiveWeapon();
            }
            else
            {
                LocalPlayer = null;
                LocalPlayerWeapon = null;
            }

            if (LocalPlayer != null)
            {
                if (entities.Exists(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1))
                    Target = entities.First(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1).Item2;
                if (players.Exists(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1))
                    Target = players.First(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1).Item2;
                else
                    Target = null;
            }
            #endregion

            if (LocalPlayer == null)
                return;

            #region IGameResources
            if (dwIGameResources != 0)
            {
                Kills = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Kills), 65);
                Deaths = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Deaths), 65);
                Armor = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Armor), 65);
                Assists = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Assists), 65);
                Score = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Score), 65);

                byte[] clantagsData = new byte[16 * 65];
                WithOverlay.MemUtils.Read((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Clantag), out clantagsData, clantagsData.Length);
                string[] clantags = new string[65];
                for (int i = 0; i < 65; i++)
                    clantags[i] = Encoding.Unicode.GetString(clantagsData, i * 16, 16);
                Clantags = clantags;

                int[] namePtrs = WithOverlay.MemUtils.ReadArray<int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Names), 65);
                string[] names = new string[65];
                for (int i = 0; i < 65; i++)
                    try
                    {
                        names[i] = WithOverlay.MemUtils.ReadString((IntPtr)namePtrs[i], 32, Encoding.ASCII);
                    }
                    catch { }
                Names = names;
            }
            #endregion

            #region Aimbot
            if (WithOverlay.ConfigUtils.GetValue<bool>("aimEnabled"))
            {
                if (WithOverlay.ConfigUtils.GetValue<bool>("aimToggle"))
                {
                    if (WithOverlay.KeyUtils.KeyWentUp(WithOverlay.ConfigUtils.GetValue<WinAPI.VirtualKeyShort>("aimKey")))
                        AimbotActive = !AimbotActive;
                }
                else if (WithOverlay.ConfigUtils.GetValue<bool>("aimHold"))
                {
                    AimbotActive = WithOverlay.KeyUtils.KeyIsDown(WithOverlay.ConfigUtils.GetValue<WinAPI.VirtualKeyShort>("aimKey"));
                }
                if (AimbotActive)
                    DoAimbot();
            }
            #endregion

            #region RCS
            DoRCS();
            #endregion

            #region Set view angles
            if (NewViewAngles != ViewAngles)
                SetViewAngles(NewViewAngles);
            #endregion

            #region triggerbot
            if (WithOverlay.ConfigUtils.GetValue<bool>("triggerEnabled"))
            {
                if (WithOverlay.ConfigUtils.GetValue<bool>("triggerToggle"))
                {
                    if (WithOverlay.KeyUtils.KeyWentUp(WithOverlay.ConfigUtils.GetValue<WinAPI.VirtualKeyShort>("triggerKey")))
                        TriggerbotActive = !TriggerbotActive;
                }
                else if (WithOverlay.ConfigUtils.GetValue<bool>("triggerHold"))
                {
                    TriggerbotActive = WithOverlay.KeyUtils.KeyIsDown(WithOverlay.ConfigUtils.GetValue<WinAPI.VirtualKeyShort>("triggerKey"));
                }
                if (TriggerbotActive && !WithOverlay.KeyUtils.KeyIsDown(WinAPI.VirtualKeyShort.LBUTTON))
                    DoTriggerbot();
            }
            #endregion

            #region triggerbot-burst
            if (TriggerShooting)
            {
                if (LocalPlayerWeapon == null)
                {
                    TriggerShooting = false;
                }
                else
                {
                    if (WithOverlay.ConfigUtils.GetValue<bool>("triggerBurstEnabled"))
                    {
                        if (TriggerBurstFired >= TriggerBurstCount)
                        {
                            TriggerShooting = false;
                            TriggerBurstFired = 0;
                        }
                        else
                        {
                            if (LocalPlayerWeapon.m_iClip1 != LastClip)
                            {
                                TriggerBurstFired += Math.Abs(LocalPlayerWeapon.m_iClip1 - LastClip);
                            }
                            else
                            {
                                Shoot();
                            }
                        }
                    }
                    else
                    {
                        Shoot();
                        TriggerShooting = false;
                    }
                }
            }

            #endregion
            if (LocalPlayerWeapon != null)
                LastClip = LocalPlayerWeapon.m_iClip1;
            else
                LastClip = 0;
            LastShotsFired = LocalPlayer.m_iShotsFired;
            LastPunch = LocalPlayer.m_vecPunch;
        }
示例#2
0
        public void Update()
        {
            List <Tuple <int, CSPlayer> >   players  = new List <Tuple <int, CSPlayer> >();
            List <Tuple <int, BaseEntity> > entities = new List <Tuple <int, BaseEntity> >();
            List <Tuple <int, Weapon> >     weapons  = new List <Tuple <int, Weapon> >();

            dwLocalPlayer    = WithOverlay.MemUtils.Read <int>((IntPtr)(clientDllBase + CSGOOffsets.Misc.LocalPlayer));
            dwIGameResources = WithOverlay.MemUtils.Read <int>((IntPtr)(clientDllBase + CSGOOffsets.GameResources.Base));

            State = (SignOnState)WithOverlay.MemUtils.Read <int>((IntPtr)(dwClientState + CSGOOffsets.ClientState.m_dwInGame));
            if (State != SignOnState.SIGNONSTATE_FULL)
            {
                return;
            }

            ViewMatrix    = WithOverlay.MemUtils.ReadMatrix((IntPtr)dwViewMatrix, 4, 4);
            ViewAngles    = WithOverlay.MemUtils.Read <Vector3>((IntPtr)(dwClientState + CSGOOffsets.ClientState.m_dwViewAngles));
            NewViewAngles = ViewAngles;
            RCSHandled    = false;

            #region Read entities
            byte[] data = new byte[16 * 8192];
            WithOverlay.MemUtils.Read((IntPtr)(dwEntityList), out data, data.Length);

            for (int i = 0; i < data.Length / 16; i++)
            {
                int address = BitConverter.ToInt32(data, 16 * i);
                if (address != 0)
                {
                    BaseEntity ent = new BaseEntity(address);
                    if (!ent.IsValid())
                    {
                        continue;
                    }
                    if (ent.IsPlayer())
                    {
                        players.Add(new Tuple <int, CSPlayer>(i, new CSPlayer(ent)));
                    }
                    else if (ent.IsWeapon())
                    {
                        weapons.Add(new Tuple <int, Weapon>(i, new Weapon(ent)));
                    }
                    else
                    {
                        entities.Add(new Tuple <int, BaseEntity>(i, ent));
                    }
                }
            }

            Players  = players.ToArray();
            Entities = entities.ToArray();
            Weapons  = weapons.ToArray();
            #endregion

            #region LocalPlayer and Target
            if (players.Exists(x => x.Item2.Address == dwLocalPlayer))
            {
                LocalPlayer       = new CSLocalPlayer(players.First(x => x.Item2.Address == dwLocalPlayer).Item2);
                LocalPlayerWeapon = LocalPlayer.GetActiveWeapon();
            }
            else
            {
                LocalPlayer       = null;
                LocalPlayerWeapon = null;
            }

            if (LocalPlayer != null)
            {
                if (entities.Exists(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1))
                {
                    Target = entities.First(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1).Item2;
                }
                if (players.Exists(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1))
                {
                    Target = players.First(x => x.Item1 == LocalPlayer.m_iCrosshairIdx - 1).Item2;
                }
                else
                {
                    Target = null;
                }
            }
            #endregion

            if (LocalPlayer == null)
            {
                return;
            }

            #region IGameResources
            if (dwIGameResources != 0)
            {
                Kills   = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Kills), 65);
                Deaths  = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Deaths), 65);
                Armor   = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Armor), 65);
                Assists = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Assists), 65);
                Score   = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Score), 65);

                byte[] clantagsData = new byte[16 * 65];
                WithOverlay.MemUtils.Read((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Clantag), out clantagsData, clantagsData.Length);
                string[] clantags = new string[65];
                for (int i = 0; i < 65; i++)
                {
                    clantags[i] = Encoding.Unicode.GetString(clantagsData, i * 16, 16);
                }
                Clantags = clantags;

                int[]    namePtrs = WithOverlay.MemUtils.ReadArray <int>((IntPtr)(dwIGameResources + CSGOOffsets.GameResources.Names), 65);
                string[] names    = new string[65];
                for (int i = 0; i < 65; i++)
                {
                    try
                    {
                        names[i] = WithOverlay.MemUtils.ReadString((IntPtr)namePtrs[i], 32, Encoding.ASCII);
                    }
                    catch { }
                }
                Names = names;
            }
            #endregion

            #region Aimbot
            if (WithOverlay.ConfigUtils.GetValue <bool>("aimEnabled"))
            {
                if (WithOverlay.ConfigUtils.GetValue <bool>("aimToggle"))
                {
                    if (WithOverlay.KeyUtils.KeyWentUp(WithOverlay.ConfigUtils.GetValue <WinAPI.VirtualKeyShort>("aimKey")))
                    {
                        AimbotActive = !AimbotActive;
                    }
                }
                else if (WithOverlay.ConfigUtils.GetValue <bool>("aimHold"))
                {
                    AimbotActive = WithOverlay.KeyUtils.KeyIsDown(WithOverlay.ConfigUtils.GetValue <WinAPI.VirtualKeyShort>("aimKey"));
                }
                if (AimbotActive)
                {
                    DoAimbot();
                }
            }
            #endregion

            #region RCS
            DoRCS();
            #endregion

            #region Set view angles
            if (NewViewAngles != ViewAngles)
            {
                SetViewAngles(NewViewAngles);
            }
            #endregion

            #region triggerbot
            if (WithOverlay.ConfigUtils.GetValue <bool>("triggerEnabled"))
            {
                if (WithOverlay.ConfigUtils.GetValue <bool>("triggerToggle"))
                {
                    if (WithOverlay.KeyUtils.KeyWentUp(WithOverlay.ConfigUtils.GetValue <WinAPI.VirtualKeyShort>("triggerKey")))
                    {
                        TriggerbotActive = !TriggerbotActive;
                    }
                }
                else if (WithOverlay.ConfigUtils.GetValue <bool>("triggerHold"))
                {
                    TriggerbotActive = WithOverlay.KeyUtils.KeyIsDown(WithOverlay.ConfigUtils.GetValue <WinAPI.VirtualKeyShort>("triggerKey"));
                }
                if (TriggerbotActive && !WithOverlay.KeyUtils.KeyIsDown(WinAPI.VirtualKeyShort.LBUTTON))
                {
                    DoTriggerbot();
                }
            }
            #endregion

            #region triggerbot-burst
            if (TriggerShooting)
            {
                if (LocalPlayerWeapon == null)
                {
                    TriggerShooting = false;
                }
                else
                {
                    if (WithOverlay.ConfigUtils.GetValue <bool>("triggerBurstEnabled"))
                    {
                        if (TriggerBurstFired >= TriggerBurstCount)
                        {
                            TriggerShooting   = false;
                            TriggerBurstFired = 0;
                        }
                        else
                        {
                            if (LocalPlayerWeapon.m_iClip1 != LastClip)
                            {
                                TriggerBurstFired += Math.Abs(LocalPlayerWeapon.m_iClip1 - LastClip);
                            }
                            else
                            {
                                Shoot();
                            }
                        }
                    }
                    else
                    {
                        Shoot();
                        TriggerShooting = false;
                    }
                }
            }

            #endregion
            if (LocalPlayerWeapon != null)
            {
                LastClip = LocalPlayerWeapon.m_iClip1;
            }
            else
            {
                LastClip = 0;
            }
            LastShotsFired = LocalPlayer.m_iShotsFired;
            LastPunch      = LocalPlayer.m_vecPunch;
        }