143 lines
4.4 KiB
C#
143 lines
4.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Diagnostics;
|
|
using System.Drawing;
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Updates the local player's stats
|
|
/// </summary>
|
|
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);
|
|
int x = (int)ProcessManager.ReadFloatRelative((IntPtr)0x3F418C);
|
|
x = x / 10;
|
|
int y = (int)ProcessManager.ReadFloatRelative((IntPtr)0x3F4188);
|
|
y += 2000;
|
|
y = y / 10;
|
|
//g.DrawEllipse(player, new Rectangle(x, y, 5, 5));
|
|
//g.FillEllipse(Brushes.Black, new Rectangle(x, y, 5, 5));
|
|
|
|
// calculate polygone points
|
|
int h = 20;
|
|
int triangleAngle = 30;
|
|
double azimuth = (int)ProcessManager.ReadFloatRelative((IntPtr)0x3F41B0) +180;
|
|
double angle = azimuth - (triangleAngle / 2);
|
|
angle = (angle / 360) * (2 * Math.PI);
|
|
|
|
int dx = (int)(Math.Cos(angle) * h);
|
|
int dy = (int)(Math.Sin(angle) * h);
|
|
|
|
int x1, x2, y1, y2;
|
|
|
|
if(angle < 90)
|
|
{
|
|
x1 = x + dx;
|
|
y1 = y - dy;
|
|
x2 = x - dy;
|
|
y2 = y - dx;
|
|
Debug.WriteLine("Case 1: (" + x + "," + y + ")(" + x1 +"," + y1 + ")(" + x2 + "," + y2 + ")");
|
|
}
|
|
else if(angle < 180)
|
|
{
|
|
x1 = x + dx;
|
|
y1 = y + dy;
|
|
x2 = x + dy;
|
|
y2 = y + dx;
|
|
Debug.WriteLine("Case 2: (" + x + "," + y + ")(" + x1 + "," + y1 + ")(" + x2 + "," + y2 + ")");
|
|
}
|
|
else if(angle < 270)
|
|
{
|
|
x1 = x - dx;
|
|
y1 = y + dy;
|
|
x2 = x - dy;
|
|
y2 = y + dx;
|
|
Debug.WriteLine("Case 3: (" + x + "," + y + ")(" + x1 + "," + y1 + ")(" + x2 + "," + y2 + ")");
|
|
|
|
}
|
|
else
|
|
{
|
|
x1 = x - dx;
|
|
y1 = y - dy;
|
|
x2 = x - dy;
|
|
y2 = y - dx;
|
|
Debug.WriteLine("Case 4: (" + x + "," + y + ")(" + x1 + "," + y1 + ")(" + x2 + "," + y2 + ")");
|
|
|
|
}
|
|
|
|
Point[] triangle =
|
|
{
|
|
new Point(x,y),
|
|
new Point(x1, y1),
|
|
new Point(x2,y2)
|
|
};
|
|
g.DrawPolygon(player, triangle);
|
|
|
|
pbMap.Image = Map;
|
|
Map = old;
|
|
g.Dispose();
|
|
}
|
|
|
|
private void PlayerStatsTimer_Tick(object sender, EventArgs e)
|
|
{
|
|
UpdatePlayerStats();
|
|
}
|
|
}
|
|
}
|