Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Drawing;
- using System.Threading;
- using System.Collections.Generic;
- using System.Linq;
- using ArcheBuddy.Bot.Classes;
- namespace OpenAuctionHouse
- {
- public class OpenAuctionHouse : Core
- {
- private int overbidamount = 40; // attempt to bid 40c above current bid
- private int waitSecondsForAuctionEnd = 300; // if a bid item is at < 3 minutes wait for it to end
- private int msToBidBeforeAuctionEnd = 5000; // wait until timeleft = 5 seconds until bidding myself
- private Random r = new Random();
- public static string GetPluginAuthor()
- {
- return "lypnn";
- }
- public static string GetPluginVersion()
- {
- return "2.3.0.0";
- }
- public static string GetPluginDescription()
- {
- return "Open Auction House";
- }
- //Call on plugin start
- public void PluginRun()
- {
- try
- {
- Log(DateTime.Now.ToShortTimeString() + " > ----- Open Auction House started -----");
- while (true)
- { //Armaduras
- buyFromAuctionHouse("Prospector's Wanderlust Breeches", 51000,1);
- buyFromAuctionHouse("Prospector's Wanderlust Cap", 51000,1);
- buyFromAuctionHouse("Prospector's Wanderlust Jerkin", 51000,1);
- buyFromAuctionHouse("Prospector's Wanderlust Guards", 51000,1); //COmpleto
- buyFromAuctionHouse("Prospector's Wanderlust Boots", 51000,1);
- buyFromAuctionHouse("Prospector's Wanderlust Belt", 51000,1);
- buyFromAuctionHouse("Prospector's Wanderlust Fists", 51000,1);
- buyFromAuctionHouse("Dawn Witch's Shoes", 51000, 1);
- buyFromAuctionHouse("Dawn Witch Hood", 51000, 1);
- buyFromAuctionHouse("Dawn Witch Pants", 51000, 1);
- buyFromAuctionHouse("Dawn Witch Sleeves", 51000, 1);
- buyFromAuctionHouse("Dawn Witch Gloves", 51000, 1); //Completo
- buyFromAuctionHouse("Dawn Witch Sash", 51000, 1);
- buyFromAuctionHouse("Dawn Witch Shirt", 51000, 1);
- buyFromAuctionHouse("Silent Forest Cap", 51000, 1);
- buyFromAuctionHouse("Silent Forest Fists", 51000, 1);
- buyFromAuctionHouse("Silent Forest Breeches", 51000, 1); //Completo
- buyFromAuctionHouse("Silent Forest Jerkin", 51000, 1);
- buyFromAuctionHouse("Silent Forest Boots", 51000, 1);
- buyFromAuctionHouse("Silent Forest Belt", 51000, 1);
- buyFromAuctionHouse("Silent Forest Guards", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Sabatons", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Gauntlets", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Tassets", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Helm", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Cuirass", 51000, 1); //Completo
- buyFromAuctionHouse("Peace Keeping Vambraces", 51000, 1);
- buyFromAuctionHouse("Peace Keeping Greaves", 51000, 1);
- buyFromAuctionHouse("Knotted Hell Gloves", 51000,1);
- buyFromAuctionHouse("Knotted Hell Hood", 51000,1);
- buyFromAuctionHouse("Knotted Hell Pants", 51000,1);
- buyFromAuctionHouse("Knotted Hell Shoes", 51000,1) ; //Completo
- buyFromAuctionHouse("Knotted Hell Sash", 51000,1) ;
- buyFromAuctionHouse("Knotted Hell Shirt", 51000,1);
- buyFromAuctionHouse("Knotted Hell Sleeves", 51000,1) ;
- buyFromAuctionHouse("Crescent Throne Hood", 51000,1);
- buyFromAuctionHouse("Crescent Throne Sash", 51000,1);
- buyFromAuctionHouse("Faded Crescent Shirt", 51000,1);
- buyFromAuctionHouse("Faded Crescent Shoes", 51000,1);
- buyFromAuctionHouse("Faded Crescent Gloves", 51000,1);
- buyFromAuctionHouse("Misty Dusk Boots", 51000,1);
- buyFromAuctionHouse("Misty Dusk Guards", 51000,1);
- buyFromAuctionHouse("Misty Dusk Jerkin", 51000,1);
- buyFromAuctionHouse("Misty Dusk Cap", 51000,1);
- buyFromAuctionHouse("Misty Dusk Breeches", 51000,1);
- buyFromAuctionHouse("Wraith Agent's Helm", 51000,1);
- buyFromAuctionHouse("Wraith Agent's Tassets", 51000,1);
- buyFromAuctionHouse("Wraith Agent's Sabatons", 51000,1);
- buyFromAuctionHouse("Wraith Agent's Cuirass", 51000,1);
- buyFromAuctionHouse("Wraith Agent's Greaves", 51000,1);
- buyFromAuctionHouse("Brave Aeon's Breeches", 51000,1);
- buyFromAuctionHouse("Brave Aeon's Belt", 51000,1);
- buyFromAuctionHouse("Brave Aeon's Jerkin", 51000,1);
- buyFromAuctionHouse("Sea Witch Sleeves", 51000,1);
- buyFromAuctionHouse("Sea Witch Pants", 51000,1);
- buyFromAuctionHouse("Sea Witch Sash", 51000,1);
- buyFromAuctionHouse("Sea Witch Hood", 51000,1); //Completo
- buyFromAuctionHouse("Sea Witch Gloves", 51000,1);
- buyFromAuctionHouse("Sea Witch Shirt", 51000,1);
- buyFromAuctionHouse("Sea Witch Shoes", 51000,1);
- //Armas
- buyFromAuctionHouse("Castaways' Vortex", 80000,1);
- buyFromAuctionHouse("Red Dusk Pardon", 80000,1);
- buyFromAuctionHouse("Moon-Eater Lion", 80000,1);
- buyFromAuctionHouse("Brilliant Knight Olivier", 80000,1);
- buyFromAuctionHouse("Splitting Earth", 80000,1);
- buyFromAuctionHouse("God's Foe", 80000,1);
- buyFromAuctionHouse("Nature's Fury: Tsunami", 80000,1);
- buyFromAuctionHouse("Castaways' Vortex", 80000,1);
- // add more items here
- }
- }
- catch (Exception e)
- {
- if (e.GetType() != typeof(System.Threading.ThreadAbortException))
- {
- Log(DateTime.Now.ToShortTimeString() +" ERROR " +GetLastError().ToString() +" " +e.GetType().ToString() +" " +e.StackTrace);
- Log(e.Message);
- }
- }
- }
- //Call on plugin stop
- public void PluginStop()
- {
- Log(DateTime.Now.ToShortTimeString() + " > ----- Open Auction House stopped -----");
- }
- ////////// no variables to edit below this line /////////////
- //buyout an auction house item
- public void buyFromAuctionHouse(string mySearchText, int maxprice, int minamount) // maxprice per item in copper, 1g = 1 00 00 copper
- {
- AuctionRequestParams req = new AuctionRequestParams(AuctionCategory.Off, 0, 0, mySearchText, false, ItemGrade.Common, AuctionSortType.Time, SortOrder.Asc);
- int pip; // per item price
- bool bidreturn;
- List<AuctionItem> items = getAuctionBuyList(req, 0);
- if(items != null)
- {
- foreach (AuctionItem item in items)
- {
- if (!item.item.name.Equals(mySearchText)) // auctionitem item name must match the searchText
- continue;
- if (Convert.ToInt32(item.time) > waitSecondsForAuctionEnd)
- {
- pip = (int)item.buyBackPrice / item.item.count;
- if (item.item.count < minamount || item.buyBackPrice == 0 || pip > maxprice)
- continue;
- if (me.goldCount >= item.buyBackPrice)
- {
- Thread.Sleep(100 + r.Next(150));
- bidreturn = item.MakeAuctionBid(item.buyBackPrice);
- Thread.Sleep(1000 + r.Next(500));
- if (bidreturn)
- Log(DateTime.Now.ToShortTimeString() + " > Attempting to BUYOUT " + item.item.count + " " + item.item.name + " with per item price " + pip.ToString() + " ... succeeded !");
- else
- Log(DateTime.Now.ToShortTimeString() + " > Attempting to BUYOUT " + item.item.count + " " + item.item.name + " with per item price " + pip.ToString() + " ... failed.");
- }
- else
- Log(DateTime.Now.ToShortTimeString() + " > not enough gold to buyout " + item.item.count + " " + item.item.name + " for " + item.buyBackPrice);
- }
- else // auction items time is nearly over, check if we want to bid on it
- {
- pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
- if (pip + overbidamount <= maxprice && item.item.count >= minamount) // check if this is an item below maxprice
- {
- bidOnAuctionHouse(req, item.uniqId, maxprice);
- break;
- }
- }
- }
- }
- else
- {
- Log(DateTime.Now.ToShortTimeString() + " > " +GetLastError().ToString() +" Error ... will try again");
- }
- Thread.Sleep(2000 + r.Next(3000)); // Random sleep 2-5s
- }
- public void bidOnAuctionHouse(AuctionRequestParams req, ulong itemId, int maxprice)
- {
- int pip; // per item price
- int myBidAmount;
- int sleepTime;
- bool bidreturn;
- List<AuctionItem> items = getAuctionBuyList(req, 9);
- foreach (AuctionItem item in items)
- {
- if (item.uniqId == itemId)
- {
- pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
- if (pip + overbidamount <= maxprice)
- {
- sleepTime = Convert.ToInt32(item.time) * 1000 - Convert.ToInt32(r.Next(500)) - msToBidBeforeAuctionEnd;
- Log(DateTime.Now.ToShortTimeString() + " > waiting " + ((int)sleepTime / 1000).ToString() + " seconds to attempt a last-second-bid on " + item.item.count + " " + item.item.name + " (current bid price per item: " + pip + " maxprice: " +maxprice +")");
- if (sleepTime > 100)
- Thread.Sleep(sleepTime);
- break;
- }
- else
- return; // the item has become too expensive
- }
- }
- items = getAuctionBuyList(req, 9);
- foreach (AuctionItem item in items)
- {
- if (item.uniqId == itemId)
- {
- pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
- if (pip + overbidamount <= maxprice)
- {
- myBidAmount = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) + overbidamount;
- if (me.goldCount >= myBidAmount)
- {
- bidreturn = item.MakeAuctionBid(myBidAmount);
- Thread.Sleep(1000 + r.Next(500));
- if (bidreturn)
- Log(DateTime.Now.ToShortTimeString() + " > Successfully sent a BID on " + item.item.count + " " + item.item.name + " with " + myBidAmount + " (pip: " + (myBidAmount/item.item.count) + ")");
- else
- Log(DateTime.Now.ToShortTimeString() + " > Failed to send a BID on " + item.item.count + " " + item.item.name + " with " + myBidAmount + " (pip: " +(myBidAmount/item.item.count) +")");
- }
- else
- Log(DateTime.Now.ToShortTimeString() + " > not enough gold to bid on " + item.item.count + " " + item.item.name + " with " + myBidAmount);
- }
- else
- return; // the item has become too expensive
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement