❓ playerbase structures

Posts 1–4 of 4 · Page 1 of 1
❓ playerbase structures
ok this is a code i been working on not yet tested but this is more of a question this should and i hope will show player distance, name and health
what do you guys think im not sure if it's posted in the correct place im sure some one will correct me and get it moved heres the code bellow

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using ProcessMemoryReaderLib;
using System.Globalization;

namespace Aimbot_cSharp
{
    public partial class CustomAimbot : Form
    {
        Process[] MyProcess;
        ProcessModule mainModule;
        ProcessMemoryReader Mem = new ProcessMemoryReader();
        PlayerData MainPlayer = new PlayerData();

        #region -----Addresses-----
        int MainPlayerBase = 0x4DF73C;
        //PUTS US AT X AXIS of our struct
        int[] MainPlayerMultiLvl = new int[] {0X30};
        PlayerDataAddr MainPlayerOffsets = new PlayerDataAddr(0x10, 0x14, 0x4, 0xC, 0x8, 0xC4);


        #region -----EnemyAddresses-----
        List<PlayerData> EnemyAddresses = new List<PlayerData>();
        int[] enONEMultiLevel = new int[] { 0x4, 0x364, 0x8, 0x30 };///*was F4 instead of 30 BUT went back C4 so I can calculate everything e.g. xpos etc*/
        int[] enTWOMultiLevel = new int[] { 0x4, 0x360, 0x8, 0x30 };
        int[] enTHREEMultiLevel = new int[] { 0x8, 0x35C, 0x8, 0x30 };
        #endregion

        float PI = 3.14159265F; // ALTHOUGH WE CAN ALWAYS use Math.PI, I prefer to use our own as a float

        #endregion

        bool GameFound = false;
        //Used to ensure we stay focused on an enemy as long as we hold the HOT KEY, if we let go of it then when pressing again we find a new enemy
        bool FocusingOnEnemy = false;
        int FocusTarget = -1;

        public CustomAimbot()
        {
            InitializeComponent();
        }

        private void gameChoiceCB_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                for (int i = 0; i < MyProcess.Length; i++)
                {
                    if (gameChoiceCB.SelectedItem.ToString().Contains(MyProcess[i].ProcessName))
                    {
                        MyProcess[0] = Process.GetProcessById(int.Parse(gameChoiceCB.Text.Replace(MyProcess[i].ProcessName + "-", "")));
                        mainModule = MyProcess[0].MainModule;
                        Mem.ReadProcess = MyProcess[0];
                        Mem.OpenProcess();
                        GameFound = true;

                        //create our player with the corresponding memory addresses
                        MainPlayer.baseAddress = MainPlayerBase;
                        //GETS US TO THE BEGINNING OF OUR STRUCT
                        MainPlayer.multiLevel = MainPlayerMultiLvl;
                        MainPlayer.offsets = new PlayerDataAddr(MainPlayerOffsets.xMouse, MainPlayerOffsets.yMouse, MainPlayerOffsets.xPos, MainPlayerOffsets.zPos, MainPlayerOffsets.yPos, MainPlayerOffsets.health);
                        SetupEnemyVars();
                    }
                }
            }
            catch(Exception ex)
            {
                MessageBox.Show("Could not connect to process " + ex.Message, "Error");
            }
        }


        private void gameChoiceCB_MouseClick(object sender, MouseEventArgs e)
        {
            gameChoiceCB.Items.Clear();
            MyProcess = Process.GetProcesses();
            for (int i = 0; i < MyProcess.Length; i++)
            {
                gameChoiceCB.Items.Add(MyProcess[i].ProcessName + "-" + MyProcess[i].Id);
            }
        }

        private void CustomAimbot_Load(object sender, EventArgs e)
        {
            ProcessTMR.Enabled = true;
        }

        #region TESTING MOUSE X AND MOUSE Y(THIS CAN BE IGNORED)
        private void upBTN_Click(object sender, EventArgs e)
        {
            int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);
            Mem.WriteFloat(playerBase + MainPlayer.offsets.yMouse, Mem.ReadFloat(playerBase + MainPlayer.offsets.yMouse) + 10.0f);
        }

        private void rightBTN_Click(object sender, EventArgs e)
        {
            int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);
            Mem.WriteFloat(playerBase + MainPlayer.offsets.xMouse, Mem.ReadFloat(playerBase + MainPlayer.offsets.xMouse) + 10.0f);
        }

        private void leftBTN_Click(object sender, EventArgs e)
        {
            int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);
            Mem.WriteFloat(playerBase + MainPlayer.offsets.xMouse, Mem.ReadFloat(playerBase + MainPlayer.offsets.xMouse) - 10.0f);
        }

        private void downBTN_Click(object sender, EventArgs e)
        {
            int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);
            Mem.WriteFloat(playerBase + MainPlayer.offsets.yMouse, Mem.ReadFloat(playerBase + MainPlayer.offsets.yMouse) - 10.0f);
        }
        #endregion


        private void ProcessTMR_Tick(object sender, EventArgs e)
        {
            if (GameFound)
            {
                int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);
                mouseXValueLBL.Text = Mem.ReadFloat(playerBase + MainPlayer.offsets.xMouse).ToString();
                mouseYValueLBL.Text = Mem.ReadFloat(playerBase + MainPlayer.offsets.yMouse).ToString();
                //DISPLAY OUR XYZ MAIN PLAYER'S POS
                xPosValueLBL.Text = Mem.ReadFloat(playerBase + MainPlayer.offsets.xPos).ToString();
                yPosValueLBL.Text = Mem.ReadFloat(playerBase + MainPlayer.offsets.yPos).ToString();
                zPosValueLBL.Text = Mem.ReadFloat(playerBase + MainPlayer.offsets.zPos).ToString();
                
                //SHOW OUR ENEMY VARIABLES
                int EnemyHealthAddy = Mem.ReadMultiLevelPointer(EnemyAddresses[2].baseAddress, 4, EnemyAddresses[2].multiLevel);

                HealthMineLBL.Text = Mem.ReadInt(playerBase + MainPlayer.offsets.health).ToString();
                    
                EnHealthValueLBL.Text = Mem.ReadInt((EnemyHealthAddy) + MainPlayer.offsets.health).ToString();
                xPosEnValueLBL.Text = Mem.ReadFloat((EnemyHealthAddy) + MainPlayer.offsets.xPos).ToString();
                yPosEnValueLBL.Text = Mem.ReadFloat((EnemyHealthAddy) + MainPlayer.offsets.yPos).ToString();
                zPosEnValueLBL.Text = Mem.ReadFloat((EnemyHealthAddy) + MainPlayer.offsets.zPos).ToString();

                //RIGHT MOUSE
                int res = ProcessMemoryReaderApi.GetKeyState(02); 
                if ((res & 0x8000) != 0)
                {
                    //if enemy is holding AIMBOT btn or key we focus on that person until they are dead
                    FocusingOnEnemy = true;
                    AimBot();
                }
                else
                {
                    //otherwise we stop staring at them and change targets
                    FocusingOnEnemy = false;
                    FocusTarget = -1;
                }
            }


            try
            {
                if (MyProcess != null)
                {
                    if (MyProcess[0].HasExited)
                    {
                        GameFound = false;
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show("There was an error " + ex.Message);
            }
        }


        private void AimBot()
        {
            //Grab our player's information
            PlayerDataVec playerDataVec = GetPlayerVecData(MainPlayer);
            //this will store every enemy that we have information
            List<PlayerDataVec> enemiesDataVec = new List<PlayerDataVec>();

            for (int i = 0; i < EnemyAddresses.Count; i++)
            {
                //Using our pointer we grab all the enemies information e.g. health, coordinates etc and we compare
                //it in order to get our mouse on the enemy and shoot at them
                PlayerDataVec enemyDataVector = GetPlayerVecData(EnemyAddresses[i]);
                //add our enemy information to the list if hes alive otherwise ignore them
              //  if (enemyDataVector.health > 0)
                    enemiesDataVec.Add(enemyDataVector);
            }

            //only aim if we are ALIVE
            if (playerDataVec.health > 0)
            {
                int target = 0;
                if (FocusingOnEnemy && FocusTarget != -1)
                {
                    //If our previous target is still alive we focus on them otherwise go after someone else
                    if (enemiesDataVec[FocusTarget].health > 0)
                        target = FocusTarget;
                    else target = FindClosestEnemyIndex(enemiesDataVec.ToArray(), playerDataVec);
                }
                else//By default aim at the first guy that appears, with this we focus on whos closest to us
                    target = FindClosestEnemyIndex(enemiesDataVec.ToArray(), playerDataVec);

                //if there are more enemies we find the closest one to us then aim
                if (target != -1) //-1 means something went wrong
                {
                    FocusTarget = target;
                    //this condition is only here in case all enemies are dead to aim at NO one
                    //previously if all were dead it would aim at the last guy killed
                    if (enemiesDataVec[target].health > 0)
                        AimAtTarget(enemiesDataVec[target], playerDataVec);
                }
            }
        }


        //With this we see which enemy is closest to OUR player, we return their index that way we aim directly
        //at our closest enemy
        private int FindClosestEnemyIndex(PlayerDataVec[] enemiesDataVec, PlayerDataVec myPosition)
        {
            float[] distances = new float[enemiesDataVec.Length];
            //store all our distances between us and the enemies to see which is closest
            for (int i = 0; i < enemiesDataVec.Length; i++)
            {
                //only store their distance if they are ALIVE
                if (enemiesDataVec[i].health > 0)
                    distances[i] = Get3dDistance(enemiesDataVec[i], myPosition);
                    //This is kind of a cheat here and im not really proud of it :/ but it was done in a rush
                    //in theory it just sets these as very high floats and ensures that DEAD enemies dont get 
                    //aimed at
                else
                    distances[i] = float.MaxValue;
            }
            //Make a copy of our array so we dont lose track of which position our closest enemy is
            float[] newDistances = new float[distances.Length];
            Array.Copy(distances, newDistances, distances.Length);

            //sorts our array from LOWEST TO HIGHEST
            Array.Sort(newDistances);

            //See which enemy was closest and return that Index for us to aim at them
            for (int i = 0; i < distances.Length; i++)
            {
                if (distances[i] == newDistances[0]) //0 BEING THE CLOSEST
                {
                    return i;
                }
            }
            return -1;
        }

        //Use the well known 3d distance formula to see  how 2 players are from each other
        //i didnt make this myself its just FACT. Almost every 3D game uses this formula. 2D games use a simpler variation
        private float Get3dDistance(PlayerDataVec to, PlayerDataVec from)
        {
            return (float)
            (Math.Sqrt(
            ((to.xPos - from.xPos) * (to.xPos - from.xPos)) + 
            ((to.yPos - from.yPos) * (to.yPos - from.yPos)) + 
            ((to.zPos - from.zPos) * (to.zPos - from.zPos))
            ));
        }

        private void AimAtTarget(PlayerDataVec enemyDataVector, PlayerDataVec playerDataVector)
        {
            float pitchX = (float)Math.Atan2(enemyDataVector.zPos - playerDataVector.zPos,
                Get3dDistance(enemyDataVector, playerDataVector))
                * 180 / PI;

            float yawY = -(float)Math.Atan2(enemyDataVector.xPos - playerDataVector.xPos, enemyDataVector.yPos - playerDataVector.yPos)
                / PI * 180 + 180;

            int playerBase = Mem.ReadMultiLevelPointer(MainPlayer.baseAddress, 4, MainPlayer.multiLevel);

            //Set our  mouse values with our new YAW and PITCH
            Mem.WriteFloat(playerBase + MainPlayer.offsets.xMouse, yawY);
            Mem.WriteFloat(playerBase + MainPlayer.offsets.yMouse, pitchX);
        }

        //By using our PlayerData pointers and memory addresses we grab all information from the player including:
        //Xmouse(YAW), Ymouse(PITCH) coordinates, player's position on the game x,y and z as well as the player's health
        //with that we can ignore dead enemies and not aim when OUR player is dead
        private PlayerDataVec GetPlayerVecData(PlayerData updatePlayer)
        {
            PlayerDataVec playerRet = new PlayerDataVec();
            int playerBase = Mem.ReadMultiLevelPointer(updatePlayer.baseAddress, 4, updatePlayer.multiLevel);

            playerRet.xMouse = Mem.ReadFloat(playerBase + updatePlayer.offsets.xMouse);
            playerRet.yMouse = Mem.ReadFloat(playerBase + updatePlayer.offsets.yMouse);
            playerRet.xPos = Mem.ReadFloat(playerBase + updatePlayer.offsets.xPos);

            playerRet.yPos = Mem.ReadFloat(playerBase + updatePlayer.offsets.yPos);
            playerRet.zPos = Mem.ReadFloat(playerBase + updatePlayer.offsets.zPos);

            playerRet.health = Mem.ReadInt(playerBase + updatePlayer.offsets.health);
            return playerRet;
        }


        //DECLARE ALL our variables regarding enemies, we later use this information to go through enemies and aim at them
        private void SetupEnemyVars()
        {
            PlayerData En1 = new PlayerData();
            //SETUP ENEMY VARIABLES
            En1.baseAddress = MyProcess[0].MainModule.BaseAddress.ToInt32() + 0x000E4E08;
            En1.multiLevel = enONEMultiLevel;
            En1.offsets = MainPlayer.offsets;
            EnemyAddresses.Add(En1);

            PlayerData En2 = new PlayerData();
            En2.baseAddress = MyProcess[0].MainModule.BaseAddress.ToInt32() + 0x000E5F00;
            En2.multiLevel = enTWOMultiLevel;
            En2.offsets = MainPlayer.offsets;
            EnemyAddresses.Add(En2);

            PlayerData En3 = new PlayerData();
            En3.baseAddress = MyProcess[0].MainModule.BaseAddress.ToInt32() + 0x000E5F00;
            En3.multiLevel = enTHREEMultiLevel;
            En3.offsets = MainPlayer.offsets;
            EnemyAddresses.Add(En3);
        }

    }
}
NOTE: im not sure if i need to add more to get this to work but hopefully this can be use full and yes this is apart of my aim bot
also at leecher's and people who ask how to use this is not working at the moment and can not be compiled as you will need the rest of the code from other header's
it needs C# (Sharp) or C ++ training to compile that?
C sharp ignore those offsets aswell there just what i put on for show here still need to find ava offsets

i compiled it in vb so im sure it will be compiled in both not sure and my bad it's c++ you can use it if you want for something if you need i made a mistake and used c sharp -_-
This isn't too hard to convert into C++ if needed.

But its good work from the looks of it. Nice
Posts 1–4 of 4 · Page 1 of 1

Post a Reply

Similar Threads

Talk with us