Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.01 KB | None | 0 0
  1. package scripts.scripts.dropPartyLooter;
  2.  
  3. import java.awt.*;
  4. import java.util.Set;
  5.  
  6. import org.tribot.api.General;
  7. import org.tribot.api2007.Player;
  8. import org.tribot.api2007.Projection;
  9. import org.tribot.api2007.types.RSCharacter;
  10. import org.tribot.script.Script;
  11. import org.tribot.script.ScriptManifest;
  12. import org.tribot.script.interfaces.Ending;
  13. import org.tribot.script.interfaces.Painting;
  14.  
  15. import scripts.scripts.dropPartyLooter.util.ItemSpawn;
  16. import scripts.scripts.dropPartyLooter.util.TileControl;
  17.  
  18. @ScriptManifest(authors = {"Dorkinator"}, name = "dp looter", description = "", version = 1.0, category = "money making")
  19. public class DropPartyLooter extends Script implements Painting, Ending {
  20. private TileControl tc;
  21. private Thread t;
  22. private RSCharacter c;
  23.  
  24. @Override
  25. public void run() {
  26. setLoginBotState(false);
  27. setAutoResponderState(false);
  28. setRandomSolverState(false);
  29. setPinBotState(false);
  30. General.useAntiBanCompliance(false);
  31. Set<Thread> threadSet = Thread.getAllStackTraces().keySet();
  32. for (Thread s : threadSet) {
  33. System.out.println(s.getName());
  34. if(s.getName().toLowerCase().contains("anti")) {
  35.  
  36. s.suspend();
  37. }
  38. }
  39. if (c == null)
  40. c = Player.getRSPlayer().getInteractingCharacter();
  41.  
  42. if (c != null) {
  43. tc = new TileControl(c);
  44. t = new Thread(tc);
  45. t.start();
  46. }else{
  47. System.out.println("Start the script while following the player who is dropping the items.");
  48. return;
  49. }
  50. while (true) {
  51. General.sleep(50);
  52. }
  53. }
  54.  
  55. @Override
  56. public void onPaint(Graphics g) {
  57. g.setColor(new Color(0, 1, 0, 0.3f));
  58. int tID = 1;
  59. for (ItemSpawn i : tc.getItemList())
  60. if (i != null) {
  61. int tCD = Math.abs(i.cd() - 10);
  62. tID++;
  63. Polygon tile = Projection.getTileBoundsPoly(i.getTile(), 0);
  64. if(tCD > 0 && tCD < 10) {
  65. g.fillPolygon(tile);
  66. g.drawString(tID+":"+tCD,tile.xpoints[0],tile.ypoints[0]);
  67. }
  68. }
  69. g.setColor(new Color(0, 0, 1, 0.1f));
  70. g.fillPolygon(Projection.getTileBoundsPoly(c.getPosition(), 0));
  71.  
  72. }
  73.  
  74. @Override
  75. public void onEnd() {
  76. t.interrupt();
  77. }
  78. }
  79.  
  80. --------------------------------------------------------------------------------------------------------------------------
  81. package scripts.scripts.dropPartyLooter.util;
  82.  
  83. import java.util.Vector;
  84.  
  85. import org.tribot.api.types.generic.Condition;
  86. import org.tribot.api2007.types.RSCharacter;
  87. import org.tribot.api2007.types.RSTile;
  88.  
  89. import scripts.lib.generic.Timing;
  90.  
  91. public class TileControl implements Runnable {
  92. private Vector<ItemSpawn> itemList;
  93. private RSCharacter target;
  94.  
  95. public TileControl(RSCharacter c) {
  96. itemList = new Vector<ItemSpawn>();
  97. this.target = c;
  98. }
  99.  
  100. @Override
  101. public void run() {
  102. while (true) {
  103. if (!isMoving(target)) {
  104. ItemSpawn i = new ItemSpawn(target);
  105. Timing.waitFor(new Condition() {
  106. @Override
  107. public boolean active() {
  108. return isMoving(target);
  109. }
  110. }, 15000);
  111. i.setLeaveTime();
  112. if (i.getTimeOn() > 99)
  113. itemList.add(i);
  114. }
  115. sleep(50);
  116. }
  117. }
  118.  
  119. @SuppressWarnings("unchecked")
  120. public Vector<ItemSpawn> getItemList() {
  121. return (Vector<ItemSpawn>) itemList.clone();
  122. }
  123.  
  124. private void sleep(long mil) {
  125. try {
  126. Thread.sleep(mil);
  127. } catch (InterruptedException e) {
  128. e.printStackTrace();
  129. }
  130. }
  131.  
  132. /**
  133. * Checks if the target player is moving
  134. *
  135. * @param target target player
  136. * @return true if they're moving false otherwise
  137. */
  138. private boolean isMoving(RSCharacter target) {
  139. if (target == null)
  140. return false;
  141. final RSTile tmp = target.getAnimablePosition();
  142. final RSTile tile = new RSTile(tmp.getX(), tmp.getY(), tmp.getPlane());
  143. return Timing.waitFor(new Condition() {
  144. @Override
  145. public boolean active() {
  146. return (tmp.getX() != tile.getX() || tmp.getY() != tile.getY());
  147. }
  148.  
  149. }, 100);
  150. }
  151. }
  152.  
  153. -------------------------------------------------------------------------------------------------------------------------
  154. package scripts.scripts.dropPartyLooter.util;
  155.  
  156. import org.tribot.api2007.types.RSCharacter;
  157. import org.tribot.api2007.types.RSTile;
  158.  
  159. public class ItemSpawn {
  160. private long enterTime;
  161. private long leaveTime = 0;
  162. private RSTile tile;
  163.  
  164. public ItemSpawn(RSCharacter tar) {
  165. this.enterTime = System.currentTimeMillis();
  166. this.tile = new RSTile(tar.getPosition().getX(), tar.getPosition().getY(), tar.getPosition().getPlane());
  167. }
  168.  
  169. public void setLeaveTime() {
  170. this.leaveTime = System.currentTimeMillis();
  171. }
  172.  
  173. public int getTimeOn() {
  174. return (int) (leaveTime - enterTime);
  175. }
  176.  
  177. public boolean hasSpawned() {
  178. return System.currentTimeMillis() >= (enterTime + (58000));
  179. }
  180.  
  181. public boolean drawSquare() {
  182. return System.currentTimeMillis() >= (enterTime + (50000));
  183. }
  184. public int cd(){
  185. return (int)(System.currentTimeMillis() - (enterTime + 58000))/1000;
  186. }
  187.  
  188. public boolean shouldLeave() {
  189. return System.currentTimeMillis() >= (leaveTime + (60000));
  190. }
  191.  
  192. public RSTile getTile() {
  193. return this.tile;
  194. }
  195.  
  196. public boolean hover() {
  197. if (tile.hover())
  198. return true;
  199. return false;
  200. }
  201.  
  202. public boolean leftSet() {
  203. return leaveTime > 0;
  204. }
  205.  
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement