Advertisement
Guest User

Untitled

a guest
Aug 19th, 2015
253
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.45 KB | None | 0 0
  1. package scripts.mining.essminer;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Graphics2D;
  7. import java.awt.Image;
  8. import java.awt.Point;
  9. import java.util.ArrayList;
  10. import java.util.Iterator;
  11. import java.util.LinkedList;
  12. import java.util.List;
  13.  
  14. import org.tribot.api.General;
  15. import org.tribot.api.Timing;
  16. import org.tribot.api.input.Mouse;
  17. import org.tribot.api2007.Camera;
  18. import org.tribot.api2007.Inventory;
  19. import org.tribot.api2007.Login;
  20. import org.tribot.api2007.Player;
  21. import org.tribot.api2007.Screen;
  22. import org.tribot.api2007.Skills;
  23. import org.tribot.api2007.Walking;
  24. import org.tribot.api2007.WebWalking;
  25. import org.tribot.api2007.types.RSNPC;
  26. import org.tribot.api2007.types.RSObject;
  27. import org.tribot.script.EnumScript;
  28. import org.tribot.script.ScriptManifest;
  29. import org.tribot.script.interfaces.MouseActions;
  30. import org.tribot.script.interfaces.MousePainting;
  31. import org.tribot.script.interfaces.MouseSplinePainting;
  32. import org.tribot.script.interfaces.Painting;
  33.  
  34. import scripts.methods.Methods;
  35.  
  36. /**
  37. * @author Ian
  38. *
  39. */
  40. @ScriptManifest(authors = { "Ian" }, category = "Mining", name = "iEssenceMiner")
  41.  
  42. public class EssMiner extends EnumScript<EssState> implements Painting,
  43. MouseSplinePainting, MousePainting, MouseActions {
  44.  
  45. public static final boolean DEBUG = true; // debug the script
  46.  
  47. private EssState state = null; // state of the script
  48.  
  49. private EssPickaxe pickaxe = null; // pickaxe instance
  50.  
  51. private EssLumbridge lumbridge = null; // lumbridge instance
  52.  
  53. private EssWalking walking = null; // walking instance
  54.  
  55. private EssBanking banking = null; // banking instance
  56.  
  57. private EssData data = null; // data instance
  58.  
  59. private long lastPlayerRan = 0; // time last player ran
  60.  
  61. private long timeout = 0;
  62.  
  63. private final String PAINT_PICTURE_URL = "http://i44.tinypic.com/20h3uwo.png";
  64.  
  65. private final Image PAINT_IMG = Methods.getImage(PAINT_PICTURE_URL);
  66.  
  67.  
  68. @Override
  69. public void onPaint(Graphics g) {
  70. ((Graphics2D)g).drawImage(PAINT_IMG, -40, 310, null);
  71. g.setFont(new Font("Verdana", Font.BOLD, 11));
  72. g.setColor(Color.BLUE);
  73. g.drawString(getState().toString().replaceAll("_", " "), 11, 357);
  74. int totalEssMined = (Skills.getXP(Skills.SKILLS.MINING) - getData().getStartXP()) / 5;
  75. int essPerHr = (int) (totalEssMined / ((System.currentTimeMillis() - getData().getStartTime()) / 3600000D));
  76. g.drawString(totalEssMined + " (" +essPerHr+")", 135, 379);
  77. g.drawString((Skills.getXP(Skills.SKILLS.MINING) - getData().getStartXP()) + " (" + (Skills.getXPToNextLevel(Skills.SKILLS.MINING)) + ")", 105, 402);
  78. g.drawString(getData().getCurrentLevel() + " (" + (getData().getCurrentLevel() - getData().getStartLevel()) + ")", 120, 425);
  79. g.drawString(Timing.msToString(Timing.timeFromMark(getData().getStartTime())), 318, 376);
  80. int tripsPerHr = (int) (getData().getTripCount()/ ((System.currentTimeMillis() - getData().getStartTime()) / 3600000D));
  81. g.drawString(getData().getTripCount() + " (" + tripsPerHr + ")", 268, 395);
  82. g.drawString(Timing.msToString(getData().getLastTripTime()), 333, 412);
  83. g.drawString(Timing.msToString(getData().getAverageTripTime()), 333, 429);
  84. }
  85.  
  86. /**
  87. * Sets the state of the script upon start
  88. */
  89.  
  90. @Override
  91. public EssState getInitialState() {
  92.  
  93. if(getData() == null) {
  94. setData(new EssData(this)); // initialize data instance
  95. }
  96.  
  97. if(getPickaxe() == null) {
  98. setPickaxe(new EssPickaxe(this)); // initialize pickaxe instance
  99. }
  100.  
  101. if(getLumbridge() == null) {
  102. setLumbridge(new EssLumbridge(this)); // initialize lumbridge instance
  103. }
  104.  
  105. if(getWalking() == null) {
  106. setWalking(new EssWalking(this)); // initialize walking instance
  107. }
  108.  
  109. if(getBanking() == null) {
  110. setBanking(new EssBanking(this)); // initialize banking instance
  111. }
  112.  
  113. getData().getInitialData(); // on paint data
  114. Walking.setWalkingTimeout(2000); // set the walking timeout
  115. Mouse.setSpeed(180); // set the mouse speed
  116.  
  117. if(EssConstants.isInsideLumbridgeCastle()) { // check lumbridge area for player position
  118.  
  119. return EssState.WALKING_TO_LUMBRIDGE_BANK; // set walking to lumbridge bank
  120.  
  121. } else if(EssConstants.isInsideBank()) { // check bank area for player position
  122.  
  123. return EssState.BANKING; // set the state banking
  124.  
  125. } else if(EssConstants.isInsideShop()
  126. || EssConstants.isInsideEastVarrock()) { // check shop or east varrock area for player position
  127.  
  128. if(!Inventory.isFull())
  129. return EssState.WALKING_TO_AUBURY; // set walking to aubury if you have inventory spaces
  130. else
  131. return EssState.WALKING_TO_BANK; // set walking to bank if your inventory is full
  132.  
  133. } else if(EssConstants.isInsideMine()) { // check mine area for player position
  134.  
  135. if(Inventory.isFull())
  136. return EssState.WALKING_TO_PORTAL; // set walking to portal if inventory is full
  137. else
  138. return EssState.WALKING_TO_ESSENCE; // set walking to essence if you have inventory spaces
  139.  
  140. } else
  141.  
  142. return EssState.BANKING; // set banking
  143. }
  144.  
  145. private boolean endScript = false;
  146.  
  147. public LoginState LoginState() {
  148.  
  149. if (Screen.getColorAt(98, 129).equals(new Color(0, 0, 0))) {
  150. return LoginState.WORLD_MENU;
  151. } else if (Screen.getColorAt(423, 248).equals(new Color(255, 255, 0))) {
  152. return LoginState.WELCOME_SCREEN;
  153. } else if (Screen.getColorAt(534, 341).equals(new Color(11, 11, 11))) {
  154. return LoginState.LOGIN_SCREEN;
  155. } else if (Screen.getColorAt(382, 323).equals(new Color(255, 255, 255))) {
  156. return LoginState.HOW_TO_PLAY;
  157. } else if (Screen.getColorAt(365, 340).equals(new Color(255, 255, 255))) {
  158. return LoginState.LOBBY;
  159. } else {
  160. return LoginState.ERROR;
  161. }
  162. }
  163.  
  164. @Override
  165. public EssState handleState(EssState state) {
  166. if(isEndScript()) {
  167. Thread.currentThread().interrupt();
  168. return null;
  169. } else if(!isOnBreak() && !isPaused()) {
  170. long t = 0;
  171. switch (LoginState()) {
  172.  
  173. case WELCOME_SCREEN:
  174. case LOGIN_SCREEN:
  175. Login.login();
  176. break;
  177.  
  178. case HOW_TO_PLAY:
  179. Mouse.moveBox(13, 470, 97, 491);
  180. General.sleep(100, 300);
  181. Mouse.click(1);
  182. t = System.currentTimeMillis();
  183. while (Timing.timeFromMark(t) < General.random(7000, 10000) && LoginState().equals(LoginState.HOW_TO_PLAY)) {
  184. General.sleep(300);
  185. }
  186. General.sleep(100);
  187. break;
  188.  
  189. case LOBBY:
  190. Mouse.moveBox(280, 296, 495, 374);
  191. General.sleep(100, 300);
  192. Mouse.click(1);
  193. t = System.currentTimeMillis();
  194. while (Timing.timeFromMark(t) < General.random(7000, 10000) && LoginState().equals(LoginState.LOBBY)) {
  195. General.sleep(300);
  196. }
  197. General.sleep(100);
  198. break;
  199. }
  200. state = getState() != null ? getState() : getInitialState();
  201. getData().setCurrentXp(Skills.getXP(Skills.SKILLS.MINING));
  202. getData().setCurrentLevel(Skills.getActualLevel(Skills.SKILLS.MINING));
  203.  
  204. if(DEBUG)
  205. println(state.toString());
  206.  
  207. switch(state) {
  208.  
  209. case AT_BANK:
  210. case BANKING:
  211. if(EssConstants.isInsideBank()) {
  212. if(getBanking().isCompleted()) {
  213. return EssState.WALKING_TO_AUBURY;
  214. }
  215. }
  216. return EssState.WALKING_TO_BANK;
  217.  
  218. case WALKING_TO_AUBURY:
  219. if(EssConstants.isInsideEastVarrock()) {
  220. if(getWalking().walkToAubury()) {
  221. if(EssConstants.isInsideShop()) {
  222. return EssState.TELEPORTING;
  223. }
  224. }
  225. }
  226. return EssState.WALKING_TO_AUBURY;
  227.  
  228. case TELEPORTING:
  229. if(EssConstants.isInsideShop()) {
  230. teleport();
  231. return EssState.TELEPORTING;
  232. }
  233. if(!EssConstants.isInsideEastVarrock()) {
  234. setState(EssState.WALKING_TO_ESSENCE);
  235. return EssState.WALKING_TO_ESSENCE;
  236. }
  237. return EssState.WALKING_TO_AUBURY;
  238.  
  239. case WALKING_TO_ESSENCE:
  240. if(EssConstants.isInsideShop()) {
  241. setState(EssState.TELEPORTING);
  242. return EssState.TELEPORTING;
  243. }
  244. if(EssConstants.isInsideEastVarrock()) {
  245. setState(EssState.WALKING_TO_AUBURY);
  246. return EssState.WALKING_TO_AUBURY;
  247. }
  248. if(EssConstants.isInsideMine()) {
  249. if(getWalking().walkToEssence()) {
  250. if(getData().getEssenceRock() != null) {
  251. return EssState.MINING_ESSENCE;
  252. }
  253. }
  254. }
  255. return EssState.TELEPORTING;
  256.  
  257. case MINING_ESSENCE:
  258. if(EssConstants.isInsideMine()) {
  259.  
  260. if(mineEssence(getData().getEssenceRock())) {
  261.  
  262. if(Inventory.isFull()) {
  263.  
  264. return EssState.WALKING_TO_PORTAL;
  265.  
  266. }
  267. }
  268. return EssState.WALKING_TO_ESSENCE;
  269. }
  270. return EssState.WALKING_TO_AUBURY;
  271.  
  272. case WALKING_TO_PORTAL:
  273. if(EssConstants.isInsideShop() || EssConstants.isInsideEastVarrock()) {
  274. println(getState().toString() + ": Inside shop or east varrock.");
  275. setState(EssState.WALKING_TO_BANK);
  276. return EssState.WALKING_TO_BANK;
  277. }
  278. if(EssConstants.isInsideMine()) {
  279. //println(getState().toString() + ": Inside essence mine.");
  280. if(getWalking().walkToPortal()) {
  281.  
  282. if(EssConstants.isInsideShop() || EssConstants.isInsideEastVarrock()) {
  283. setState(EssState.WALKING_TO_BANK);
  284. return EssState.WALKING_TO_BANK;
  285.  
  286. }
  287. }
  288. return EssState.WALKING_TO_PORTAL;
  289. }
  290. println(getState().toString() + ": Not inside shop, east varrock, or essence mine.");
  291. setState(EssState.WALKING_TO_BANK);
  292. return EssState.WALKING_TO_BANK;
  293.  
  294. case WALKING_TO_BANK:
  295. if(EssConstants.isInsideEastVarrock()) {
  296.  
  297. if(getWalking().walkToBank()) {
  298.  
  299. if(EssConstants.isInsideBank()) {
  300.  
  301. return EssState.AT_BANK;
  302. }
  303. }
  304. }
  305. return EssState.WALKING_TO_BANK;
  306.  
  307. case WALKING_TO_LUMBRIDGE_BANK:
  308. if(EssConstants.isInsideLumbridgeCastle()) {
  309.  
  310. if(getLumbridge().walkToBank()) {
  311.  
  312. return EssState.AT_BANK;
  313. }
  314. }
  315. return EssState.BANKING;
  316.  
  317. }
  318. }
  319. return null;
  320. }
  321.  
  322. /**
  323. * Teleports using Aubury to the Essence mine
  324. * @return Inside essence mine
  325. */
  326.  
  327. private boolean teleport() {
  328. /*
  329. * Attempt to teleport
  330. */
  331. setTimeout(System.currentTimeMillis());
  332. while(EssConstants.isInsideEastVarrock() && !isTimedOut(7000, 8000)) {
  333.  
  334. if(DEBUG)
  335. println(getState().toString() + ": Teleport loop");
  336.  
  337. /*
  338. * Open blocking shop door
  339. */
  340. if(getWalking().nearClosedDoor()) {
  341. getWalking().openDoor();
  342. }
  343.  
  344. RSNPC aubury = Methods.findNPCByModelPoints(new int[]{EssConstants.AUBURY});
  345. if(aubury != null) {
  346. /*
  347. * Walk to aubury farther than 3 squares away
  348. */
  349. if(!Player.isMoving() && Methods.distanceTo(this, aubury.getPosition()) > 3)
  350. WebWalking.walkTo(aubury);
  351.  
  352. aubury.click("Teleport");
  353.  
  354. /*
  355. * Change state once in the mine
  356. */
  357. if(isFinishedTeleporting(500)) {
  358. setState(EssState.WALKING_TO_ESSENCE);
  359. return true;
  360. }
  361.  
  362. } else {
  363.  
  364. if(DEBUG)
  365. println(getState().toString() + ": AUBURY NULL");
  366.  
  367. }
  368. }
  369. return false;
  370. }
  371.  
  372. /**
  373. * Mines the closest essence rock
  374. * @param essence - RSObject essence rock
  375. * @return full inventory
  376. */
  377.  
  378. public boolean mineEssence(RSObject essence) {
  379. setState(EssState.MINING_ESSENCE);
  380. /*
  381. * Checks if your inventory is full
  382. */
  383. if(isInventoryFull()) {
  384. return true;
  385. }
  386. /*
  387. * Finds a new essence rock if the parameter returns null
  388. */
  389. if(essence == null) {
  390. essence = Methods.findObjectByModelPoints(new int[]{EssConstants.ESSENCE_ROCK});
  391. }
  392. /*
  393. * Checks if the parameter essence rock is the distance
  394. * of the closest essence rock
  395. */
  396. if(!isCorrectDistance(Methods.distanceTo(this, essence.getPosition()))) {
  397. return false;
  398. }
  399.  
  400. Inventory.open();
  401. Camera.turnToTile(essence);
  402.  
  403. /*
  404. * Attempt to click essence rock
  405. */
  406. setTimeout(System.currentTimeMillis());
  407. while(Player.getAnimation() <= -1 && !isTimedOut(4000, 5000)) {
  408. if(DEBUG)
  409. println(getState().toString() + ": no animation loop");
  410. if(essence.getPosition().distanceTo(Player.getPosition()) > 4) {
  411. WebWalking.walkTo(essence);
  412. }
  413. Camera.turnToTile(essence);
  414. essence.click("Mine");
  415. startedMining(2000);
  416. }
  417.  
  418. /*
  419. * Sleep while mining animations are being played
  420. */
  421. setTimeout(System.currentTimeMillis());
  422. while(Player.getAnimation() >= 624 && Player.getAnimation() <= 630 && !isTimedOut(90000, 120000)) {
  423. if(DEBUG)
  424. println(getState().toString() + ": animation loop");
  425. if(isInventoryFull()) {
  426. return true;
  427. }
  428. finishedMining(2000);
  429. }
  430.  
  431. /*
  432. * failsafe, attempt the method again if inventory
  433. * still has spaces and you don't have an animation
  434. */
  435. if(!isInventoryFull() && Player.getAnimation() <= -1) {
  436. return mineEssence(essence);
  437. }
  438.  
  439. return false;
  440. }
  441.  
  442. /**
  443. *
  444. * @param object - RSObject portal
  445. * @param npc - RSNPC portal
  446. * @return Used portal successfully
  447. */
  448.  
  449. public boolean usePortal(RSObject object, RSNPC npc) {
  450. /*
  451. * Portal sometimes is an object or an npc
  452. */
  453. if(object != null) {
  454. if(!object.isOnScreen()) {
  455. Camera.turnToTile(object);
  456. }
  457. /*
  458. * Farther than 4 squares away then walk to the portal
  459. */
  460. if(Methods.distanceTo(this, object.getPosition()) > 4) {
  461. WebWalking.walkTo(object);
  462. }
  463.  
  464. /*
  465. * Attempt to click portal
  466. */
  467. setTimeout(System.currentTimeMillis());
  468. while(Methods.distanceTo(this, object.getPosition()) < 5 && !isTimedOut(7000, 8000)) {
  469. object.click(new String[]{"Use", "Exit"});
  470. usedPortal(500);
  471. }
  472. /*
  473. * Walk to the bank if you made it to the shop
  474. */
  475. if(EssConstants.isInsideShop()) {
  476. setState(EssState.WALKING_TO_BANK);
  477. return true;
  478. }
  479. }
  480. if(npc != null) {
  481. if(!npc.isOnScreen()) {
  482. Camera.turnToTile(npc);
  483. }
  484. /*
  485. * Farther than 4 squares away then walk to the portal
  486. */
  487. if(Methods.distanceTo(this, npc.getPosition()) > 4) {
  488. WebWalking.walkTo(npc);
  489. }
  490. /*
  491. * Attempt to click portal
  492. */
  493. setTimeout(System.currentTimeMillis());
  494. while(Methods.distanceTo(this, npc.getPosition()) < 5 && !isTimedOut(7000, 8000)) {
  495. npc.click(new String[]{"Use", "Exit"});
  496. usedPortal(500);
  497. }
  498. /*
  499. * Walk to the bank if you made it to the shop
  500. */
  501. if(EssConstants.isInsideShop()) {
  502. setState(EssState.WALKING_TO_BANK);
  503. return true;
  504. }
  505. }
  506. return false;
  507. }
  508.  
  509. public boolean isTimedOut(int min, int max) {
  510. if(System.currentTimeMillis() - getTimeout() < General.random(min, max)) {
  511. return false;
  512. }
  513. return true;
  514. }
  515.  
  516. private int distanceToClosestEssenceRock() {
  517. return Methods.findObjectByModelPoints(new int[]{EssConstants.ESSENCE_ROCK}).getPosition().distanceTo(Player.getPosition());
  518. }
  519.  
  520. private boolean isInventoryFull() {
  521. if(Inventory.isFull()) {
  522. getData().setEssenceRock(null);
  523. setState(EssState.WALKING_TO_PORTAL);
  524. return true;
  525. }
  526. return false;
  527. }
  528.  
  529. public boolean isCorrectDistance(int distance) {
  530. if(distance > distanceToClosestEssenceRock()) {
  531. setState(EssState.WALKING_TO_ESSENCE);
  532. getData().setEssenceRock(Methods.findObjectByModelPoints(new int[]{EssConstants.ESSENCE_ROCK}));
  533. return false;
  534. }
  535. return true;
  536. }
  537.  
  538. public boolean isFinishedTeleporting(int time) {
  539. long t = System.currentTimeMillis();
  540. while (Timing.timeFromMark(t) < time) {
  541. if (!EssConstants.isInsideEastVarrock()) {
  542. return true;
  543. }
  544. sleep(50, 150);
  545. }
  546. return false;
  547. }
  548.  
  549. private boolean finishedMining(int time) {
  550. long t = System.currentTimeMillis();
  551. while (Timing.timeFromMark(t) < time) {
  552. if (Inventory.isFull() || Player.getAnimation() <= -1) {
  553. return true;
  554. }
  555. sleep(50, 150);
  556. }
  557. return false;
  558. }
  559.  
  560. private boolean startedMining(int time) {
  561. long t = System.currentTimeMillis();
  562. while (Timing.timeFromMark(t) < time) {
  563. if (Player.getAnimation() >= 624 && Player.getAnimation() <= 630) {
  564. return true;
  565. }
  566. sleep(50, 150);
  567. }
  568. return false;
  569. }
  570.  
  571. private boolean usedPortal(int time) {
  572. long t = System.currentTimeMillis();
  573. while (Timing.timeFromMark(t) < time) {
  574. if (EssConstants.isInsideShop()) {
  575. return true;
  576. }
  577. sleep(50, 150);
  578. }
  579. return false;
  580. }
  581.  
  582. public void setPickaxe(EssPickaxe pickaxe) {
  583. this.pickaxe = pickaxe;
  584. }
  585.  
  586. public EssPickaxe getPickaxe() {
  587. return pickaxe;
  588. }
  589.  
  590. public void setLumbridge(EssLumbridge essLumbridge) {
  591. this.lumbridge = essLumbridge;
  592. }
  593.  
  594. public EssLumbridge getLumbridge() {
  595. return lumbridge;
  596. }
  597.  
  598. public void setWalking(EssWalking walking) {
  599. this.walking = walking;
  600. }
  601.  
  602. public EssWalking getWalking() {
  603. return walking;
  604. }
  605.  
  606. public void setBanking(EssBanking banking) {
  607. this.banking = banking;
  608. }
  609.  
  610. public EssBanking getBanking() {
  611. return banking;
  612. }
  613.  
  614. public void setData(EssData data) {
  615. this.data = data;
  616. }
  617.  
  618. public EssData getData() {
  619. return data;
  620. }
  621.  
  622. public void setState(EssState state) {
  623. this.state = state;
  624. }
  625.  
  626. public EssState getState() {
  627. return state;
  628. }
  629.  
  630. public long getLastPlayerRan() {
  631. return lastPlayerRan;
  632. }
  633.  
  634. public void setTimeout(long timeout) {
  635. this.timeout = timeout;
  636. }
  637.  
  638. public long getTimeout() {
  639. return timeout;
  640. }
  641.  
  642. public void setLastPlayerRan(long lastPlayerRan) {
  643. this.lastPlayerRan = lastPlayerRan;
  644. }
  645.  
  646. public List<Cross> getClicks() {
  647. return clicks;
  648. }
  649.  
  650. public Object getLock() {
  651. return lock;
  652. }
  653.  
  654. public void setPaintClick(boolean paintClick) {
  655. this.paintClick = paintClick;
  656. }
  657.  
  658. public boolean isPaintClick() {
  659. return paintClick;
  660. }
  661.  
  662. private class Cross {
  663.  
  664. private final long time;
  665. private final Point location;
  666. private final double rot;
  667.  
  668. public Cross(long lifetime, long st, Point loc, double rot) {
  669. this.time = System.currentTimeMillis() + lifetime;
  670. location = loc;
  671. this.rot = rot;
  672. }
  673.  
  674. public long getAge() {
  675. return time - System.currentTimeMillis();
  676. }
  677.  
  678. public int getAlpha() {
  679. return Math.min(255,
  680. Math.max(0, (int) (256.0D * (getAge() / 1500.0D))));
  681. }
  682.  
  683. public boolean handle() {
  684. return System.currentTimeMillis() <= time;
  685. }
  686.  
  687. public double getRot() {
  688. return rot;
  689. }
  690.  
  691. public Point getLocation() {
  692. return location;
  693. }
  694.  
  695. @Override
  696. public boolean equals(Object o) {
  697. if (o instanceof Cross) {
  698. Cross oo = (Cross) o;
  699. return oo.location.equals(this.location);
  700. }
  701. return false;
  702. }
  703.  
  704. }
  705.  
  706. public double getRot() {
  707. return System.currentTimeMillis() % 3600 / 5.0D;
  708. }
  709.  
  710. private final List<Cross> clicks = new LinkedList<Cross>();
  711. private final Object lock = new Object();
  712.  
  713. private boolean paintClick;
  714.  
  715. @Override
  716. public void paintMouse(Graphics g, Point arg1, Point arg2) {
  717. final Point location = new Point(Mouse.getPos().x, Mouse.getPos().y);
  718. g.setColor(Color.GREEN);
  719. g.drawLine(location.x, location.y - 5, location.x, location.y + 5);
  720. g.drawLine(location.x - 5, location.y, location.x + 5, location.y);
  721. if (isPaintClick()) {
  722. setPaintClick(false);
  723. Cross newCross = new Cross(1500, General.random(40, 300), location, getRot());
  724. if (!getClicks().contains(newCross)) {
  725. getClicks().add(newCross);
  726. }
  727. }
  728. synchronized (getLock()) {
  729. Iterator<Cross> clickIterator = getClicks().listIterator();
  730. while (clickIterator.hasNext()) {
  731. Cross toDraw = clickIterator.next();
  732. if (toDraw.handle()) {
  733. drawPoint(toDraw.getLocation(), toDraw.getRot(), g,
  734. toDraw.getAlpha());
  735. } else {
  736. getClicks().remove(toDraw);
  737. }
  738. }
  739. }
  740.  
  741. }
  742. private void drawPoint(Point location, double rot, Graphics g, int al) {
  743. Graphics2D g1 = (Graphics2D) g.create();
  744. g1.setColor(new Color(255, 0, 0, 155));
  745. g1.rotate(rot, location.x, location.y);
  746. g1.drawLine(location.x, location.y - 5, location.x, location.y + 5);
  747. g1.drawLine(location.x - 5, location.y, location.x + 5, location.y);
  748. }
  749. @Override
  750. public void mouseClicked(Point p, int button, boolean isBot) {
  751. setPaintClick(true);
  752. }
  753. @Override
  754. public void mouseDragged(Point arg0, int arg1, boolean arg2) {
  755. }
  756. @Override
  757. public void mouseMoved(Point arg0, boolean arg1) {
  758. }
  759. @Override
  760. public void mouseReleased(Point arg0, int arg1, boolean arg2) {
  761. }
  762. @Override
  763. public void paintMouseSpline(Graphics arg0, ArrayList<Point> arg1) {
  764. }
  765.  
  766. public boolean isEndScript() {
  767. return endScript;
  768. }
  769.  
  770. public void setEndScript(boolean endScript) {
  771. this.endScript = endScript;
  772. }
  773. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement