using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Diagnostics; using System.Drawing; using System.Drawing.Drawing2D; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace MW2_Ultimate_Hacks { public partial class Form1 : Form { ProcessManager ProcessManager; Bitmap Map; public Form1() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Graphics g; g = Graphics.FromImage(Map); Pen mypen = new Pen(Color.Black); g.DrawLine(mypen, 0, 0, 200, 150); pbMap.Image = Map; g.Dispose(); } private void Form1_Load(object sender, EventArgs e) { // Setup the map Map = new Bitmap(pbMap.Size.Width, pbMap.Size.Height); pbMap.Image = Map; // Connect to the game's process ProcessManager = new ProcessManager("iw4x"); // Start updating the local player's stats PlayerStatsTimer.Enabled = true; } /// /// Updates the local player's stats /// private void UpdatePlayerStats() { lblPlayerX.Text = ProcessManager.ReadFloatRelative((IntPtr)0x3F418C).ToString(); lblPlayerY.Text = ProcessManager.ReadFloatRelative((IntPtr)0x3F4188).ToString(); lblPlayerZ.Text = ProcessManager.ReadFloatRelative((IntPtr)0x3F4190).ToString(); lblPlayerIncline.Text = ProcessManager.ReadFloatRelative((IntPtr)0x3F41AC).ToString(); lblPlayerAzimuth.Text = ProcessManager.ReadFloatRelative((IntPtr)0x3F41B0).ToString(); // this could be moved else where lblNumberOfPlayers.Text = ProcessManager.ReadIntRelative((IntPtr)0x3F741C).ToString(); // Draw the map Graphics g; Bitmap old = new Bitmap(Map); g = Graphics.FromImage(Map); Pen player = new Pen(Color.Black); var x = ProcessManager.ReadFloatRelative((IntPtr)0x3F418C); var y = ProcessManager.ReadFloatRelative((IntPtr)0x3F4188); var azimuth = ProcessManager.ReadFloatRelative((IntPtr)0x3F41B0) + 180; // Scale to fit. x = x / 10; y = (y + 2000) / 10; var triangle = GenerateTriangle(x, y, azimuth); g.DrawPolygon(player, triangle); Map.RotateFlip(RotateFlipType.RotateNoneFlipXY); pbMap.Image = Map; Map = old; g.Dispose(); } private void PlayerStatsTimer_Tick(object sender, EventArgs e) { UpdatePlayerStats(); } private Point[] GenerateTriangle(float x, float y, float angle) { var width = 20; var height = 50; // Verticies of a triangle around origin. var triangle = new Point[] { new Point(-width/2, height/2), new Point(width/2, height/2), new Point(0, -height/2) }; var rotationMatrix = new Matrix(); rotationMatrix.Rotate(-angle); rotationMatrix.TransformPoints(triangle); var translationMatrix = new Matrix(); translationMatrix.Translate(x, y); translationMatrix.TransformPoints(triangle); return triangle; } } }