• Visit Rebornbuddy
  • Visit Panda Profiles
  • Visit LLamamMagic
  • Auctionhouse plugin.

    Discussion in 'Archives' started by morgalis, Feb 10, 2010.

    1. morgalis

      morgalis New Member

      Joined:
      Jan 15, 2010
      Messages:
      54
      Likes Received:
      0
      Trophy Points:
      0
      @MrBig: did you got my PM
       
    2. morgalis

      morgalis New Member

      Joined:
      Jan 15, 2010
      Messages:
      54
      Likes Received:
      0
      Trophy Points:
      0
      Added Bag handle , items itemcount and stack creating

      Code:
      namespace Styx.Bot.CustomClasses
      {
          using Logic.Inventory.Frames.MailBox;
          using Logic;
          using System;
          using Helpers;
          using Logic.Pathing;
          using System.Threading;
          using System.Diagnostics;
          using Logic.Common.Combat;
          using Object_Dumping_Enumeration;
          using CustomCombat.CombatInterface;
          using Memory_Read_Write_Inject.Lua;
          using Object_Dumping_Enumeration.WoWObjects;
          using System.Collections.Generic;
          using System.IO;
          using System.Runtime.InteropServices;
          using System.Xml.Linq;
          using System.Linq;
          using System.Net;
          using Styx.Plugins.PluginClass;
          using Styx;
      
          public class AH : HBPlugin
          {
              public Status currentAction = Status.MoveToAuctionner;
      
              string Totauctions = "";
      
              //private WoWUnit AHnpc;
              //private WoWGameObject mailbox;
              
              public enum Status
              {
                  Idle             = 0,
                  MoveToAuctionner = 1,
                  MoveToMail       = 2,
                  SellingStuff     = 3,
                  BuyStuff         = 4,
                  Disenchanting    = 5,
                  SearchingAH      = 6,
                  BottomScan       = 7,
                  Waiting          = 8
              }
      
              private static Stopwatch avoidCrashTimer = new Stopwatch();
      
              private static Stopwatch waitTimer = new Stopwatch();
      
              public override void Pulse()
              {
                  if (!avoidCrashTimer.IsRunning)
                  {
                      avoidCrashTimer.Start();
      
                  }
                  if (avoidCrashTimer.Elapsed.Seconds < 1)
                  {
                      return;
                  }
                  avoidCrashTimer.Reset();
      
                 
                  
                  switch (currentAction)
                  { // temporary statemachine , need better when finishing tests.
      
                      case Status.MoveToAuctionner: //TO_AUCTIONEER                    
                          MoveToAuctioneer();
                          scanAhWithAuctioneerAddon();
                         
                          break;
      
                      case Status.MoveToMail://move to mail and fetch.
                          MoveToMail();
                          break;
      
                      case Status.SellingStuff:
                          //sell stuff here
                          break;
      
                      case Status.BuyStuff:
                          //buying stuff here.
                          break;
                      case Status.SearchingAH:
                          //should wait until completion
                          //todo: add completion checks
                          
                          break;
                      case Status.Waiting:
                          if (waitTimer.Elapsed.Minutes > 2)
                              currentAction = Status.Idle;
                          break;
                      case Status.Idle:
                          // do something
                          //shouldnt really just move to auctionner, but make maintenance checks
                          if (CheckMail() /*todo: and bags are not full*/)
                          {
                              currentAction = Status.MoveToMail;
                              return;
                          }
                          currentAction = Status.MoveToAuctionner;
                          break;
      
                      default:
                          Thread.Sleep(1000);
                          break;
                  }
              }
              //
              //
              //
              //
              public bool TargetUnit(uint Nom)
              {
                  ObjectManager.Update();
                  Thread.Sleep(1000);
      
                  foreach (WoWUnit wu in ObjectManager.GetObjectsOfType<WoWUnit>())
                  {
                      if (wu.Entry == Nom)
                      {
                          Logging.Write(wu.Name + " is now my target!");
                          wu.Target();
                      }
                  }
      
                  Thread.Sleep(1000);
                  if (ObjectManager.Me.CurrentTarget.Entry == Nom)
                  {
      
                      return true;
                  }
                  return false;
              }
              //
              //
              //
              //
              public bool TargetObj(uint Nom)
              {
                  ObjectManager.Update();
                  Thread.Sleep(1000);
      
                  foreach (WoWGameObject wa in ObjectManager.GetObjectsOfType<WoWGameObject>())
                  {
                      if (wa.Entry == Nom)
                      {
                          wa.Interact();
                      }
                  }
                  Thread.Sleep(1000);
                  if (ObjectManager.Me.CurrentTarget.Entry == Nom)
                  {
                      return true;
                  }
                  return false;
              }
      
              public bool MoveToAuctioneer()
              {
                  WoWUnit ahnpc = findNearestAH();
                  //this need better loggic.maybe using Frames
                  var wp = ahnpc.Location;
      
                  if (wp.Distance(ObjectManager.Me.Location) > 5)
                  {
                      Navigator.GeneratePathFromMe(wp);
                      Logging.Write("Moving to Auctioneer");
      
                      while (wp.Distance(ObjectManager.Me.Location) > 5)
                      {
                          Navigator.MoveTo(wp);
                          Navigator.Pulse();
                      }
                      Thread.Sleep(1000);
                      //findNearestAH());
                      //TargetUnit(findNearestAH().Guid);
                      findNearestAH().Target();
                      Thread.Sleep(1000);
                      ObjectManager.Me.CurrentTarget.Interact();
                      Thread.Sleep(2000);
                      Lua.DoString("QueryAuctionItems(\"Eternal Fire\",\"\",\"\",nil,nil,nil,nil,nil,nil)");// Eternal fire hardcoded. Styx has some AH stuff inside already.
                      Thread.Sleep(1000);
                      Logging.Write("Displayed Auction lines:  " + TotalAuctionLines());
                  }
                  return true;
              }
             
              public bool MoveToMail()
              {
                  WoWGameObject mail = findNearestMailbox();
      
                  var wp = mail.Location;
                  var ml = new MailFrame();
                  Navigator.GeneratePathFromMe(mail.Location);
                  Logging.Write("Moving to Mail");
                  while (wp.Distance(ObjectManager.Me.Location) > 5)
                  {
                      Navigator.MoveTo(mail.Location);
                      Navigator.Pulse();
                  }
                  if (wp.Distance(ObjectManager.Me.Location) < 5)
                  {
                      //TargetObj(173221);
                      mail.Interact();
                      Thread.Sleep(3000);
                      while (Convert.ToInt32(ml.MailCount.ToString()) > 0)
                      {
                          Logging.Write("Standing at Mailbox for collecting mails: " + ml.MailCount.ToString());
                          Thread.Sleep(1000);
                          ml.GetMailAttachments(1);
                      }
                      currentAction = Status.MoveToAuctionner;
                  }
                  currentAction = Status.MoveToAuctionner;
      
                  //found greens?
                  GetGreens();
                  return true;
      
              }
              public string TotalAuctionLines()
              {
                  Lua.DoString("Totauctions = GetNumAuctionItems(\"list\")");
                  Totauctions = Lua.GetLocalizedText("Totauctions");
      
                  return Totauctions;
              }
      
              public bool CheckMail()
              {
                  int IHave = 0;
                  Lua.DoString("IHave = HasNewMail()");
                  IHave = Convert.ToInt32(Lua.GetLocalizedText("IHave"));
                  Logging.Write("Gonna check for new mail");// Debug spam.
                  if (IHave > 0)
                  {
                      currentAction = Status.MoveToMail;
      
                      return true;
                  }
                  return false;
              }
      
              public WoWGameObject findNearestMailbox()
              {
                  ObjectManager.Update();
                  Thread.Sleep(1000);
                  foreach (WoWGameObject wu in ObjectManager.GetObjectsOfType<WoWGameObject>())
                  {
                      if (wu.Name == "Mailbox")
                      {
                          Logging.Write("Found " + wu.Name + " at: [" + wu.Location.X + "," + wu.Location.Y + "," + wu.Location.Z+"]");
                          return wu;
                      }
                  }
                  return null;
              }
              public WoWUnit findNearestAH()
              {
                  ObjectManager.Update();
                  Thread.Sleep(1000);
                  foreach (WoWUnit wu in ObjectManager.GetObjectsOfType<WoWUnit>())
                  {
                      if (wu.IsAuctioneer) //&& Navigator.CurrentMesh.IsPointPathingAvailable(wu.Location))
                      {
                          Logging.Write("Found " + wu.Name + " at: [" + wu.Location.X + "," + wu.Location.Y + "," + wu.Location.Z+"]");
                          return wu;
                      }
                  }
                  return null;
              }
      
      
      
      
      
              public void scanAhWithAuctioneerAddon()
              {
                  Logging.Write("Searching AH");
                  Lua.DoString("if (AucAdvScanButton:IsVisible()) then AucAdvScanButton:Click() end");
                  currentAction = Status.SearchingAH;
                  waitTimer.Reset();
                  waitTimer.Start();
                  
              }
      
      
      
      
      
              public void PickupNumberOfItems(string itemName, int numberToPickup)
              {
                  MakeStacks(itemName);
                  Thread.Sleep(1000);
                  Lua.DoString(
                      "for bag=0,4 do " + //foreach bag
                          "for slot=1,GetContainerNumSlots(bag) do " + //foreach item in bag"
                              "local item = GetContainerItemLink(bag,slot) " +
                              "if item and item:find(\"" + itemName + "\") then " +
                                  "local _,itemCount = GetContainerItemInfo(bag,slot) " +
                                  "if itemCount>" + (numberToPickup - 1) + " then " +
                                      "local a=0 local b=0 " +
                                      "for x=0,4 do " +
                                          "for y=1,GetContainerNumSlots(x) do " +
                                              "if not GetContainerItemLink(x,y) then " +
                                                  "a=x b=y " +
                                              "end " +
                                          "end " +
                                      "end " +
                                    "if b > 0 then " +
                                  "ClearCursor() " +
                                "repeat " +
                              "local_,_,locked1 = GetContainerItemInfo(bag,slot) " +
                          "local_,_,locked2 = GetContainerItemInfo(a,b) " +
                      "until not locked1 and not locked2 " +
                                          "SplitContainerItem(bag,slot," + numberToPickup + ") " +
                                          "PickupContainerItem(a,b) " +
                                          "bag=1000 slot=1000 " +
                                      "end " +
                                  "end " +
                              "end " +
                          "end " +
                      "end");
                  Thread.Sleep(1000);
                  Lua.DoString(
                      "for bag=0,4 do " + //foreach bag
                          "for slot=1,GetContainerNumSlots(bag) do " + //foreach item in bag"
                              "local item = GetContainerItemLink(bag,slot) " +
                              "if item and item:find(\"" + itemName + "\") then " +
                                  "local _,itemCount = GetContainerItemInfo(bag,slot) " +
                                  "if itemCount==" + numberToPickup + " then " +
                                      "PickupContainerItem(bag,slot) " +
                                      "bag=1000 slot=1000 " +
                                  "end " +
                              "end " +
                          "end " +
                      "end");
              }
      
      
      
      
      
              private void MakeStacks(string itemName)
              {
                  Lua.DoString(
                      "for bag=0,4 do " + //foreach bag
                          "for slot=1,GetContainerNumSlots(bag) do " + //foreach item in bag"
                              "local item = GetContainerItemLink(bag,slot) " +
                              "if item and item:find(\"" + itemName + "\") then " +
                                  "PickupContainerItem(bag,slot) " +
                                  "local t,x,c=GetCursorInfo()if t==\"item\"then for i=0,4 do for j=1,28 do _,c,t=GetContainerItemInfo(i,j)if c and c>0 and c<select(8,GetItemInfo(x))and not t and strmatch(GetContainerItemLink(i,j)or\"\",\"m:\"..x)then PickupContainerItem(i,j)end end end end " +
                              "end " +
                          "end " +
                      "end");
              }
              //
              //
              //
              //
              #region Disenchanting
              //todo: add more
              private void GetGreens()
              {
                  var items = ObjectManager.GetObjectsOfType<WoWItem>(false);
                  var notSoulbound = items.Where(obj => !obj.IsSoulbound &&
                      obj.Quality == WoWItemQuality.Uncommon).ToList();
      
                  foreach (WoWItem item in notSoulbound)
                  {
                      Logging.Write("{0} is not soulbound", item.Name);
                  }
              }
              #endregion
      
      
              public override string Name { get { return "Auctioneer Fixed"; } }
      
              public override string Author { get { return "Morgalis and MrBig"; } }
      
              public override Version Version { get { return new Version(1, 2); } }
      
              public override bool WantButton { get { return false; } }
          }
      }
       
    3. hDyz

      hDyz Member

      Joined:
      Jan 15, 2010
      Messages:
      147
      Likes Received:
      1
      Trophy Points:
      18
      Will this be able to grab a set number of stacks out of a bank/guild bank?
       
    4. morgalis

      morgalis New Member

      Joined:
      Jan 15, 2010
      Messages:
      54
      Likes Received:
      0
      Trophy Points:
      0
      As you can see
      GetContainerNumSlots

      means bags. But i am sure that same code should work on bank when using bank functions.
       
    5. MrBig

      MrBig Member

      Joined:
      Jan 25, 2010
      Messages:
      419
      Likes Received:
      5
      Trophy Points:
      18
      Hey, i am on vacation, in Spain, but the weather is bad right now, will probably have to cancel :/

      Never the less, if you dont hear from me for some days you know why xD
       
      Last edited: Feb 13, 2010
    6. MrBig

      MrBig Member

      Joined:
      Jan 25, 2010
      Messages:
      419
      Likes Received:
      5
      Trophy Points:
      18
      No I didnt :( Nothing here, u sure u sent it to the right person?
       
    7. morgalis

      morgalis New Member

      Joined:
      Jan 15, 2010
      Messages:
      54
      Likes Received:
      0
      Trophy Points:
      0
      check again pls
       
    8. MrBig

      MrBig Member

      Joined:
      Jan 25, 2010
      Messages:
      419
      Likes Received:
      5
      Trophy Points:
      18
      The stored message is a message i sent
       
    9. tier

      tier New Member

      Joined:
      Jan 15, 2010
      Messages:
      53
      Likes Received:
      1
      Trophy Points:
      0
      Any update on this?
       
    10. aqrhine

      aqrhine New Member

      Joined:
      Jan 15, 2010
      Messages:
      104
      Likes Received:
      0
      Trophy Points:
      0
      Not yet sadly.. He must be letting the anticipation grow.. I've been checking the plugins forum bi-daily to see if it's been released yet.
       
    11. Hjubi

      Hjubi New Member

      Joined:
      Jan 15, 2010
      Messages:
      3
      Likes Received:
      1
      Trophy Points:
      0
      I've been trying to improve this code to fit my needs but I failed at two things.

      First I just can?t access information on what items are stored in guild bank - ObjectManager.GetObjectsOfType<WoWItem> only returns items in bags and bank not guild bank.
      I looked through all Blizzard API functions and found just one texture, count, locked = GetGuildBankItemInfo(tab, slot)
      But it doesn't seem to return needed information and I wouldn?t know how to use it anyway (any functions that retrieve values from LUA scripts ?).

      Second I don?t know how to ?push? Refresh button with alt on Auctioneer Appraiser tab and Batch post + Alt +Ctr + Shift. What code/script could do that?

      If you guys can help me with any of the above I?d be grateful.
       
    12. laria

      laria Well-Known Member

      Joined:
      Jan 15, 2010
      Messages:
      5,386
      Likes Received:
      36
      Trophy Points:
      48
    13. aqrhine

      aqrhine New Member

      Joined:
      Jan 15, 2010
      Messages:
      104
      Likes Received:
      0
      Trophy Points:
      0
      Any update on this? How about enrenion's?
       
    14. Hawker

      Hawker Well-Known Member Buddy Core Dev

      Joined:
      Jan 15, 2010
      Messages:
      2,509
      Likes Received:
      70
      Trophy Points:
      48
      We are debugging erenion's. I hope to release in an hour or so.
       
    15. lynar

      lynar New Member

      Joined:
      Jan 15, 2010
      Messages:
      394
      Likes Received:
      2
      Trophy Points:
      0
      OMG this will be so freaking good, i can't even belive it!!
       
    16. Hawker

      Hawker Well-Known Member Buddy Core Dev

      Joined:
      Jan 15, 2010
      Messages:
      2,509
      Likes Received:
      70
      Trophy Points:
      48
    17. Noinput

      Noinput New Member

      Joined:
      Jan 15, 2010
      Messages:
      9
      Likes Received:
      0
      Trophy Points:
      1
      What plugins are needed for wow?
       
    18. erenion

      erenion DEVELOPER Buddy Core Dev

      Joined:
      Jan 15, 2010
      Messages:
      321
      Likes Received:
      6
      Trophy Points:
      0
      None. (filler)
       
    19. MrBig

      MrBig Member

      Joined:
      Jan 25, 2010
      Messages:
      419
      Likes Received:
      5
      Trophy Points:
      18
      Erenion did a very good job at keeping it dependancy free, no need for other addons :)
       
    20. Marcus

      Marcus New Member

      Joined:
      Jul 10, 2010
      Messages:
      129
      Likes Received:
      0
      Trophy Points:
      0
      How to run.

      Hi, mate

      I've been wondering, what program u use to run the code.
      Personally last day i began to think: "How to make a AH Bot using G15 Keyboard"
      And i probably got the answer, just need to be tested ill do in a few days....
      Ill gladly post if i got it run in the later days, just want u to answer my question.

      Ps.
      U guys are AWESOME
       

    Share This Page