Advertisement
lazyy

Untitled

Dec 10th, 2020
6,561
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.03 KB | None | 0 0
  1. package Chinchompa;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import java.text.DecimalFormat;
  6. import java.util.concurrent.TimeUnit;
  7.  
  8. import net.runelite.api.coords.WorldPoint;
  9. import simple.hooks.filters.SimpleSkills.Skills;
  10. import simple.hooks.scripts.Category;
  11. import simple.hooks.scripts.ScriptManifest;
  12. import simple.hooks.simplebot.ChatMessage;
  13. import simple.hooks.wrappers.SimpleGroundItem;
  14. import simple.hooks.wrappers.SimpleItem;
  15. import simple.hooks.wrappers.SimpleObject;
  16. import simple.robot.script.Script;
  17. import simple.robot.utils.ScriptUtils;
  18.  
  19. @ScriptManifest(author = "Nate/Trester", category = Category.HUNTER, description = "Start near chins with boxes in inv, rework by Trester",
  20. discord = "Nathan#6809 | Loreen#4582", name = "Amazing Chins v2", servers = { "Zaros" }, version = "0.1")
  21.  
  22. public class Main extends Script{
  23.  
  24. public final int BOX_TRAP_ITEM = 10008;
  25. public WorldPoint startingTile;
  26. public DecimalFormat formatter= new DecimalFormat("#,###,###,###");
  27. public String status;
  28. public int startExperience;
  29. public int chinsGained;
  30. public long startTime;
  31. public long timeRan;
  32.  
  33. private WorldPoint[] locs;
  34.  
  35. @Override
  36. public void paint(Graphics g) {
  37. timeRan = System.currentTimeMillis() - startTime;
  38. g.setColor(Color.BLACK);
  39. g.fillRect(5, 230, 200, 70);
  40. g.setColor(Color.ORANGE);
  41. g.drawRect(5, 230, 200, 70);
  42. g.drawString("Nate Chins - trester rework", 7, 245);
  43. g.drawString("Time Ran: " + ft(timeRan), 7, 260);
  44. g.drawString("Exp: " + formatter.format(this.getGainedXP()) + " (" + formatter.format(ScriptUtils.getValuePerHour(startTime, System.currentTimeMillis(), getGainedXP())) + ")", 7, 275);
  45. g.drawString("Chins: " + formatter.format(this.getGainedChins()) + " (" + formatter.format(ScriptUtils.getValuePerHour(startTime, System.currentTimeMillis(), getGainedChins())) + ")", 7, 290);
  46.  
  47. }
  48.  
  49. @Override
  50. public void onChatMessage(ChatMessage arg0) {
  51. // TODO Auto-generated method stub
  52.  
  53. }
  54.  
  55. @Override
  56. public void onExecute() {
  57. //ctx.updateStatus("Starting Perfect Chin Catcher");
  58. startTime = System.currentTimeMillis();
  59. chinsGained = 0;
  60. startExperience = ctx.skills.experience(Skills.HUNTER);
  61. startingTile = ctx.players.getLocal().getLocation();
  62. int p = ctx.players.getLocal().getLocation().getPlane();
  63. locs = new WorldPoint[] {
  64. new WorldPoint(startingTile.getX(), startingTile.getY(), p),
  65. new WorldPoint(startingTile.getX() - 1, startingTile.getY() + 1, p),
  66. new WorldPoint(startingTile.getX() + 1, startingTile.getY() + 1, p),
  67. new WorldPoint(startingTile.getX() + 1, startingTile.getY() - 1, p),
  68. new WorldPoint(startingTile.getX() - 1, startingTile.getY() - 1, p)
  69. };
  70. }
  71.  
  72. @Override
  73. public void onProcess() {
  74. if(ctx.players.getLocal().getAnimation() != -1){
  75. ctx.onCondition(() -> ctx.players.getLocal().getAnimation() == -1, 200,10);
  76. ctx.sleep(500);
  77. return;
  78. }
  79. //ctx.updateStatus("Scanning for Traps");
  80. SimpleGroundItem floorTrap = ctx.groundItems.populate().filter(BOX_TRAP_ITEM).nearest().next();
  81. if(floorTrap != null && floorTrap.validateInteractable()){
  82. //ctx.updateStatus("Picking up broken trap");
  83. int trapAm = ctx.inventory.populate().filter(BOX_TRAP_ITEM).population();
  84. if(floorTrap.click("lay")){
  85. ctx.sleep(1000);
  86. ctx.onCondition(() -> ctx.inventory.populate().filter(BOX_TRAP_ITEM).population() > trapAm,250,5);
  87. }
  88. return;
  89. }
  90. WorldPoint trapTile = getAvailableTrapLocation();
  91. if(placedTraps() != trapAmount() && trapTile != null) {
  92. //ctx.updateStatus("Trap is in inventory");
  93. SimpleItem invTrap = ctx.inventory.populate().filter(BOX_TRAP_ITEM).next();
  94.  
  95. if(invTrap != null && trapTile != null){
  96.  
  97. if(!ctx.players.getLocal().getLocation().equals(trapTile)){
  98. //ctx.updateStatus("Walking to available trap spot");
  99. ctx.pathing.step(trapTile.getX(),trapTile.getY());
  100. ctx.onCondition(()-> ctx.players.getLocal().getLocation().equals(trapTile),200,10);
  101. }
  102. if(ctx.players.getLocal().getLocation().equals(trapTile)){
  103. //ctx.updateStatus("Setting up trap");
  104. setupTrap(invTrap, trapTile);
  105. }
  106. } else {
  107. //System.out.println("Shit is nulled");
  108. }
  109. } else {
  110. // //ctx.updateStatus("Scanning ground objects for traps");
  111. SimpleObject trap = ctx.objects.populate().filter(9382,9385,9384).filter(t -> objectInLocation(t.getLocation())).next();
  112. if(trap != null && trap.validateInteractable()){
  113. // //ctx.updateStatus("Resetting traps");
  114. int chins = getChinCount();
  115. if(trap.click("Reset")){
  116. if(trap.getName().toLowerCase().equals("shaking box") && ctx.onCondition(()-> getChinCount() > chins,250,10)){
  117. chinsGained++;
  118. }
  119. ctx.onCondition(()-> !trapExistsForTile(trap.getLocation()));
  120. }
  121. }
  122. }
  123. }
  124.  
  125. private boolean objectInLocation(WorldPoint w)
  126. {
  127. for (int i = 0; i < locs.length; i++) {
  128. if (w.distanceTo(locs[i]) == 0) {
  129. return true;
  130. }
  131. }
  132. return false;
  133. }
  134.  
  135. public WorldPoint getAvailableTrapLocation(){
  136. for (int i = 0; i < trapAmount(); i++) {
  137. WorldPoint loc = locs[i];
  138. if (!trapExistsForTile(loc)) {
  139. return loc;
  140. }
  141. }
  142. return null;
  143. }
  144.  
  145. public int trapAmount() {
  146. final int level = ctx.skills.level(Skills.HUNTER);
  147. if (level >= 80) {
  148. return 5;
  149. } else if (level >= 60) {
  150. return 4;
  151. } else if (level >= 40) {
  152. return 3;
  153. } else if (level >= 20) {
  154. return 2;
  155. }
  156. return 1;
  157. }
  158.  
  159. public int getGainedXP() {
  160. return this.ctx.skills.experience(Skills.HUNTER) - startExperience;
  161. }
  162.  
  163. public int getGainedChins() {
  164. return chinsGained;
  165. }
  166.  
  167. public int getChinCount() {
  168. return ctx.inventory.populate().filter("chinchompa", "red chinchompa", "black chinchompa").population(true);
  169. }
  170.  
  171. public void setupTrap(final SimpleItem invTrap, final WorldPoint tile) {
  172. if (invTrap.click(1)) {
  173. ctx.sleepCondition(() -> this.trapExistsForTile(tile));
  174. }
  175. }
  176.  
  177. public boolean trapExistsForTile(final WorldPoint tile) {
  178. return !ctx.objects.populate().filter(9380, 9382,9385,9384).filter(tile).isEmpty();
  179. }
  180.  
  181. public int placedTraps() {
  182. int count = 0;
  183. for (int i = 0; i < trapAmount(); i++) {
  184. WorldPoint loc = locs[i];
  185. if (trapExistsForTile(loc)) {
  186. count++;
  187. }
  188. }
  189. return count;
  190. }
  191.  
  192. @Override
  193. public void onTerminate() {
  194. // TODO Auto-generated method stub
  195.  
  196. }
  197.  
  198. private String ft(long duration) {
  199. String res = "";
  200. long days = TimeUnit.MILLISECONDS.toDays(duration);
  201. long hours = TimeUnit.MILLISECONDS.toHours(duration)
  202. - TimeUnit.DAYS.toHours(TimeUnit.MILLISECONDS.toDays(duration));
  203. long minutes = TimeUnit.MILLISECONDS.toMinutes(duration)
  204. - TimeUnit.HOURS.toMinutes(TimeUnit.MILLISECONDS
  205. .toHours(duration));
  206. long seconds = TimeUnit.MILLISECONDS.toSeconds(duration)
  207. - TimeUnit.MINUTES.toSeconds(TimeUnit.MILLISECONDS
  208. .toMinutes(duration));
  209. if (days == 0) {
  210. res = (hours + ":" + minutes + ":" + seconds);
  211. } else {
  212. res = (days + ":" + hours + ":" + minutes + ":" + seconds);
  213. }
  214. return res;
  215.  
  216. }
  217.  
  218. }
  219.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement