• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • [Tool] Pirox to Honorbuddy Profile Converter

    Discussion in 'Archives' started by Apoc, Dec 11, 2011.

    1. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      Just a simple exe file to convert Pirox's .ini profile format, to HB's XML format.

      Please keep in mind; this does NOT support vendors, as pirox profiles don't hold enough information to create the vendor tags with. (And I'm not going to write a WoWHead parser to pull the required info)

      It will insert some default tags. If you want to change the sell/mail behaviors, edit the XML it spits out.

      Instructions:

      Drop the Pirox .ini profile on the exe, and... thats it. A file with a .xml extension will be created (with the same name as the .ini version).

      EXE is attached below for those not wanting to play with code.

      Actual code is as follows;

      Code:
      using System;using System.Collections.Generic;
      using System.Globalization;
      using System.IO;
      using System.Linq;
      using System.Runtime.InteropServices;
      using System.Text;
      using System.Xml.Linq;
      
      
      namespace PiroxToHonorbuddy
      {
          internal class Program
          {
              private static void Main(string[] args)
              {
                  try
                  {
                      if (args.Length == 0)
                      {
                          Console.WriteLine("Please specify a Pirox profile.");
                          return;
                      }
                      if (!File.Exists(args[0]))
                      {
                          Console.WriteLine("File does not exist.");
                          return;
                      }
      
      
                      // Quick wrapper to make reading easier. Win32 API is annoying...
                      var file = new IniFile(args[0]);
      
      
                      // TODO: Sanit-check these for "0" values
                      string minLevel = file.Read("Profile", "MinLevel");
                      string maxLevel = file.Read("Profile", "MaxLevel");
                      // Just use the filename as the name. Don't bother parsing the name in the profile
                      string name = Path.GetFileNameWithoutExtension(args[0]);
      
      
                      // Pirox profiles continue the "z#" count throughout ini sections. So we need to store the "i" counter globally
                      // to ensure we can read in the next sections on the profile properly.
                      int i;
      
      
                      // Get WPs
                      var pts = new List<Point>();
                      // 10k just to make sure we get everything. This is seriously overkill, but pirox profiles really have no "count" type variable
                      // to optimize reading. Then again, .ini format for profiles in general is terrible
                      for (i = 1; i < 10000; i++) 
                      {
                          string tmp = file.Read("GoTo", "z" + i);
                          if (tmp == null)
                          {
                              continue;
                          }
      
      
                          if (!tmp.StartsWith("WPX"))
                          {
                              continue;
                          }
      
      
                          // Remove Pirox's call stuff
                          tmp = tmp.Replace("WPX", "").Replace("(", "").Replace(")", "").Trim();
      
      
                          // Split it. X, Y, Z
                          string[] split = tmp.Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries);
      
      
                          // Parse it to a "Point"
                          var p = new Point(
                              float.Parse(split[0], CultureInfo.InvariantCulture),
                              float.Parse(split[1], CultureInfo.InvariantCulture),
                              float.Parse(split[2], CultureInfo.InvariantCulture));
      
      
                          pts.Add(p);
                      }
      
      
                      // TODO: Add vendor shit.
      
      
                      var root = new XElement(
                          "HBProfile",
                          new XElement("Name", name),
      
      
                          // Defaults
                          new XElement("MinDurability", "0.4"),
                          new XElement("MinFreeBagSlots", "1"),
                          new XElement("MailGrey", false),
                          new XElement("MailWhite", true),
                          new XElement("MailGreen", true),
                          new XElement("MailBlue", true),
                          new XElement("MailPurple", true),
                          new XElement("SellGrey", false),
                          new XElement("SellWhite", false),
                          new XElement("SellGreen", false),
                          new XElement("SellBlue", false),
                          new XElement("SellPurple", false),
      
      
                          // From profile
                          new XElement("MinLevel", minLevel),
                          new XElement("MaxLevel", maxLevel),
      
      
                          // [GoTo] points
                          new XElement(
                              "Hotspots",
                              pts.Select(p => p.ToXml()).ToArray()));
      
      
                      File.WriteAllText(Path.ChangeExtension(args[0], ".xml"), root.ToString());
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine(e.ToString());
                  }
              }
      
      
              #region Nested type: IniFile
      
      
              public class IniFile
              {
                  private readonly string _path;
      
      
                  public IniFile(string iniPath)
                  {
                      _path = iniPath;
                  }
      
      
                  [DllImport("kernel32")]
                  private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
      
      
                  public string Read(string section, string key)
                  {
                      var temp = new StringBuilder(255);
                      int i = GetPrivateProfileString(section, key, "", temp, 255, _path);
                      if (i == 0)
                      {
                          return null;
                      }
      
      
                      return temp.ToString();
                  }
              }
      
      
              #endregion
      
      
              #region Nested type: Point
      
      
              private struct Point
              {
                  public float X, Y, Z;
      
      
                  public Point(float x, float y, float z)
                  {
                      X = x;
                      Y = y;
                      Z = z;
                  }
      
      
                  public XElement ToXml()
                  {
                      return new XElement(
                          "Hotspot",
                          new XAttribute("X", X),
                          new XAttribute("Y", Y),
                          new XAttribute("Z", Z));
                  }
              }
      
      
              #endregion
          }
      }
       

      Attached Files:

      Last edited: Dec 11, 2011
    2. Kickazz006

      Kickazz006 Well-Known Member Moderator

      Joined:
      Jan 15, 2010
      Messages:
      20,567
      Likes Received:
      302
      Trophy Points:
      83
    3. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      Doesn't work and I want to release many profiles, sample here

      Code:
      
      [Info]
      Author=
      Version=
      Date=02.05.2011
      pTVersion=2.9.0.0
      Description=
      Mobs & Lvl Range=
      Drops=
      Ghost=
      Vendor=
      Spirithealer=
      Start Place=Alabaster Shelf
      Zone=Alabaster Shelf
      ZoneId=5042
      MapId=646
      pvpTool pack requirement=
      Forum Profile Link=
      
      
      
      [Profile]
      Faction=Both
      StartPath=;multiple paths possible, e.g: 'goto,vendor,ghost'
      MinLevel=0
      MaxLevel=0
      Loop=0
      Reversible=0
      NaturalRun=1
      DisableSearchTargets=1
      DisableCombat=1
      UseFlyMount=1
      SearchFishPools=0
      MaxObjectDistance_Min=0
      MaxObjectDistance_Max=0
      [BeforeStart]
      z0=IgnoreFaction() ;ignore human players
      [GoTo]
      z1=UseBuff() ;default
      z2=Loop() ;default
      z45=WPX( -0.54, 1134.17, 280, 0 )
      z46=WPX( -24.19, 1146.35, 280, 0 )
      z47=WPX( -53.74, 1161.59, 280, 0 )
      z48=WPX( -63.27, 1181.71, 280, 0 )
      z49=WPX( -46.71, 1202.52, 280, 0 )
      z50=WPX( -30.14, 1223.33, 280, 0 )
      z51=WPX( -13.58, 1244.15, 280, 0 )
      z52=WPX( 2.99, 1264.96, 280, 0 )
      z53=WPX( 19.56, 1285.77, 280, 0 )
      z54=WPX( 40.26, 1311.78, 280, 0 )
      z55=WPX( 60.97, 1337.8, 280, 0 )
      z56=WPX( 81.68, 1363.81, 280, 0 )
      z57=WPX( 98.24, 1384.62, 280, 0 )
      
      It can't find the profile, I think it's got something to do with Path class.
       
      Last edited: Dec 11, 2011
    4. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      Redownload and try again. Made a small change. (There's really no consistency with his profile format =\)
       
    5. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      still not finding the profile, definitly something to do with the Path.GetName i think

      I tried in drive C: and Y:, although it seems to work in Downloads folder though

      EDIT1: It converted 1 profile once and didn't work again out of many many profiles
       
      Last edited: Dec 11, 2011
    6. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      [​IMG]

      Sample.ini is the same as the one above (in code tags)

      Managed to screenshot it within the second that the window was open, no readline function for me :(

      using latest version of your program that you just updated (7.50KB)
       
      Last edited: Dec 11, 2011
    7. Paragon

      Paragon Member

      Joined:
      Dec 4, 2011
      Messages:
      74
      Likes Received:
      0
      Trophy Points:
      6
      Still not working for me. :(
       
    8. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      Keep trying though, they're many profiles in PiroxBots.com that can be used in Honorbuddy.

      A for Effort :D
       
    9. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      it's a comment in your code-snippet.

      the numbers at the 'z' are not a counter. this means they are NOT in ascending order.
      they can be left away and so on.

      the only fixed thing for the Profile is the 'z' at the beginning of the line, follow by a number or not, and then the '=' ;)




      //sorry for bad english -.-
       
    10. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      Yes, z= is exactly the same as with numbers... i personally hated it but pirox never changed it back, you could have z=25 and then z=84 and it would still work fine.
       
    11. raynez

      raynez New Member

      Joined:
      Dec 16, 2011
      Messages:
      45
      Likes Received:
      0
      Trophy Points:
      0
      Everytime I try to open it it opens up counsel menu but just shuts off and it still wont work
       
    12. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      you have to drag the profile and drop it on the .exe
       
    13. Giwin

      Giwin Well-Known Member Buddy Store Developer

      Joined:
      Dec 3, 2011
      Messages:
      3,431
      Likes Received:
      49
      Trophy Points:
      48
      this seems to be working.
       
    14. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      i modified Apoc's code a little bit. (if it is ok for you ;) if not please delete my post here)

      it is nearly the same as you can see below.
      i just changed the WPX finding thing (regex in this case), cause i remembered that i began a log parser for pvpTool logs.


      if you try to use it you should separate multiway-profiles with many pathes in it in different (pvpTool)profiles / files, because it takes now ALL WPX(x,y,y)-lines out of the profile and convert them to HB hotspots!
      (possibly not what you want / expect)

      Code:
      using System;
      using System.Collections.Generic;
      using System.Globalization;
      using System.IO;
      using System.Linq;
      using System.Runtime.InteropServices;
      using System.Text;
      using System.Xml.Linq;
      using System.Text.RegularExpressions;
      
      namespace ProfilConverter
      {
          class Program
          {
              static void Main(string[] args)
              {
                  //copied from Apoc -> all credits belong to him
                  //just modified the WPX-coords finding thing
                  try
                  {                
                      if (args.Length == 0)
                      {
                          Console.WriteLine("Please specify a Pirox profile.");
                          return;
                      }
                      if (!File.Exists(args[0]))
                      {
                          Console.WriteLine("File does not exist.");
                          return;
                      }
      
                      // Quick wrapper to make reading easier. Win32 API is annoying...
                      var file = new IniFile(args[0]);
                      
                      // TODO: Sanit-check these for "0" values
                      string minLevel = file.Read("Profile", "MinLevel");
                      string maxLevel = file.Read("Profile", "MaxLevel");
                      // Just use the filename as the name. Don't bother parsing the name in the profile
                      string name = Path.GetFileNameWithoutExtension(args[0]);
                
                      // Get WPs
                      var pts = new List<Point>();
      
                      //removed Apoc's loop and add other Handling to find all WPX(x,y,z) lines in the profile                
                      foreach (string line in File.ReadAllLines(args[0]))
                      {
                          //commented line check
                          if(line.StartsWith(";"))
                              continue;
      
                          //check for a 'z' at the beginning of a line
                          if (!line.StartsWith("z"))
                              continue;
                          
                          //check if there is a 'WPX' anywhere 
                          if (!line.Contains("WPX"))
                              continue;
      
                          //parse the coords out of it                    
                          Regex _regex = new Regex(@"WPX\([ ]*(.+)[ ]*\)");
      
                          Match match = _regex.Match(line);
                          string dummy = match.Groups[1].Value;
                          
                          //copied from Apoc
      
                          // Split it. X, Y, Z
                          string[] split = dummy.Split(new[] { ',' });
      
                          // Parse it to a "Point"
                          var p = new Point(
                              float.Parse(split[0], CultureInfo.InvariantCulture),
                              float.Parse(split[1], CultureInfo.InvariantCulture),
                              float.Parse(split[2], CultureInfo.InvariantCulture));
      
                          pts.Add(p);
                      }
      
                      // TODO: Add vendor shit.                
                      var root = new XElement(
                          "HBProfile",
                          new XElement("Name", name),
      
      
                          // Defaults
                          new XElement("MinDurability", "0.4"),
                          new XElement("MinFreeBagSlots", "1"),
                          new XElement("MailGrey", false),
                          new XElement("MailWhite", true),
                          new XElement("MailGreen", true),
                          new XElement("MailBlue", true),
                          new XElement("MailPurple", true),
                          new XElement("SellGrey", false),
                          new XElement("SellWhite", false),
                          new XElement("SellGreen", false),
                          new XElement("SellBlue", false),
                          new XElement("SellPurple", false),
      
      
                          // From profile
                          new XElement("MinLevel", minLevel),
                          new XElement("MaxLevel", maxLevel),
      
      
                          // [GoTo] points
                          // -> all Points found in the file
                          new XElement(
                              "Hotspots",
                              pts.Select(p => p.ToXml()).ToArray()));
      
      
                      File.WriteAllText(Path.ChangeExtension(args[0], ".xml"), root.ToString());
                  }
                  catch (Exception e)
                  {
                      Console.WriteLine(e.ToString());
                  }
      
              }
              
      
              #region Nested type: IniFile
      
              public class IniFile
              {
                  private readonly string _path;
      
      
                  public IniFile(string iniPath)
                  {
                      _path = iniPath;
                  }
      
      
                  [DllImport("kernel32")]
                  private static extern int GetPrivateProfileString(string section, string key, string def, StringBuilder retVal, int size, string filePath);
      
      
                  public string Read(string section, string key)
                  {
                      var temp = new StringBuilder(255);
                      int i = GetPrivateProfileString(section, key, "", temp, 255, _path);
                      if (i == 0)
                      {
                          return null;
                      }
      
                      return temp.ToString();
                  }
              }
      
      
              #endregion
      
      
              #region Nested type: Point
      
      
              private struct Point
              {
                  public float X, Y, Z;
      
      
                  public Point(float x, float y, float z)
                  {
                      X = x;
                      Y = y;
                      Z = z;
                  }
      
      
                  public XElement ToXml()
                  {
                      return new XElement(
                          "Hotspot",
                          new XAttribute("X", X),
                          new XAttribute("Y", Y),
                          new XAttribute("Z", Z));
                  }
              }
      
      
              #endregion
          }
      }
       

      Attached Files:

    15. Apoc

      Apoc Moderator Staff Member Moderator

      Joined:
      Jan 16, 2010
      Messages:
      2,790
      Likes Received:
      94
      Trophy Points:
      48
      I didn't do this because Honorbuddy doesn't need to be told how to get back to a wander path to get your corpse. It will simply go straight to your corpse, regardless of where you are.
       
    16. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      I agree. The Corpse paths are Not needed.

      But you can Name the section with the waypoints to whatever you want. It Must Not be 'Goto'.

      Code:
      [Goto]
      z=WPX(xxx,yyy,zzz)
      ....
      z=J2P('Farm')
      
      [Farm]
      z=WPX(hhh,lll,kkk)
      ...
      Thats why i changed it to grep all WPX Parts.

      But the converter Users have to know how pirox profiles work and separate them into different Files.


      Sent from my iPhone using Tapatalk
       
      Last edited: Dec 23, 2011
    17. HB6526V74

      HB6526V74 New Member

      Joined:
      Jun 7, 2011
      Messages:
      48
      Likes Received:
      0
      Trophy Points:
      0
      Still not working

      I dont get this Multi Jump profile to a Honorbuddy profile !
       

      Attached Files:

      Last edited: Dec 24, 2011
    18. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      mutli jump is not support by this converter. (atm)
      you have to transform every file into a honorbuddy profile, if possible.

      i know that the pvpTool profiles can be "complex" with the J2P, J2PIfInRangen, .... so not every profile can be easily converted.
       
    19. trollp

      trollp New Member

      Joined:
      Dec 11, 2011
      Messages:
      219
      Likes Received:
      0
      Trophy Points:
      0
      i tested your "this.zip" and it seems to work.
      BUT you don't have multiple pathes then in the honorbuddy profile, only one big list of hotspots!

      that what i said before -> http://www.thebuddyforum.com/honorb...onorbuddy-profile-converter-2.html#post417142
       
    20. grutamu

      grutamu Member

      Joined:
      Jan 15, 2010
      Messages:
      226
      Likes Received:
      0
      Trophy Points:
      16
      Is their a way to get the PvP profiles from pirox working? I tried converting about 10 profiles and not a single one worked. It doesn't record anything from the PvP profiles.
       

    Share This Page