Guest User

Untitled

a guest
Oct 16th, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.89 KB | None | 0 0
  1. import static sys.*
  2. import static drunkard.*
  3. import util.AreaWalker
  4.  
  5.  
  6. /************************************************
  7. ***** Start in Northwest Corner *****
  8. ************************************************/
  9.  
  10. /******************************
  11. ** user modifiable variables **
  12. ******************************/
  13.  
  14. flower_stage = 3; //Only need to change for Hemp, leave at 3 for others.
  15. rePlant = 0; // Replant seeds? 1 - Yes , 0 - No
  16. inventory_Size = 30; //Inventory size
  17. use_Cupboards = 0; // Use Cupboards? 1 - Yes , 0 - No
  18. rouse = 0; // 1 - Yes, 0 - No
  19. water = 0; // 1 - Yes, 0 - No
  20. min_Space = 5; //Minimum Space left in inventory
  21. pumpkin=0; //1- yes 0- no needs empty inventory slices&drops pumpkin to ground
  22. /******************************
  23. ** Do not modify below **
  24. ******************************/
  25. masInd = 0;
  26. current_X = 0;
  27. current_Y = 0;
  28. items = -1;
  29. inventory_Space = 90;
  30. buckets = 0;
  31. cb_Items = 0;
  32. waterskins = 0;
  33.  
  34. main();
  35. /******************************
  36. ** Delicious content **
  37. ******************************/
  38.  
  39. void main() {
  40. def a = selectArea("Select area to harvest.")
  41. if (a == null)
  42. return;
  43. def walker = new AreaWalker(a)
  44. for (tile in walker.eachTile()) {
  45. tile_work(tile)
  46. }
  47. }
  48.  
  49. void tile_work(tile)
  50. {
  51. if( Stamina < 65 )
  52. {
  53. print "refill sta"
  54. refill_stam();
  55. print "refill sta end"
  56. }
  57. //TODO
  58. // check_Inventory();
  59. processHarvestTile(tile);
  60. if (rePlant == 1)
  61. {
  62. plantSeed ();
  63. }
  64. if(pumpkin) pumpkinate();
  65. }
  66.  
  67. /********************************************************
  68. ***** HARVESTING/PLANTING *****
  69. ********************************************************/
  70.  
  71. void processHarvestTile(tile)
  72. {
  73. int id;
  74. int stage;
  75. def p = getMyCoord()
  76. id = findMapObject("", 2, tile.tileX - p.tileX, tile.tileY - p.tileY);
  77. if (id > 0) {
  78. stage = getObjectBlob(id, 0);
  79. if (stage >= flower_stage)
  80. {
  81. if (getCursor() != "harvest")
  82. {
  83. sendAction("harvest");
  84. waitCursor("harvest");
  85. }
  86. doClick(id, 1, 0);
  87. waitHourglass();
  88. }
  89. }
  90. if (id < 0) {
  91. stage = getObjectBlob(id, 0);
  92. if (stage >= flower_stage)
  93. {
  94. if (getCursor() != "harvest")
  95. {
  96. sendAction("harvest");
  97. waitCursor("harvest");
  98. }
  99. doClick(id, 1, 0);
  100. waitHourglass();
  101. }
  102. }
  103. }
  104.  
  105.  
  106. void plantSeed() {
  107. def BestItem=null;
  108. int MaxQ=0;
  109. for (item in getInventory("Inventory").getItems()) {
  110. if (isSeed(item)) {
  111. if (item.getQuality()>MaxQ) {
  112. MaxQ=item.getQuality();
  113. BestItem=item;
  114. }
  115. }
  116. }
  117. if (BestItem==null) return;
  118. int ix=BestItem.row;
  119. int iy=BestItem.column;
  120. BestItem.take();
  121. waitDrag();
  122. mapInteractClick(0, 0, 0);
  123. Thread.sleep 100;
  124. // If seed planting failed, return it to inventory
  125. if (hasDragItem())
  126. {
  127. getInventory("Inventory").drop(ix, iy);
  128. }
  129. }
  130.  
  131. static boolean isSeed(item)
  132. {
  133. if (item.isName("carrot") ||
  134. item.isName("peapod") ||
  135. item.isName ("seed-grape") ||
  136. item.isName ("flaxseed") ||
  137. item.isName ("seed-wheat") ||
  138. item.isName ("seed-pumpkin") ||
  139. item.isName ("seed-carrot") ||
  140. item.isName ("seed-pepper") ||
  141. item.isName ("seed-hemp") ||
  142. item.isName ("seed-hops") ||
  143. item.isName ("seed-poppy") ||
  144. item.isName ("seed-tea") ||
  145. (item.isName ("beetroot") && !item.isName ("leaves") && !item.isName ("Weird")))
  146. return true
  147. else
  148. return false
  149. }
  150.  
  151.  
  152. /********************************************************
  153. ***** OTHER *****
  154. ********************************************************/
  155.  
  156. void resetCursor()
  157. {
  158. if (getCursor() != "arw")
  159. {
  160. mapClick(0,0,3,0);
  161. waitCursor("arw");
  162. }
  163. }
  164.  
  165. void refill_stam()
  166. {
  167.  
  168. if( rouse == 1 )
  169. {
  170. say(":rouse");
  171. while(Stamina < 95) Thread.sleep(100);
  172. }
  173. if( water == 1 )
  174. {
  175. resetCursor();
  176. mapAbsClick(getMyCoordX(), getMyCoordY(),1, 0);
  177. drinkWater(true);
  178. while(Stamina < 90) Thread.sleep(100);
  179. }
  180. }
  181.  
  182. void pumpkinate()
  183. {
  184. Thread.sleep(300)
  185. for (item in getInventory("Inventory").getItems())
  186. {
  187. if (item.isName("pumpkin"))
  188. {
  189. item.act()
  190. waitContextMenu().select("Slice")
  191. }
  192. }
  193. Thread.sleep(300)
  194. for (item in getInventory("Inventory").getItems())
  195. {
  196. if (item.isName("flesh")||item.isName("seed"))
  197. {
  198. item.take()
  199. waitDrag()
  200. drop()
  201. }
  202. }
  203.  
  204. }
Add Comment
Please, Sign In to add comment