Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Image;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Keyboard;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCChat;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Prayer;
- import org.tribot.api2007.Prayer.PRAYERS;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Skills.SKILLS;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- @ScriptManifest(authors = { "kulers"}, category = "Mini-games", name = "kulersNMZ", description = "You need dwarven rock cake in you inventory only! And you must have 255 Absorption and Overload potions in barrel")
- public class nmz_dh extends Script implements Painting {
- public static long nextPrayFlick = Time();
- public static int nextAbsorption = General.random(80, 160);
- public static long startTime = Time();
- public static long timmer = Time();
- public static long obPot = Time()+300000;
- public static int strXp = Skills.getXP(SKILLS.STRENGTH);
- public static int hpXp = Skills.getXP(SKILLS.HITPOINTS);
- public static int ranXp = Skills.getXP(SKILLS.RANGED);
- public static int attXp = Skills.getXP(SKILLS.ATTACK);
- public static int magXp = Skills.getXP(SKILLS.MAGIC);
- public static int defXp = Skills.getXP(SKILLS.DEFENCE);
- public static RSTile poTitle;
- private final Image img = getImage("http://i.imgur.com/g3qJdov.png?1");
- public Font font = new Font("Verdana", Font.BOLD, 14);
- @Override
- public void run() {
- // TODO Auto-generated method stub
- while (true) {
- if (getNmzPoints() != -1) {
- if (timmer + 30000 > Time())
- sleep(get51Hp());
- int i = checkPrayFlick();
- sleep(i);
- if (i == 0 && getHp() <= 51) {
- sleep(checkOverloads());
- sleep(checkAbsorption());
- //sleep(checkRanging());
- }
- if (i == 0 && getHp() == 1 && (nextPrayFlick - Time()) >= 5000) {
- if (Objects.findNearest(5, "<col=ff9040>Potion").length != 0) {
- poTitle = Objects.findNearest(5, "<col=ff9040>Potion")[0].getPosition();
- }
- try {
- RSTile pos = new RSTile(poTitle.getX() - 20, poTitle.getY() + 32, 3);
- if (pos.getX() != Player.getPosition().getX() || pos.getY() != Player.getPosition().getY()) {
- //Walking.walkPath(Walking.generateStraightPath(pos));
- Walking.walkScreenPath(Walking.generateStraightScreenPath(pos));
- sleep(General.random(500, 2000));
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- }
- } else {
- //sleep(get51Hp());
- //Login.logout();
- int i = payForDream();
- sleep(i);
- if (i == 0) {
- RSTile tt = new RSTile(2601, 3116, 0);
- if (Player.getPosition().distanceTo(tt) >= 5) {
- Walking.walkPath(Walking.generateStraightPath(tt));
- sleep(General.random(1000, 2000));
- } else
- if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length != 13 && Player.getAnimation() == -1) {
- try {
- if (Objects.findNearest(20, "Overload potion").length == 1) {
- Objects.findNearest(20, "Overload potion")[0].click("Store");
- sleep(General.random(3000, 5000));
- try {
- NPCChat.selectOption(NPCChat.getOptions()[0], true);
- } catch (Exception e) {}
- sleep(General.random(1000, 2000));
- Objects.findNearest(20, "Overload potion")[0].click("Take");
- sleep(General.random(1000, 2000));
- Keyboard.typeKeys('5', '2');
- sleep(General.random(200, 300));
- Keyboard.pressEnter();
- sleep(General.random(3000, 5000));
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- } else
- if (Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length != 14 && Player.getAnimation() == -1) {
- try {
- if (Objects.findNearest(20, "Absorption potion").length == 1) {
- Objects.findNearest(20, "Absorption potion")[0].click("Store");
- sleep(General.random(3000, 5000));
- try {
- NPCChat.selectOption(NPCChat.getOptions()[0], true);
- } catch (Exception e) {}
- sleep(General.random(1000, 2000));
- Objects.findNearest(20, "Absorption potion")[0].click("Take");
- sleep(General.random(1000, 2000));
- Keyboard.typeKeys('5', '6');
- sleep(General.random(200, 300));
- Keyboard.pressEnter();
- sleep(General.random(3000, 5000));
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- } else {
- if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length == 13 && Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length == 14) {
- if (getIsDreamOpened() == -1)
- Objects.findNearest(20, 26291)[0].click("Drink");
- sleep(General.random(4000, 5000));
- timmer = Time();
- }
- }
- }
- }
- }
- }
- @Override
- public void onPaint(Graphics g) {
- //
- long timeRan = Time() - startTime;
- g.drawImage(img, 0, 338, null);
- g.setFont(font);
- drawTextShadow(g,""+Math.max((int)((nextPrayFlick - Time())/1000),0), 70, 392); //Pray flick
- drawTextShadow(g, "" + nextAbsorption, 82, 447);
- drawTextShadow(g, ""+Timing.msToString(timeRan), 162, 392);
- drawTextShadow(g, "" + Math.max((int)((obPot-Time())/1000),0), 190, 447);
- if( Math.floor((timeRan / 10000)) % 2 == 0){
- //xp
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.HITPOINTS) - hpXp),0), 312, 392);//HP
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.STRENGTH) - strXp),0), 430, 392);//Str
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.RANGED) - ranXp),0), 312, 422);//Range
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.ATTACK) - attXp),0), 430, 422);//Att
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.MAGIC) - magXp),0), 312, 450);//mage
- drawTextShadow(g, ""+coolFormat((Skills.getXP(SKILLS.DEFENCE) - defXp),0), 430, 450);//def
- }else{
- //xp/h
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.HITPOINTS) - hpXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 392);//HP
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.STRENGTH) - strXp )/ (timeRan / 3600000.0D)),0)+"/h", 430, 392);//Str
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.RANGED) - ranXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 422);//Range
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.ATTACK) - attXp)/ (timeRan / 3600000.0D)),0)+"/h", 430, 422);//Att
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.MAGIC) - magXp)/ (timeRan / 3600000.0D)),0)+"/h", 312, 450);//mage
- drawTextShadow(g, ""+coolFormat(((Skills.getXP(SKILLS.DEFENCE) - defXp)/ (timeRan / 3600000.0D)),0)+"/h", 430, 450);//def
- }
- /*drawTextShadow(g, "STRENGTH: " + (Skills.getXP(SKILLS.STRENGTH) - strXp) + " (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.STRENGTH) - strXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 100);
- drawTextShadow(g, "HITPOINTS: " + (Skills.getXP(SKILLS.HITPOINTS) - hpXp) + " (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.HITPOINTS) - hpXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 120);
- drawTextShadow(g, "RANGED: " + (Skills.getXP(SKILLS.RANGED) - ranXp) + " (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.RANGED) - ranXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 140);
- drawTextShadow(g, "TOTAL: " + (Skills.getXP(SKILLS.HITPOINTS) - hpXp + Skills.getXP(SKILLS.STRENGTH) - strXp + Skills.getXP(SKILLS.RANGED) - ranXp) + " (" + NumberFormat.getNumberInstance(Locale.US).format((int)((Skills.getXP(SKILLS.HITPOINTS) - hpXp + Skills.getXP(SKILLS.STRENGTH) - strXp + Skills.getXP(SKILLS.RANGED) - ranXp) / (timeRan / 3600000.0D))) + ") per hour", 10, 180);
- */
- //
- /*if (getNmzPoints() == -1) {
- drawTextShadow(g, "In arena: False", 10, 258);
- drawTextShadow(g, "Absorption: " + getNmzAmsorbtion(), 10, 258 + 20);
- } else {
- drawTextShadow(g, "Absorption: " + getNmzAmsorbtion(), 10, 258 + 20);
- }*/
- }
- public void drawTextShadow(Graphics g, String t, int x, int y) {
- g.setColor(Color.BLACK);
- g.drawString(t, x + 1, y + 1);
- g.setColor(Color.WHITE);
- g.drawString(t, x, y);
- }
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- public static int checkPrayFlick() {
- if (Prayer.isPrayerEnabled(PRAYERS.RAPID_HEAL)) {
- Prayer.disable(PRAYERS.RAPID_HEAL);
- return General.random(1000, 3000);
- } else
- if (Time() >= nextPrayFlick) {
- nextPrayFlick = Time() + General.random(General.random(10000, 30000), 40000);
- Prayer.enable(PRAYERS.RAPID_HEAL);
- return General.random(100, 300);
- }
- return 0;
- }
- public static int checkAbsorption() {
- if (getNmzAmsorbtion() < nextAbsorption) {
- if (Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)").length != 0) {
- Inventory.find("Absorption (4)", "Absorption (3)", "Absorption (2)", "Absorption (1)")[0].click("Drink");
- nextAbsorption = General.random(80, 160);
- return General.random(1000, 3000);
- }
- return 0;
- }
- return 0;
- }
- public static int checkOverloads() {
- if (Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)").length != 0 && Skills.getActualLevel(SKILLS.STRENGTH) == Skills.getCurrentLevel(SKILLS.STRENGTH)) {
- Inventory.find("Overload (4)", "Overload (3)", "Overload (2)", "Overload (1)")[0].click("Drink");
- obPot = Time()+300000;
- return General.random(1000, 3000);
- }
- return 0;
- }
- public static int checkRanging() {
- if (Skills.getActualLevel(SKILLS.RANGED) + 7 >= Skills.getCurrentLevel(SKILLS.RANGED)) {
- Inventory.find("Super ranging (4)", "Super ranging (3)", "Super ranging (2)", "Super ranging (1)")[0].click("Drink");
- return General.random(1000, 3000);
- }
- return 0;
- }
- public static long Time() {
- return System.currentTimeMillis();
- }
- public static int get51Hp() {
- //General.println("HP:"+getHp() );
- if (getHp() >= 67 || getHp() == 0) {
- Inventory.find("Dwarven rock cake")[0].click("Guzzle");
- return General.random(200, 400);
- } else
- if (getHp() >= 65 && getHp() <= 67 || getHp() == 0) {
- Inventory.find("Dwarven rock cake")[0].click("Guzzle");
- return General.random(200, 400);
- } else
- if (getHp() >= 52 && getHp() <= 65 || getHp() == 0) {
- Inventory.find("Dwarven rock cake")[0].click("Eat");
- return General.random(1000, 1200);
- }
- return General.random(200, 400);
- }
- public static int getNmzAmsorbtion() {
- try {
- if (Interfaces.get(202, 1).getChild(9).isHidden()) {
- return -2;
- }
- return Integer.parseInt(Interfaces.get(202, 1).getChild(9).getText());
- } catch (Exception e) {
- return -1;
- }
- }
- public static int getHp() {
- try {
- if (Interfaces.get(160, 5).isHidden()) {
- return 0;
- }
- return Integer.parseInt(Interfaces.get(160, 5).getText());
- } catch (Exception e) {
- return 0;
- }
- }
- public static int getNmzPoints() {
- try {
- if (Interfaces.get(202, 1).getChild(3).isHidden()) {
- return -1;
- }
- return Integer.parseInt(Interfaces.get(202, 1).getChild(3).getText().split("<br>")[1].replace(",", ""));
- } catch (Exception e) {
- return -1;
- }
- }
- public static int payForDream() {
- if (Objects.findNearest(20, "<col=ff9040>Potion").length == 0) {
- try {
- NPCs.find("Dominic Onion")[0].click("Dream");
- General.sleep(General.random(8000, 15000));
- if (NPCChat.getOptions().length == 4) {
- NPCChat.selectOption(NPCChat.getOptions()[3], true);
- General.sleep(General.random(1000, 2000));
- NPCChat.clickContinue(true);
- General.sleep(General.random(1000, 2000));
- if (NPCChat.getOptions().length == 2) {
- NPCChat.selectOption(NPCChat.getOptions()[0], true);
- General.sleep(General.random(1000, 2000));
- NPCChat.clickContinue(true);
- General.sleep(General.random(1000, 2000));
- }
- }
- } catch (Exception e) {
- // TODO: handle exception
- }
- return General.random(4000, 5000);
- }
- return 0;
- }
- public static int getIsDreamOpened() {
- try {
- Interfaces.get(129, 6).getChild(9).click("Continue");
- return 1;
- } catch (Exception e) {
- return -1;
- }
- }
- private static char[] c = new char[]{'k', 'm', 'b', 't'};
- /**
- * Recursive implementation, invokes itself for each factor of a thousand, increasing the class on each invokation.
- * @param n the number to format
- * @param iteration in fact this is the class from the array c
- * @return a String representing the number n formatted in a cool looking way.
- */
- private static String coolFormat(double n, int iteration) {
- double d = ((long) n / 100) / 10.0;
- boolean isRound = (d * 10) %10 == 0;//true if the decimal part is equal to 0 (then it's trimmed anyway)
- return (d < 1000? //this determines the class, i.e. 'k', 'm' etc
- ((d > 99.9 || isRound || (!isRound && d > 9.99)? //this decides whether to trim the decimals
- (int) d * 10 / 10 : d + "" // (int) d * 10 / 10 drops the decimal
- ) + "" + c[iteration])
- : coolFormat(d, iteration+1));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement