Read-only archive of the Armageddon Games Forums Archive (2000–2026) · About this archive

NPC XY Coordinates

1 replies · 1,544 views · Started 26 February 2007

I believe it is possible to change the XY coordinates of an NPC, all I ask is what is the variable called, and is it possible to manipulate it?

EDIT: Never mind, but is there a way to retrieve the NPC's direction/distance from Link?

There's no built-in function for that. Here's the distance function, though, in case you don't know it:

float Distance(float x1, float y1, float x2, float y2)
{
return Sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
}

Then the distance is just [font="Courier New"]Distance(Link->X, Link->Y, NPCPtr->X, NPCPtr->Y)[/font].
As for the direction... Well, there are a few different ways you could find that, depending on what you're trying to accomplish. If you just need up/down/left/right, the easiest way is just to compare the X and Y values. If you need a precise angle, though, you'll probably have to bring trigonometry into it.
Hm... I'm pretty sure there's no arctangent function at the moment, though.