Advertisement
Guest User

lala

a guest
Nov 26th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 13.47 KB | None | 0 0
  1. using System;
  2. using System.Drawing;
  3. using System.Threading;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using ArcheBuddy.Bot.Classes;
  7.  
  8. namespace OpenAuctionHouse
  9. {
  10. public class OpenAuctionHouse : Core
  11. {
  12. private int overbidamount = 40; // attempt to bid 40c above current bid
  13. private int waitSecondsForAuctionEnd = 300; // if a bid item is at < 3 minutes wait for it to end
  14. private int msToBidBeforeAuctionEnd = 5000; // wait until timeleft = 5 seconds until bidding myself
  15.  
  16. private Random r = new Random();
  17. public static string GetPluginAuthor()
  18. {
  19. return "lypnn";
  20. }
  21.  
  22. public static string GetPluginVersion()
  23. {
  24. return "2.3.0.0";
  25. }
  26.  
  27. public static string GetPluginDescription()
  28. {
  29. return "Open Auction House";
  30. }
  31.  
  32. //Call on plugin start
  33. public void PluginRun()
  34. {
  35. try
  36. {
  37. Log(DateTime.Now.ToShortTimeString() + " > ----- Open Auction House started -----");
  38.  
  39. while (true)
  40. { //Armaduras
  41. buyFromAuctionHouse("Prospector's Wanderlust Breeches", 51000,1);
  42. buyFromAuctionHouse("Prospector's Wanderlust Cap", 51000,1);
  43. buyFromAuctionHouse("Prospector's Wanderlust Jerkin", 51000,1);
  44. buyFromAuctionHouse("Prospector's Wanderlust Guards", 51000,1); //COmpleto
  45. buyFromAuctionHouse("Prospector's Wanderlust Boots", 51000,1);
  46. buyFromAuctionHouse("Prospector's Wanderlust Belt", 51000,1);
  47. buyFromAuctionHouse("Prospector's Wanderlust Fists", 51000,1);
  48.  
  49.  
  50. buyFromAuctionHouse("Dawn Witch's Shoes", 51000, 1);
  51. buyFromAuctionHouse("Dawn Witch Hood", 51000, 1);
  52. buyFromAuctionHouse("Dawn Witch Pants", 51000, 1);
  53. buyFromAuctionHouse("Dawn Witch Sleeves", 51000, 1);
  54. buyFromAuctionHouse("Dawn Witch Gloves", 51000, 1); //Completo
  55. buyFromAuctionHouse("Dawn Witch Sash", 51000, 1);
  56. buyFromAuctionHouse("Dawn Witch Shirt", 51000, 1);
  57.  
  58. buyFromAuctionHouse("Silent Forest Cap", 51000, 1);
  59. buyFromAuctionHouse("Silent Forest Fists", 51000, 1);
  60. buyFromAuctionHouse("Silent Forest Breeches", 51000, 1); //Completo
  61. buyFromAuctionHouse("Silent Forest Jerkin", 51000, 1);
  62. buyFromAuctionHouse("Silent Forest Boots", 51000, 1);
  63. buyFromAuctionHouse("Silent Forest Belt", 51000, 1);
  64. buyFromAuctionHouse("Silent Forest Guards", 51000, 1);
  65.  
  66. buyFromAuctionHouse("Peace Keeping Sabatons", 51000, 1);
  67. buyFromAuctionHouse("Peace Keeping Gauntlets", 51000, 1);
  68. buyFromAuctionHouse("Peace Keeping Tassets", 51000, 1);
  69. buyFromAuctionHouse("Peace Keeping Helm", 51000, 1);
  70. buyFromAuctionHouse("Peace Keeping Cuirass", 51000, 1); //Completo
  71. buyFromAuctionHouse("Peace Keeping Vambraces", 51000, 1);
  72. buyFromAuctionHouse("Peace Keeping Greaves", 51000, 1);
  73.  
  74. buyFromAuctionHouse("Knotted Hell Gloves", 51000,1);
  75. buyFromAuctionHouse("Knotted Hell Hood", 51000,1);
  76. buyFromAuctionHouse("Knotted Hell Pants", 51000,1);
  77. buyFromAuctionHouse("Knotted Hell Shoes", 51000,1) ; //Completo
  78. buyFromAuctionHouse("Knotted Hell Sash", 51000,1) ;
  79. buyFromAuctionHouse("Knotted Hell Shirt", 51000,1);
  80. buyFromAuctionHouse("Knotted Hell Sleeves", 51000,1) ;
  81.  
  82. buyFromAuctionHouse("Crescent Throne Hood", 51000,1);
  83. buyFromAuctionHouse("Crescent Throne Sash", 51000,1);
  84. buyFromAuctionHouse("Faded Crescent Shirt", 51000,1);
  85. buyFromAuctionHouse("Faded Crescent Shoes", 51000,1);
  86. buyFromAuctionHouse("Faded Crescent Gloves", 51000,1);
  87.  
  88. buyFromAuctionHouse("Misty Dusk Boots", 51000,1);
  89. buyFromAuctionHouse("Misty Dusk Guards", 51000,1);
  90. buyFromAuctionHouse("Misty Dusk Jerkin", 51000,1);
  91. buyFromAuctionHouse("Misty Dusk Cap", 51000,1);
  92. buyFromAuctionHouse("Misty Dusk Breeches", 51000,1);
  93.  
  94. buyFromAuctionHouse("Wraith Agent's Helm", 51000,1);
  95. buyFromAuctionHouse("Wraith Agent's Tassets", 51000,1);
  96. buyFromAuctionHouse("Wraith Agent's Sabatons", 51000,1);
  97. buyFromAuctionHouse("Wraith Agent's Cuirass", 51000,1);
  98. buyFromAuctionHouse("Wraith Agent's Greaves", 51000,1);
  99.  
  100.  
  101. buyFromAuctionHouse("Brave Aeon's Breeches", 51000,1);
  102. buyFromAuctionHouse("Brave Aeon's Belt", 51000,1);
  103. buyFromAuctionHouse("Brave Aeon's Jerkin", 51000,1);
  104.  
  105. buyFromAuctionHouse("Sea Witch Sleeves", 51000,1);
  106. buyFromAuctionHouse("Sea Witch Pants", 51000,1);
  107. buyFromAuctionHouse("Sea Witch Sash", 51000,1);
  108. buyFromAuctionHouse("Sea Witch Hood", 51000,1); //Completo
  109. buyFromAuctionHouse("Sea Witch Gloves", 51000,1);
  110. buyFromAuctionHouse("Sea Witch Shirt", 51000,1);
  111. buyFromAuctionHouse("Sea Witch Shoes", 51000,1);
  112.  
  113.  
  114. //Armas
  115. buyFromAuctionHouse("Castaways' Vortex", 80000,1);
  116. buyFromAuctionHouse("Red Dusk Pardon", 80000,1);
  117. buyFromAuctionHouse("Moon-Eater Lion", 80000,1);
  118. buyFromAuctionHouse("Brilliant Knight Olivier", 80000,1);
  119. buyFromAuctionHouse("Splitting Earth", 80000,1);
  120. buyFromAuctionHouse("God's Foe", 80000,1);
  121. buyFromAuctionHouse("Nature's Fury: Tsunami", 80000,1);
  122. buyFromAuctionHouse("Castaways' Vortex", 80000,1);
  123.  
  124. // add more items here
  125. }
  126. }
  127. catch (Exception e)
  128. {
  129. if (e.GetType() != typeof(System.Threading.ThreadAbortException))
  130. {
  131. Log(DateTime.Now.ToShortTimeString() +" ERROR " +GetLastError().ToString() +" " +e.GetType().ToString() +" " +e.StackTrace);
  132. Log(e.Message);
  133. }
  134. }
  135. }
  136.  
  137. //Call on plugin stop
  138. public void PluginStop()
  139. {
  140. Log(DateTime.Now.ToShortTimeString() + " > ----- Open Auction House stopped -----");
  141. }
  142.  
  143. ////////// no variables to edit below this line /////////////
  144.  
  145. //buyout an auction house item
  146. public void buyFromAuctionHouse(string mySearchText, int maxprice, int minamount) // maxprice per item in copper, 1g = 1 00 00 copper
  147. {
  148. AuctionRequestParams req = new AuctionRequestParams(AuctionCategory.Off, 0, 0, mySearchText, false, ItemGrade.Common, AuctionSortType.Time, SortOrder.Asc);
  149. int pip; // per item price
  150. bool bidreturn;
  151.  
  152. List<AuctionItem> items = getAuctionBuyList(req, 0);
  153. if(items != null)
  154. {
  155. foreach (AuctionItem item in items)
  156. {
  157. if (!item.item.name.Equals(mySearchText)) // auctionitem item name must match the searchText
  158. continue;
  159.  
  160. if (Convert.ToInt32(item.time) > waitSecondsForAuctionEnd)
  161. {
  162. pip = (int)item.buyBackPrice / item.item.count;
  163.  
  164. if (item.item.count < minamount || item.buyBackPrice == 0 || pip > maxprice)
  165. continue;
  166.  
  167. if (me.goldCount >= item.buyBackPrice)
  168. {
  169. Thread.Sleep(100 + r.Next(150));
  170. bidreturn = item.MakeAuctionBid(item.buyBackPrice);
  171. Thread.Sleep(1000 + r.Next(500));
  172. if (bidreturn)
  173. Log(DateTime.Now.ToShortTimeString() + " > Attempting to BUYOUT " + item.item.count + " " + item.item.name + " with per item price " + pip.ToString() + " ... succeeded !");
  174. else
  175. Log(DateTime.Now.ToShortTimeString() + " > Attempting to BUYOUT " + item.item.count + " " + item.item.name + " with per item price " + pip.ToString() + " ... failed.");
  176. }
  177. else
  178. Log(DateTime.Now.ToShortTimeString() + " > not enough gold to buyout " + item.item.count + " " + item.item.name + " for " + item.buyBackPrice);
  179. }
  180. else // auction items time is nearly over, check if we want to bid on it
  181. {
  182. pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
  183. if (pip + overbidamount <= maxprice && item.item.count >= minamount) // check if this is an item below maxprice
  184. {
  185. bidOnAuctionHouse(req, item.uniqId, maxprice);
  186. break;
  187. }
  188. }
  189. }
  190. }
  191. else
  192. {
  193. Log(DateTime.Now.ToShortTimeString() + " > " +GetLastError().ToString() +" Error ... will try again");
  194. }
  195. Thread.Sleep(2000 + r.Next(3000)); // Random sleep 2-5s
  196. }
  197. public void bidOnAuctionHouse(AuctionRequestParams req, ulong itemId, int maxprice)
  198. {
  199. int pip; // per item price
  200. int myBidAmount;
  201. int sleepTime;
  202. bool bidreturn;
  203.  
  204. List<AuctionItem> items = getAuctionBuyList(req, 9);
  205. foreach (AuctionItem item in items)
  206. {
  207. if (item.uniqId == itemId)
  208. {
  209. pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
  210. if (pip + overbidamount <= maxprice)
  211. {
  212. sleepTime = Convert.ToInt32(item.time) * 1000 - Convert.ToInt32(r.Next(500)) - msToBidBeforeAuctionEnd;
  213. 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 +")");
  214. if (sleepTime > 100)
  215. Thread.Sleep(sleepTime);
  216. break;
  217. }
  218. else
  219. return; // the item has become too expensive
  220. }
  221. }
  222.  
  223. items = getAuctionBuyList(req, 9);
  224. foreach (AuctionItem item in items)
  225. {
  226. if (item.uniqId == itemId)
  227. {
  228. pip = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) / item.item.count;
  229. if (pip + overbidamount <= maxprice)
  230. {
  231. myBidAmount = (item.bidMoney != 0 ? item.bidMoney : item.sellPrice) + overbidamount;
  232. if (me.goldCount >= myBidAmount)
  233. {
  234. bidreturn = item.MakeAuctionBid(myBidAmount);
  235. Thread.Sleep(1000 + r.Next(500));
  236. if (bidreturn)
  237. Log(DateTime.Now.ToShortTimeString() + " > Successfully sent a BID on " + item.item.count + " " + item.item.name + " with " + myBidAmount + " (pip: " + (myBidAmount/item.item.count) + ")");
  238. else
  239. Log(DateTime.Now.ToShortTimeString() + " > Failed to send a BID on " + item.item.count + " " + item.item.name + " with " + myBidAmount + " (pip: " +(myBidAmount/item.item.count) +")");
  240. }
  241. else
  242. Log(DateTime.Now.ToShortTimeString() + " > not enough gold to bid on " + item.item.count + " " + item.item.name + " with " + myBidAmount);
  243. }
  244. else
  245. return; // the item has become too expensive
  246. }
  247. }
  248. }
  249. }
  250. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement