Advertisement
Guest User

ok_StarterThiever

a guest
Dec 7th, 2013
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.25 KB | None | 0 0
  1. package scripts;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6.  
  7. import org.tribot.api.DynamicClicking;
  8. import org.tribot.api.General;
  9. import org.tribot.api.Timing;
  10. import org.tribot.api.input.Mouse;
  11. import org.tribot.api.types.generic.Condition;
  12. import org.tribot.api2007.Camera;
  13. import org.tribot.api2007.GameTab;
  14. import org.tribot.api2007.GameTab.TABS;
  15. import org.tribot.api2007.Login;
  16. import org.tribot.api2007.NPCs;
  17. import org.tribot.api2007.Player;
  18. import org.tribot.api2007.Screen;
  19. import org.tribot.api2007.Skills;
  20. import org.tribot.api2007.Walking;
  21. import org.tribot.api2007.types.RSNPC;
  22. import org.tribot.api2007.types.RSTile;
  23. import org.tribot.script.Script;
  24. import org.tribot.script.ScriptManifest;
  25. import org.tribot.script.interfaces.Painting;
  26. import org.tribot.script.interfaces.Pausing;
  27.  
  28. @ScriptManifest(authors = { "Okokokok" }, category = "ok_StarterPack", name = "ok_StarterThiever")
  29. public class ok_StarterThiever extends Script implements Painting, Pausing {
  30.  
  31.  
  32. private final double version = 1.00;
  33.  
  34. boolean paused;
  35.  
  36. public RSArea thievingArea = new RSArea(new RSTile(3213, 3206, 0), new RSTile(3232, 3232, 0));
  37.  
  38. private final String manName = "Man",
  39. manThief = "Pickpocket";
  40.  
  41.  
  42. // MISC METHODS
  43.  
  44. public boolean waitFor(Condition c, long timeout) {
  45. Timer t = new Timer(timeout);
  46. while (t.isRunning()) {
  47. if (c.active()) {
  48. return true;
  49. }
  50. sleep(60, 80);
  51. }
  52. return false;
  53. }
  54.  
  55. public boolean loggedOut() {
  56. return (Login.getLoginState() == Login.STATE.LOGINSCREEN)
  57. && (!Screen.getColorAt(100, 200).equals(new Color(0, 0, 0)));
  58. }
  59.  
  60. public boolean logout() {
  61. if (Login.getLoginState() == Login.STATE.INGAME)
  62. {
  63. Login.logout();
  64. for(int x = 0; x < 6; x++)
  65. {
  66. if(loggedOut())
  67. {
  68. return true;
  69. }
  70. sleep(490,510);
  71. }
  72. }
  73. return false;
  74. }
  75.  
  76. public void antiBan(int rotation) {
  77. int number = General.random(1, 500);
  78. sleep(200);
  79. switch (number) {
  80. case 1:
  81. case 2:
  82. case 3:
  83. case 4:
  84. case 5:
  85. Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
  86. break;
  87. case 20:
  88. case 21:
  89. case 22:
  90. case 23:
  91. case 24:
  92. case 25:
  93. case 26:
  94. case 27:
  95. case 28:
  96. case 29:
  97. case 30:
  98. case 31:
  99. Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
  100. sleep(200);
  101. break;
  102. case 50:
  103. GameTab.open(TABS.INVENTORY);
  104. sleep(200);
  105. break;
  106. case 75:
  107. case 76:
  108. break;
  109. case 89:
  110. case 90:
  111. case 91:
  112. case 92:
  113. case 93:
  114. case 94:
  115. Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
  116. sleep(200, 400);
  117. break;
  118. case 95:
  119. case 96:
  120. case 97:
  121. case 98:
  122. case 99:
  123. case 100:
  124. Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
  125. sleep(200, 400);
  126. break;
  127. }
  128. }
  129.  
  130. // THIEVING METHOD
  131.  
  132. private boolean findManOnscreen(){
  133. RSNPC[] man = NPCs.findNearest(manName);
  134. return man != null && man.length > 0 && man[0].isOnScreen();
  135. }
  136.  
  137. private RSTile manTile(){
  138. RSNPC[] man = NPCs.findNearest(manName);
  139. if (man != null && man.length > 0){
  140. return man[0].getPosition();
  141. }
  142. return null;
  143. }
  144.  
  145. private boolean distanceMan(){
  146. RSTile myPos = Player.getPosition();
  147. if (!findManOnscreen()){
  148. if (myPos.distanceTo(manTile()) > 8){
  149. return true;
  150. }
  151. }
  152. return false;
  153. }
  154.  
  155. private void walkMan(){
  156. RSNPC[] man = NPCs.findNearest(manName);
  157. if (man != null && man.length > 0){
  158. if (!distanceMan() && thievingArea.contains(manTile())){
  159. Walking.walkTo(manTile());
  160. }
  161. }
  162. }
  163.  
  164. private void handleStunned(){
  165. if (isStunned()){
  166. sleep (4000, 4400);
  167. }
  168. }
  169.  
  170. public void thiefMethod(){
  171. RSNPC[] man = NPCs.findNearest(manName);
  172. if (man != null && man.length > 0 && man[0].isOnScreen() && !isStunned() && !Player.isMoving()){
  173. if (DynamicClicking.clickRSNPC(man[0], manThief)){
  174. waitFor(new Condition(){
  175. @Override
  176. public boolean active(){
  177. return Player.getAnimation() == -1 || isStunned();
  178. }
  179. }, 10000);
  180. }
  181. }
  182. }
  183.  
  184. // CHECK METHODS
  185.  
  186. private boolean isStunned(){
  187. return Player.getAnimation() == 388;
  188. }
  189.  
  190. private static final long startTime = System.currentTimeMillis();
  191. Font font = new Font("Calibri", Font.BOLD, 16);
  192. private State SCRIPT_STATE = getState();
  193.  
  194.  
  195. @SuppressWarnings("deprecation")
  196. private final int startXP = Skills.getXP("thieving");
  197. private int START_XP;
  198.  
  199. @SuppressWarnings("deprecation")
  200. @Override
  201. public void onPaint(Graphics g) {
  202. RSTile myPos = Player.getPosition();
  203.  
  204. long timeRan = System.currentTimeMillis() - startTime;
  205. double multiplier = timeRan / 3600000D;
  206. int currentLvl = Skills.getActualLevel("thieving");
  207. int xpToNextLvl = Skills.getXPToNextLevel("thieving");
  208. int xpGained = Skills.getXP("thieving") - START_XP;
  209. int pickpockets = xpGained / 8;
  210.  
  211. g.setFont(font);
  212. g.setColor(new Color(255, 255, 255));
  213. g.drawString("ok_StarterThiever V" + version, 558, 220);
  214. g.drawString("Action: " + SCRIPT_STATE, 558, 235);
  215. g.drawString("Time running: " + Timing.msToString(timeRan), 558, 250);
  216.  
  217. g.drawString("XP Gained p/h: " + (int) (xpGained / multiplier), 558, 265);
  218. g.drawString("XP Gained: " + (int) xpGained, 558, 280);
  219. g.drawString("Current level: " + currentLvl, 558, 295);
  220. g.drawString("XP to Next Level: " + xpToNextLvl, 558, 310);
  221.  
  222. if (thievingArea.contains(myPos)){
  223. g.drawString("Pickpockets p/h: " + (int)(pickpockets / multiplier), 558, 325);
  224. g.drawString("Pickpockets done: " + pickpockets, 558, 340);
  225. }
  226. }
  227.  
  228. public enum State{
  229. PICKPOCKETING, WALKING_TO_MAN,
  230. STUNNED, LOGING_OUT,
  231. PAUSING;
  232. }
  233.  
  234. private State getState(){
  235. RSTile myPos = Player.getPosition();
  236. if (paused){
  237. return State.PAUSING;
  238. }
  239. if (thievingArea.contains(myPos)){
  240. if (findManOnscreen() && !isStunned()){
  241. return State.PICKPOCKETING;
  242. }
  243. if (findManOnscreen() && isStunned()){
  244. return State.STUNNED;
  245. }
  246. if (!findManOnscreen() && !isStunned()){
  247. return State.WALKING_TO_MAN;
  248. }
  249. }
  250. return State.LOGING_OUT;
  251. }
  252.  
  253. @SuppressWarnings("deprecation")
  254. @Override
  255. public void run() {
  256. START_XP = startXP;
  257. super.setRandomSolverState(true);
  258. Walking.setControlClick(true);
  259.  
  260. while(true){
  261. if (loggedOut()) {
  262. super.setLoginBotState(active);
  263. } else {
  264. while (!loggedOut()) {
  265. SCRIPT_STATE = getState();
  266. int mSpeed = General.random(180, 200);
  267. Mouse.setSpeed(mSpeed);
  268. Walking.setControlClick(true);
  269.  
  270. switch (SCRIPT_STATE) {
  271.  
  272. case STUNNED:
  273. handleStunned();
  274. break;
  275.  
  276. case LOGING_OUT:
  277. logout();
  278. stopScript();
  279. break;
  280.  
  281. case PICKPOCKETING:
  282. int rotation = General.random(90, 200);
  283. antiBan(rotation);
  284.  
  285. thiefMethod();
  286. break;
  287.  
  288. case WALKING_TO_MAN:
  289. walkMan();
  290. break;
  291.  
  292. case PAUSING:
  293. sleep(100, 200);
  294. }
  295. }
  296. }
  297. }
  298. }
  299.  
  300. @Override
  301. public void onPause() {
  302. paused = true;
  303. while (paused){
  304. sleep(200, 300);
  305. }
  306.  
  307.  
  308. }
  309.  
  310. @Override
  311. public void onResume() {
  312.  
  313. paused = false;
  314. sleep(18000, 20000);
  315. }
  316. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement