I needed a little bit of help making a compass feature for a game.
SO, this is my code.. it will only show "E" (east) .. im assuming because for some reason its always seeing the direction as 0 and not updating with the direction.
Code:
long eOffset = this.GameMemory.ReadInt64(gOffset);
long pOffset = this.GameMemory.ReadInt64(eOffset + 0x22D8);
pD = this.GameMemory.ReadFloat(pOffset + 0x128);
if (pD > -0.5 || pD < 0.5 )
{
compass = "E";
}
else if (pD > 0.5 || pD < 0.9)
{
compass = "NE";
}
else if (pD > 0.9 || pD < 2.0)
{
compass = "N";
}
else if (pD > 2.0 || pD < 2.4)
{
compass = "NW";
}
else if (pD > 2.4 || pD <= 3.14)
{
compass = "W";
}
else if (pD >= -3.14 || pD < -2.4)
{
compass = "W";
}
else if (pD > -2.4 || pD < -2.0)
{
compass = "SW";
}
else if (pD > -2.0 || pD < -0.9)
{
compass = "S";
}
else if (pD > -0.9 || pD < -0.5)
{
compass = "SE";
}
Also, I have this declared in the main class
Code:
public static float pD;
public string compass; // <----- maybe this is not the right format to set this?
Code:
TextRegion = new POINT(this.GameWindowRect.Left + 15, this.GameWindowRect.Top + 35);
if (ShowDirection)
{
DrawText("Direction: " + pD.ToString("F2") + " : " + compass, ref TextRegion, Color.Cyan);
}
Just for further clarification.. let me give an example of my problem.
In the drawn text, it shows "Direction: 2.10 : E".
This is clearly wrong because according to the math, if the pD ("2.10") is greater than 2.0 and also less than 2.4, it should be displaying "NW" not "E".
Any help or info would be appreciated thanks.






