• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • [Helper] WorldMapAreas - how to convert abs coords to map coords (0.00-1.00)

    Discussion in 'Archives' started by cowdude, Jun 16, 2010.

    1. cowdude

      cowdude Active Member

      Joined:
      Feb 17, 2010
      Messages:
      337
      Likes Received:
      27
      Trophy Points:
      28
      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
       

      Attached Files:

      thedrunk likes this.
    2. DarkBen

      DarkBen New Member

      Joined:
      Jan 15, 2010
      Messages:
      299
      Likes Received:
      12
      Trophy Points:
      0

      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.
       
    3. MaiN

      MaiN Moderator Staff Member Moderator Buddy Core Dev

      Joined:
      Jan 15, 2010
      Messages:
      1,017
      Likes Received:
      35
      Trophy Points:
      48
      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;
      }
      
       
    4. cowdude

      cowdude Active Member

      Joined:
      Feb 17, 2010
      Messages:
      337
      Likes Received:
      27
      Trophy Points:
      28
      Didnt know about static constructors. :)
       
    5. MaiN

      MaiN Moderator Staff Member Moderator Buddy Core Dev

      Joined:
      Jan 15, 2010
      Messages:
      1,017
      Likes Received:
      35
      Trophy Points:
      48
      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: Jun 17, 2010

    Share This Page