Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
225
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 11.23 KB | None | 0 0
  1. package scripts.scripts.nmzAssist;
  2.  
  3. import java.awt.Color;
  4. import java.awt.Font;
  5. import java.awt.Graphics;
  6. import java.awt.Point;
  7. import java.util.ArrayList;
  8. import java.util.HashMap;
  9. import java.util.Map;
  10.  
  11. import org.tribot.api2007.Skills.SKILLS;
  12. import org.tribot.script.Script;
  13. import org.tribot.script.ScriptManifest;
  14. import org.tribot.script.interfaces.MessageListening07;
  15. import org.tribot.script.interfaces.MousePainting;
  16. import org.tribot.script.interfaces.MouseSplinePainting;
  17. import org.tribot.script.interfaces.Painting;
  18.  
  19. import scripts.lib.dataType.Money;
  20. import scripts.scripts.nmzAssist.paintTasks.OutOfCombat;
  21. import scripts.scripts.nmzAssist.paintTasks.Overload;
  22. import scripts.scripts.nmzAssist.paintTasks.Prayer_;
  23.  
  24. @ScriptManifest(authors = {"Dorkinator"}, name = "NMZAssistant", description = "", version = 1.0, category = "tools")
  25. public class NMZAssist extends Script implements Painting, MessageListening07, MouseSplinePainting, MousePainting {
  26. public boolean overload = false;
  27. public boolean prayer = false;
  28. public boolean reOvl;
  29. public int ppots1st;
  30. public int ppots2nd;
  31. private int contHeight = 0;
  32. private double prayDrain = 0;
  33. private int sessionRemaining = 0;
  34. public Prayer_ pr;
  35. public Overload ol;
  36. private Painting[] paintables = {pr = new Prayer_(this), ol = new Overload(this), new OutOfCombat(this)};
  37. private ArrayList<Integer> startXp;
  38.  
  39. @Override
  40. public void onPaint(Graphics g) {
  41. for (Painting p : paintables)
  42. p.onPaint(g);
  43. g.setColor(new Color(0, 0, 0, 125));
  44. g.drawRect(15, 20, 100, contHeight + 7);
  45. g.fillRect(15, 20, 100, contHeight + 7);
  46. g.setColor(Color.green);
  47. g.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 13));
  48. int y = 0;
  49. g.drawString("NMZAssistant", 20, 35 + y);
  50. y = y + 15;
  51. if (overload) {
  52. g.drawString("Ovlcd: " + intToTime(303 - (ol.ovlTimer.timeRunning() / 1000)), 20, 35 + y);
  53. y = y + 15;
  54. }
  55. if (prayer) {
  56. double doses = (double) pr.missingPrayerPoints() / (double) pr.pointsPerDose();
  57. if (Math.floor(doses) > 0) {
  58. g.drawString("Doses avail: " + (int) Math.floor(doses), 20, 35 + y);
  59. y = y + 15;
  60. }
  61. if (sessionRemaining > 0) {
  62. g.drawString("Time left: " + intToTime(sessionRemaining), 20, 35 + y);
  63. y = y + 15;
  64. }
  65. }
  66. Map<String, Integer> xpHr = getXpHr();
  67. for (String s : xpHr.keySet())
  68. if (xpHr.get(s) > 5) {
  69. g.drawString(s + ": " + new Money(xpHr.get(s)), 20, 35 + y);
  70. y = y + 15;
  71. }
  72. contHeight = y;
  73. }
  74.  
  75. @Override
  76. public void run() {
  77. setLoginBotState(false);
  78. setAutoResponderState(false);
  79. setRandomSolverState(false);
  80. startXp = new ArrayList<Integer>();
  81. startXp.add(SKILLS.HITPOINTS.getXP());
  82. startXp.add(SKILLS.ATTACK.getXP());
  83. startXp.add(SKILLS.STRENGTH.getXP());
  84. startXp.add(SKILLS.DEFENCE.getXP());
  85. startXp.add(SKILLS.RANGED.getXP());
  86. startXp.add(SKILLS.MAGIC.getXP());
  87. while (true) {
  88. long sTime = System.currentTimeMillis();
  89. ppots1st = pr.missingPrayerPoints();
  90. sleep(10000);
  91. ppots2nd = pr.missingPrayerPoints();
  92. if (pr.missingPrayerPoints() > 0) {
  93. prayer = true;
  94. }
  95. if (ppots1st < ppots2nd) {
  96. long eTime = System.currentTimeMillis();
  97. if (prayDrain == 0)
  98. prayDrain = ((double) (ppots2nd - ppots1st)) / ((eTime - sTime) / 1000);
  99. else
  100. prayDrain = ((((double) (ppots2nd - ppots1st)) / ((eTime - sTime) / 1000)) + (prayDrain * 19)) / 20;
  101. sessionRemaining = (int) (((pr.pointsPerDose() * pr.remainingDoses()) + SKILLS.PRAYER.getCurrentLevel()) / prayDrain);
  102. }
  103. }
  104. }
  105.  
  106. private Map<String, Integer> getXpHr() {
  107. Map<String, Integer> xpHr = new HashMap<String, Integer>();
  108. xpHr.put("hp", (int) ((SKILLS.HITPOINTS.getXP() - startXp.get(0)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  109. xpHr.put("Atk", (int) ((SKILLS.ATTACK.getXP() - startXp.get(1)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  110. xpHr.put("Str", (int) ((SKILLS.STRENGTH.getXP() - startXp.get(2)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  111. xpHr.put("Def", (int) ((SKILLS.DEFENCE.getXP() - startXp.get(3)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  112. xpHr.put("Rng", (int) ((SKILLS.RANGED.getXP() - startXp.get(4)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  113. xpHr.put("Mag", (int) ((SKILLS.MAGIC.getXP() - startXp.get(5)) / (((double) getRunningTime()) / 1000 / 60 / 60)) + 1);
  114.  
  115. return xpHr;
  116. }
  117.  
  118. private String intToTime(int time) {
  119. return (int) Math.floor(time / 60) + ":" + ((time % 60 + "").length() == 1 ? "0" : "") + time % 60;
  120. }
  121.  
  122. @Override
  123. public void clanMessageReceived(String arg0, String arg1) {
  124.  
  125. }
  126.  
  127. @Override
  128. public void duelRequestReceived(String arg0, String arg1) {
  129.  
  130. }
  131.  
  132. @Override
  133. public void personalMessageReceived(String arg0, String arg1) {
  134.  
  135. }
  136.  
  137. @Override
  138. public void playerMessageReceived(String arg0, String arg1) {
  139.  
  140. }
  141.  
  142. @Override
  143. public void serverMessageReceived(String m) {
  144. if (m.contains("You drink some of your overload potion")) {
  145. ol.resetTimer();
  146. overload = true;
  147. } else if (m.contains("The effects of overload have worn off, and you feel normal again.")) {
  148. overload = true;
  149. ol.dropTimer();
  150. }
  151.  
  152. }
  153.  
  154. @Override
  155. public void tradeRequestReceived(String arg0) {
  156. }
  157.  
  158. @Override
  159. public void paintMouse(Graphics arg0, Point arg1, Point arg2) {
  160. }
  161.  
  162. @Override
  163. public void paintMouseSpline(Graphics arg0, ArrayList<Point> arg1) {
  164. }
  165.  
  166. }
  167.  
  168. ----------------------------------------------------------------------------------------------------------------------------
  169. package scripts.scripts.nmzAssist.paintTasks;
  170.  
  171. import java.awt.Color;
  172. import java.awt.Font;
  173. import java.awt.Graphics;
  174.  
  175. import org.tribot.api2007.Inventory;
  176. import org.tribot.api2007.Skills.SKILLS;
  177. import org.tribot.api2007.types.RSItem;
  178. import org.tribot.script.interfaces.Painting;
  179.  
  180. import scripts.lib.timer.Timer;
  181. import scripts.lib.tone.Tone;
  182. import scripts.scripts.nmzAssist.NMZAssist;
  183.  
  184. public class Prayer_ implements Painting {
  185. private NMZAssist s;
  186. private int frame;
  187. private Timer bepDelay;
  188.  
  189. public Prayer_(NMZAssist s) {
  190. this.s = s;
  191. bepDelay = new Timer(0);
  192. }
  193.  
  194. @Override
  195. public void onPaint(Graphics g) {
  196. if (s.prayer) {
  197. frame++;
  198. frame = frame % 60;
  199. if (pointsPerDose() >= prayerPoints() && hasPrayPots()) {
  200. g.setColor(new Color(0, 255, 255, 80 + (int) (Math.sin((frame) / (Math.PI * 2)) * frame)));
  201. g.fillRect(0, 0, 765, 503);
  202. int doses = (int) Math.floor((double) missingPrayerPoints() / (double) pointsPerDose());
  203. g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 40));
  204. g.drawString("DRINK " + doses + " DOSE" + (doses > 1 ? "S" : ""), 120, 230);
  205. if (!bepDelay.isRunning()) {
  206. Tone.tone(1000, 100, 1.0);
  207. bepDelay = new Timer(3000);
  208. }
  209. }
  210. }
  211. }
  212.  
  213.  
  214. public int missingPrayerPoints() {
  215. return SKILLS.PRAYER.getActualLevel() - SKILLS.PRAYER.getCurrentLevel();
  216. }
  217.  
  218. public int pointsPerDose() {
  219. return (SKILLS.PRAYER.getActualLevel() / 4) + 7;
  220. }
  221.  
  222. private int prayerPoints() {
  223. return SKILLS.PRAYER.getCurrentLevel();
  224. }
  225.  
  226. private boolean hasPrayPots() {
  227. RSItem[] inv = Inventory.getAll();
  228. for (RSItem i : inv)
  229. switch (i.getID()) {
  230. case 143:
  231. case 141:
  232. case 139:
  233. case 2434://4dose
  234. return true;
  235.  
  236. }
  237. return false;
  238. }
  239.  
  240. public int remainingDoses() {
  241. RSItem[] inv = Inventory.getAll();
  242. int out = 0;
  243. for (RSItem i : inv)
  244. switch (i.getID()) {
  245. case 143:
  246. out = out + 1;
  247. case 141:
  248. out = out + 2;
  249. case 139:
  250. out = out + 3;
  251. case 2434://4dose
  252. out = out + 4;
  253. }
  254. return out;
  255. }
  256. }
  257.  
  258. ----------------------------------------------------------------------------------------------------------------------------
  259. package scripts.scripts.nmzAssist.paintTasks;
  260.  
  261. import java.awt.Color;
  262. import java.awt.Font;
  263. import java.awt.Graphics;
  264.  
  265. import org.tribot.api2007.Inventory;
  266. import org.tribot.api2007.types.RSItem;
  267. import org.tribot.script.interfaces.Painting;
  268.  
  269. import scripts.lib.timer.Timer;
  270. import scripts.lib.tone.Tone;
  271. import scripts.scripts.nmzAssist.NMZAssist;
  272.  
  273. public class Overload implements Painting {
  274. private NMZAssist s;
  275. int frame;
  276. public Timer ovlTimer;
  277. private Timer bepDelay;
  278.  
  279. public Overload(NMZAssist s) {
  280. this.s = s;
  281. bepDelay = new Timer(0);
  282. ovlTimer = new Timer(0);
  283. }
  284.  
  285. @Override
  286. public void onPaint(Graphics g) {
  287. if (s.overload) {
  288. frame++;
  289. frame = frame % 60;
  290. if (!ovlTimer.isRunning() && hasOvlPots()) {
  291. g.setColor(new Color(0, 0, 0, 80 + (int) (Math.sin((frame) / (Math.PI * 2)) * frame)));
  292. g.fillRect(0, 0, 765, 503);
  293. g.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 40));
  294. g.drawString("OVERLOAD FOOL", 120, 270);
  295. if (!bepDelay.isRunning()) {
  296. Tone.tone(1000, 100, 1.0);
  297. bepDelay = new Timer(3000);
  298. }
  299. }
  300. }
  301. }
  302.  
  303. public void resetTimer() {
  304. ovlTimer = new Timer(5 * 60 * 1000);
  305. }
  306.  
  307. private boolean hasOvlPots() {
  308. RSItem[] inv = Inventory.getAll();
  309. for (RSItem i : inv)
  310. switch (i.getID()) {
  311. case 11733:
  312. case 11732:
  313. case 11731:
  314. case 11730://4dose
  315. return true;
  316. }
  317. return false;
  318. }
  319.  
  320. public void dropTimer() {
  321. ovlTimer = new Timer(0);
  322. }
  323. }
  324.  
  325. ----------------------------------------------------------------------------------------------------------------------------
  326. package scripts.scripts.nmzAssist.paintTasks;
  327.  
  328. import java.awt.Graphics;
  329.  
  330. import org.tribot.script.interfaces.Painting;
  331.  
  332. import scripts.scripts.nmzAssist.NMZAssist;
  333.  
  334. public class OutOfCombat implements Painting {
  335.  
  336. public OutOfCombat(NMZAssist s) {//Should probably put some actual code here at some point
  337.  
  338. }
  339.  
  340. @Override
  341. public void onPaint(Graphics arg0) {
  342. // TODO Auto-generated method stub
  343.  
  344. }
  345.  
  346. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement