• Visit Rebornbuddy
  • Checking if instance is locked out?

    Discussion in 'Honorbuddy Forum' started by thetrueman2, Jan 19, 2015.

    1. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      Hello there buddies!

      I'm currently working on a profile that will do a very large run around various instances and raids to get certain drops. However I'm running into a small issue with the API. I was unable to find any way to find out if a character is instance locked (for heroic modes/raids). This is key for me, as when the profile is interrupted or restarted for whatever reason I need it to skip the instances it has already done.

      I tried to work around this issue by getting the value from LUA as described here: https://www.thebuddyforum.com/honor...-profile-check-raid-instance-boss-killed.html but was ultimately unsuccesful due to bugs in the MapID naming system and lua returning weird things (some names do not match the instance lockout names, like [Auchindoun: ]Sethekk Halls). Didnt want to necro that topic, hence this one.

      Does anyone know a way around this, or give me a pointer where I can find a (lua) workaround?

      Thanks in advance!

      ttm2
       
    2. h4xxor

      h4xxor New Member

      Joined:
      Sep 18, 2012
      Messages:
      445
      Likes Received:
      3
      Trophy Points:
      0
    3. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      Thanks for the reply! I built on the code as supplied in the tread above but improved on it. This also includes a check that checks if the user is actually locked out, as instance locks remain in the list even if they expired.

      I ran it within a client and it evaluated properly when I wanted it to, but it always evaluates to true in HB even if the bot isnt locked out. I also tried replacing the ".First" with "[0]" but as they should essentially return the same result the problem can't be in there.. can it?

      Code:
            <If Condition="(Lua.GetReturnValues(&quot;&quot;for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == GetMapNameByID(*area id*) and l == true) then return 1 end end return 0&quot;&quot;).First() == &quot;&quot;0&quot;&quot;)" >
      
      The result is the same with GetReturnVal<int>
      Code:
            <If Condition="(Lua.GetReturnVal&lt;int&gt;(&quot;&quot;for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == GetMapNameByID(798) and l == true) then return 1 end end return 0&quot;&quot;, 0) == 0)" >
      
      Any idea what I'm doing wrong? Or is there a bug present that causes HB to return invalid values?
       
    4. namednoob

      namednoob Community Developer

      Joined:
      Apr 25, 2014
      Messages:
      1,097
      Likes Received:
      25
      Trophy Points:
      38
      Last edited: Jan 20, 2015
    5. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      The problem I'm having is that i need to know if a specific boss has already been killed or not.. the CanShowResetInstances() would show me too wide of a scope for that (eg it may be true for several bosses, which makes it unusable for what I'm trying to do).

      I'm not an expert at lua, but running the following ingame works regardless if I opened the raid frame or not (although I will include a macro to open and close it at the beginning, thanks for the tip!). I'm running into problems when HB checks if what lua returns is 0 or 1, because it's neither if HB is to be believed.

      Simplified check to see if Magister's Terrace is locked out (working ingame, not in my profile):
      Code:
      /run for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == GetMapNameByID(798) and l == true) then print(n.." is locked out"); end end print("no lockout or end of script");
      
      I'm seriously stuck on this. the moving around won't work properly if I can't get this to work :/
       
    6. namednoob

      namednoob Community Developer

      Joined:
      Apr 25, 2014
      Messages:
      1,097
      Likes Received:
      25
      Trophy Points:
      38
      Untested but have you tried something like:
      HTML:
      <If Condition="(Me.MapId == 798 &amp;&amp; Lua.GetReturnValues(&quot;return GetSavedInstanceInfo(instanceIdHere)&quot;)[0] == &quot;1&quot;)" >
       
    7. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      I appreciate the help but that won't work. GetSavedInstanceInfo() takes an index as an argument from the player's list of saved instances. But the index between players is never the same.

      Example:

      Bot 1:
      Code:
      (1) Active Lock for Naxxramas
      (2) Active Lock for Sethekk Halls
      (3) Expired Lock for Magister's Terrace
      
      Bot 2
      Code:
      (1) Active Lock for Tempest Keep
      (2) Expired Lock for Magister's Terrace
      
      Bot 3
      Code:
      (1) Active Lock for Tempest Keep
      
      if I were to call GetSavedInstanceInfo(2) on bot 1 it would return a lockout for Sethekk Halls, if I were to check for that same command on bot 2 it would return an expired lock for Magister's Terrace, and on bot 3 it would return null because there is no instance lock at index 2. The lua code I have works but I can't get HB to read the return value properly. Because of that HB thinks every instance is locked out and it doesn't go anywhere.
       
    8. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      Ok, so I spent more time debugging and it turns out my formatting was wrong.

      This is the final solution, which seems to be working so far:
      Code:
        <If Condition="(Lua.GetReturnValues(&quot;for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == GetMapNameByID(*area id*) and l == true) then return 1 end end return 0&quot;).First() == &quot;1&quot;)" >
      
      This returns true if a bot is locked out of the area id given in *area id* and false if there is no lock or it has expired. As mentioned in the OP please do note that not all instance locks share names with the name given in GetMapNameByID() and I would recommend testing the result of that query with /dump before putting it into production.

      Thanks for the help nontheless! :)
       
    9. HHeLiBeBCNOF

      HHeLiBeBCNOF Member

      Joined:
      Oct 24, 2014
      Messages:
      93
      Likes Received:
      3
      Trophy Points:
      8
      I spent a while trying to figure this out and every time I went to Google I cam across this post. For those also looking, this works;

      PHP:
      <If Condition="(Lua.GetReturnValues(&quot;for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == 'Auchindoun: Sethekk Halls' and l == true) then return 1 end end return 0&quot;).First() == &quot;1&quot;)" >
          <
      CustomBehavior File="Message" Text="Locked to Sethekk Halls" />
      </If>
      <If 
      Condition="(Lua.GetReturnValues(&quot;for i=1,GetNumSavedInstances() do local n,_,_,_,l = GetSavedInstanceInfo(i) if (n == 'Auchindoun: Sethekk Halls' and l == true) then return 1 end end return 0&quot;).First() == &quot;0&quot;)" >
          <
      CustomBehavior File="Message" Text="Not Locked to Sethekk Halls" />
      </If>
      EDIT: Please note, the code has been cropped, it should read on only 6 lines like so;
      PHP:
      <If Condition="...&quot;1&quot;)" >
          <
      CustomBehavior ... />
      </If>
      <If 
      Condition="...&quot;0&quot;)" >
          <
      CustomBehavior ... />
      </If>
      In order to get this working, I found this little LUA snippet extremely helpful, it will get the zoneID of any map (need to be inside dungeons for their ID):
      PHP:
      /run local id=GetCurrentMapAreaID();print(("%s:%d"):format(GetMapNameByID(id),GetCurrentMapAreaID()))
      Derefered link to source of this code.
       
      Last edited: Mar 6, 2015
    10. thetrueman2

      thetrueman2 Member

      Joined:
      Jan 24, 2012
      Messages:
      64
      Likes Received:
      2
      Trophy Points:
      8
      I solved this in a similar way. The issue with your code being that it will not function on clients other than enGB, because the instance lock names will not match with foreign names. For example, the name returned by GetSavedInstanceInfo() for Magister's Terrace is 'Magister's Terrace', while the name given by GetMapNameByID() is 'Magisters' Terrace'. This obviously does not match, so the way Im working around this is to only match part of the instance name to the value saved in n. This obviously does not resolve issues for every localization, but will work for example for german clients ('Terrasse der Magister').

      Code:
      string.find(n, 'Magister') ~= nil
      
       

    Share This Page