What's new
  • Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Visit Resources
  • Visit Downloads
  • Visit Portal

[Helper] WorldMapAreas - how to convert abs coords to map coords (0.00-1.00)

cowdude

Active Member
Joined
Feb 17, 2010
Messages
337
Reaction score
27
Hi,

I'm cleaning CowStats by removing most of LUA calls. Here's a simple class that might help anyone who needs relative coords.

Usage:
Code:
//init helper
WorldMapAreas.Init();
//get rel coords of player
WorldMapAreas.MapCoords relative = WorldMapAreas.GetRelativeCoords(me.ZoneId, me.Location);

Bugs:
Will not work in many instances
Does not work in Dalaran
 

Attachments

Hi,

I'm cleaning CowStats by removing most of LUA calls. Here's a simple class that might help anyone who needs relative coords.

Usage:
Code:
//init helper
WorldMapAreas.Init();
//get rel coords of player
WorldMapAreas.MapCoords relative = WorldMapAreas.GetRelativeCoords(me.ZoneId, me.Location);

Bugs:
Will not work in many instances
Does not work in Dalaran


Great!

I have been tinkering with this. I think i have the map offset and size for dalaran, i will check and pm you if i do.
 
Why don't you use a static constructor instead of a redundant Init function?

Also, you can go the other way too by using a simple linear interpolation:
Code:
public Vector2 GetAbsoluteCoords(Vector2 relativeCoords)
{
    return new Vector2(Interpolate(x1, x2, relativeCoords.X), Interpolate(y1, y2, relativeCoords.Y));
}

private static float Interpolate(float min, float max, float amount)
{
    return min + (max - min) * amount;
}
 
Also, if you want maximum performance, use a Dictionary<uint, worldmaparea=""> and make the key the zone ID.

EDIT: And also, instead of hardcoding it, you can use the database in HB - you just pass the zone ID to GetRow.

Code:
WoWDb.DbTable worldMapArea = StyxWoW.Db[ClientDb.WorldMapArea];
WoWDb.Row durotar = worldMapArea.GetRow(4);
var ay = durotar.GetField<float>(4);
var by = durotar.GetField<float>(5);
var ax = durotar.GetField<float>(6);
var bx = durotar.GetField<float>(7);
var a = new Vector2(ax, ay);
var b = new Vector2(bx, by);
WoWPoint myLoc = ObjectManager.Me.Location;
Logging.Write("You are at {0}, {1} relative", (myLoc.Y - a.Y) / (b.Y - a.Y), (myLoc.X - a.X) / (b.X - a.X));
</uint,>
 
Last edited:
Back
Top