MGT Madness Posted February 22, 2017 Share Posted February 22, 2017 (edited) I used this for 10 hours a day for 5 days, last time i used it was a week ago, i quit Osrs because membership ran out xD. If someone could provide a screenshot of it in use, would be cute. How to use: Enter the NMZ instance, use your overload and a few absorbtions. Features: - Decent anti-ban - Uses overload when needed - Uses absorbtion potions after overloading - Uses rock cake - Interface that shows experience in skill gained and xp per hour - It will stop the script when outside NMZ instance. Improvements to do yourself: - There is like a very rare chance the bot will kill itself in the NMZ instance by rockcaking then overloading - Make Randomized actions instead of randomized delays between actions - Add support for Magic/Ranged potion - Support for use of prayer - Currently you need to overload and absorbtion manually when you enter the instance. - Make it log out properly or restock when out of NMZ instance. import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.RenderingHints; import java.util.ArrayList; import java.util.List; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mgt Madness", info = "Nightmare Zone", name = "Nmz", version = 1.0, logo = "") public class NightmareZoneMgt extends Script { private final Color BACKGROUND_COLOUR = new Color(0, 0, 0, 80); private final Color BACKGROUND_OUTLINE_CLOUR = new Color(0, 0, 0, 80); private final Color MAIN_TEXT_COLOUR = new Color(102, 188, 255); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font(Font.SANS_SERIF, 0, 12); private final int X = -134; private final int Y = 85; private final int BOX_ARC_AMOUNT = 8; private final String[] ABSORBTION_POTIONS = {"Absorption (1)", "Absorption (2)", "Absorption (3)", "Absorption (4)"}; private final String[] OVERLOAD_POTIONS = {"Overload (1)", "Overload (2)", "Overload (3)", "Overload (4)"}; private long timeScriptStarted = System.currentTimeMillis(); private String status = ""; private ArrayList<String> skillsExperienceStart = new ArrayList<String>(); private ArrayList<String> skillsExperienceGained = new ArrayList<String>(); private long timeToDrinkOverload; private int absorbtionDosesToDrink; private long timeCanCake; @Override public void onStart() { setStatus("Script started."); for (Skill data : Skill.values()) { skillsExperienceStart.add(data.name() + ":" + skills.getExperience(data)); } } @Override public int onLoop() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) == 0) { setStatus("Player is 0 hp."); } if (getClient().getLoginStateValue() == 40) { log("Connection lost"); } if (areaHasPlayers()) { setStatus("Area has players, stop script"); stop(); } updateExperienceGained(); overload(); absorbtion(); antiBan(); cake(); return random(500, 1000); } private void cake() { if (System.currentTimeMillis() < timeCanCake) { return; } if (System.currentTimeMillis() < timeToDrinkOverload) { return; } if (skills.getDynamic(Skill.STRENGTH) > skills.getStatic(Skill.STRENGTH)) { if (skills.getDynamic(Skill.HITPOINTS) > 2) { setStatus("Eat"); inventory.interact(random(1, 15) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); moveMouse(3); } else if (skills.getDynamic(Skill.HITPOINTS) == 2) { long delay = random(61000, 170000); if (random(1, 7) == 1) { delay = random(170000, 360000); } if (random(1, 6) == 1) { // Do not guzzle. } else { setStatus("Eat"); inventory.interact("Guzzle", "Dwarven rock cake"); } moveMouse(3); timeCanCake = System.currentTimeMillis() + delay; } } } private void antiBan() throws InterruptedException { if (random(1, 200) == 1) { setStatus("Anti-ban random mouse movement"); moveMouse(1); } if (random(1, 300) == 1) { moveMouse(2); if (skills.getCombat().getSpecialPercentage() >= 55) { skills.getCombat().toggleSpecialAttack(true); setStatus("Anti-ban special attack activated"); } } if (random(1, 300) == 1) { int random = random(1, 50); if (random <= 5) { absorbtionDosesToDrink = random(1, 2); setStatus("Anti-ban drink abosrbtion"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 25) { attackRandomTarget(); } else if (random <= 30) { getWalking().walk(new Position((myPlayer().getX() - 10) + random(0, 10), (myPlayer().getY() - 10) + random(0, 10), myPlayer().getHeight())); setStatus("Anti-ban walk"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 40) { random = random(1, 10); if (random <= 4) { setStatus("Anti-ban friends"); getTabs().open(Tab.FRIENDS); sleep(random(3000, 10000)); getTabs().open(Tab.INVENTORY); } else if (random <= 7) { setStatus("Anti-ban attack tab"); getTabs().open(Tab.ATTACK); sleep(random(3000, 7000)); getTabs().open(Tab.INVENTORY); } else if (random <= 10) { setStatus("Anti-ban skills tab"); getTabs().open(Tab.SKILLS); sleep(random(2000, 4000)); skills.hoverSkill(random(1, 3) == 1 ? Skill.HITPOINTS : Skill.RANGED); sleep(random(4000, 12000)); getTabs().open(Tab.INVENTORY); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 50) { if (System.currentTimeMillis() < timeCanCake) { attackRandomTarget(); return; } if (skills.getDynamic(Skill.HITPOINTS) > 1) { setStatus("Anti-ban eat"); inventory.interact(random(1, 2) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } } } private void attackRandomTarget() throws InterruptedException { List<NPC> allNpcs = npcs.getAll(); for (int index = 0; index < allNpcs.size(); index++) { NPC npc = allNpcs.get(index); if (npc == null) { continue; } if (!npc.exists()) { continue; } if (!npc.isOnScreen()) { continue; } if (random(1, 2) == 1) { continue; } npc.interact("Attack"); setStatus("Anti-ban switch target"); sleep(random(2000, 8000)); skills.getMouse().moveRandomly(); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); break; } } private void absorbtion() { if (absorbtionDosesToDrink > 0) { setStatus("Drinking absorbtion"); inventory.interact("Drink", ABSORBTION_POTIONS); moveMouse(10); absorbtionDosesToDrink--; if (absorbtionDosesToDrink == 0) { timeCanCake = System.currentTimeMillis() + random(500, 7000); } } } private void overload() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) < 51) { return; } if (timeToDrinkOverload == 0) { if (skills.getDynamic(Skill.STRENGTH) == skills.getStatic(Skill.STRENGTH)) { setStatus("Will overload shortly"); long delay = random(2000, 20000); if (random(1, 6) == 1) { delay = random(20000, 120000); setStatus("Will overload longly"); } timeToDrinkOverload = System.currentTimeMillis() + delay; } return; } if (System.currentTimeMillis() > timeToDrinkOverload) { setStatus("Drinking overload"); timeCanCake = System.currentTimeMillis() + random(10000, 25000); inventory.interact("Drink", OVERLOAD_POTIONS); timeToDrinkOverload = 0; moveMouse(3); sleep(random(1000, 8000)); absorbtionDosesToDrink = random(2, 7); } } private void moveMouse(int chance) { if (random(1, chance) == 1) { if (random(1, 15) == 1) { skills.getMouse().moveRandomly(); } else if (random(1, 8) == 1) { skills.getMouse().moveSlightly(); } else { skills.getMouse().moveVerySlightly(); } setStatus("Anti-ban random mouse movement"); } } @Override public void onExit() { setStatus("Script ended."); } @Override public void onPaint(Graphics2D g) { int ySize = skillsExperienceGained.size() * 16; g.setColor(BACKGROUND_COLOUR); g.fillRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setColor(BACKGROUND_OUTLINE_CLOUR); g.setStroke(stroke1); g.drawRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setFont(font1); g.setColor(MAIN_TEXT_COLOUR); g.drawString("Duration: " + getRuntime(), 147 + X, 24 + Y); g.drawString("Last action: " + status, 147 + X, 40 + Y); for (int index = 0; index < skillsExperienceGained.size(); index++) { g.drawString(skillsExperienceGained.get(index), 147 + X, 40 + Y + ((index + 1) * 16)); } drawMouse(g); } private void setStatus(String status) { log("Status: " + status); this.status = status; } /** * Get time since script started. */ private String getRuntime() { long seconds = (System.currentTimeMillis() - timeScriptStarted) / 1000; String time = ""; if (seconds < 60) { return seconds + "s"; } else if (seconds < 3600) { int remainder = (int) (seconds / 60); if (60 * remainder < seconds) { remainder = (int) (seconds - (60 * remainder)); } else { remainder = 0; } return (seconds / 60) + "m " + remainder + "s"; } else { int remainderMinutes = (int) seconds / 3600; int seconds1 = 0; if (3600 * remainderMinutes < seconds) { remainderMinutes = (int) (seconds - (3600 * remainderMinutes)); seconds1 = remainderMinutes; remainderMinutes /= 60; int remainder = (int) (seconds1 / 60); if (60 * remainder < seconds1) { remainder = (int) (seconds1 - (60 * remainder)); } else { remainder = 0; } seconds1 = remainder; } else { remainderMinutes = 0; } return (seconds / 3600) + "h " + remainderMinutes + "m " + seconds1 + "s"; } } /** * @return * The number in thousands with k at the end. */ private String getFormattedRunescapeNumber(int amount) { if (amount >= 1000) { return (amount / 1000) + "k"; } else { return amount + ""; } } private void updateExperienceGained() { int index = 0; skillsExperienceGained.clear(); for (Skill data : Skill.values()) { int currentXp = skills.getExperience(data); String[] parse = skillsExperienceStart.get(index).split(":"); int startXp = Integer.parseInt(parse[1]); if (currentXp > startXp) { int totalXp = currentXp - startXp; skillsExperienceGained.add(capitalize(parse[0]) + " xp: " + getFormattedRunescapeNumber(totalXp) + " (" + getFormattedRunescapeNumber(getExperienceperHour(totalXp)) + "/h)"); } index++; } } public int getExperienceperHour(int totalExperienceGained) { int minutes = (int) ((System.currentTimeMillis() - timeScriptStarted) / 60000); int beforeSeconds = 0; double multiplier = 1.0; if (minutes < 60) { beforeSeconds = (int) ((System.currentTimeMillis() - timeScriptStarted) / 1000); multiplier = 3600.0 / (double) beforeSeconds; minutes = 60; } double convert = (double) minutes; convert = convert / 60.0; return (int) ((totalExperienceGained / convert) * multiplier); } /** * Capitalize the first letter and other letters that before it is a space. * @param s * @return */ public static String capitalize(String s) { s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { if (i == 0) { s = String.format("%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1)); } if (!Character.isLetterOrDigit(s.charAt(i))) { if (i + 1 < s.length()) { s = String.format("%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2)); } } } return s; } public boolean areaHasPlayers() { Area area = myPlayer().getArea(10);//create your own area int amount = 0; for (Player player : players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())) { if (area.contains(player)) { amount++; } } } return amount > 0; } public void drawMouse(Graphics g) { ((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point p = mouse.getPosition(); Graphics2D spinG = (Graphics2D) g.create(); Graphics2D spinGRev = (Graphics2D) g.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, p.x, p.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, p.x, p.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } Edited February 22, 2017 by MGT Madness Quote Link to comment Share on other sites More sharing options...
AdnaneSen Posted February 22, 2017 Share Posted February 22, 2017 rip fruity nmz 2 Quote Link to comment Share on other sites More sharing options...
Froheisme Posted February 22, 2017 Share Posted February 22, 2017 :OOOOOOOOOOOOOOOOOOOOOO Quote Link to comment Share on other sites More sharing options...
meteos Posted February 24, 2017 Share Posted February 24, 2017 I am really inexperienced, how do i put it in my scripts? Quote Link to comment Share on other sites More sharing options...
thinq Posted March 29, 2017 Share Posted March 29, 2017 Would be great if you could compile it to .jar and upload it @MGT Madness Quote Link to comment Share on other sites More sharing options...
payton9812 Posted April 1, 2017 Share Posted April 1, 2017 jar please Quote Link to comment Share on other sites More sharing options...
maxitaxi Posted April 18, 2017 Share Posted April 18, 2017 Does this still work? Quote Link to comment Share on other sites More sharing options...
Juggles Posted April 19, 2017 Share Posted April 19, 2017 (edited) Yah it 5 hours ago, maxitaxi said: Does this still work? Yeah it should works if you compile Edited April 19, 2017 by Juggles Quote Link to comment Share on other sites More sharing options...
maxitaxi Posted April 19, 2017 Share Posted April 19, 2017 29 minutes ago, Juggles said: Yah it Yeah it should works if you compile ok sweet, thanks. Time to head over and read how to compile .jar again haha. Quote Link to comment Share on other sites More sharing options...
Mistys Posted April 19, 2017 Share Posted April 19, 2017 Anyone tested? Quote Link to comment Share on other sites More sharing options...
hrkljus7 Posted May 22, 2017 Share Posted May 22, 2017 guys anyone have compiled version? and can tell me how to put it to work? Thanks! love! Quote Link to comment Share on other sites More sharing options...
Lol_marcus Posted May 9, 2020 Share Posted May 9, 2020 Fixed the script, for anyone who's actively looking for a NMZ script. I had to remove a few things, not sure if they're older code that the client doesn't recognize anymore. I've tested the script for 25 minutes and it works fine. You can find the .jar at the end of the post. package core; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.RenderingHints; import java.util.ArrayList; import java.util.List; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mgt Madness", info = "Nightmare Zone", name = "Nmz", version = 1.1, logo = "") public class Main extends Script { private final Color BACKGROUND_COLOUR = new Color(0, 0, 0, 80); private final Color BACKGROUND_OUTLINE_CLOUR = new Color(0, 0, 0, 80); private final Color MAIN_TEXT_COLOUR = new Color(102, 188, 255); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font(Font.SANS_SERIF, 0, 12); private final int X = -134; private final int Y = 85; private final int BOX_ARC_AMOUNT = 8; private final String[] ABSORBTION_POTIONS = {"Absorption (1)", "Absorption (2)", "Absorption (3)", "Absorption (4)"}; private final String[] OVERLOAD_POTIONS = {"Overload (1)", "Overload (2)", "Overload (3)", "Overload (4)"}; private long timeScriptStarted = System.currentTimeMillis(); private String status = ""; private ArrayList<String> skillsExperienceStart = new ArrayList<String>(); private ArrayList<String> skillsExperienceGained = new ArrayList<String>(); private long timeToDrinkOverload; private int absorbtionDosesToDrink; private long timeCanCake; @Override public void onStart() { setStatus("Script started."); for (Skill data : Skill.values()) { skillsExperienceStart.add(data.name() + ":" + skills.getExperience(data)); } } @Override public int onLoop() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) == 0) { setStatus("Player is 0 hp."); } if (areaHasPlayers()) { setStatus("Area has players, stop script"); stop(); } updateExperienceGained(); overload(); absorbtion(); antiBan(); cake(); return random(500, 1000); } private void cake() { if (System.currentTimeMillis() < timeCanCake) { return; } if (System.currentTimeMillis() < timeToDrinkOverload) { return; } if (skills.getDynamic(Skill.STRENGTH) > skills.getStatic(Skill.STRENGTH)) { if (skills.getDynamic(Skill.HITPOINTS) > 2) { setStatus("Eat"); inventory.interact(random(1, 15) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); moveMouse(3); } else if (skills.getDynamic(Skill.HITPOINTS) == 2) { long delay = random(61000, 170000); if (random(1, 7) == 1) { delay = random(170000, 360000); } if (random(1, 6) == 1) { // Do not guzzle. } else { setStatus("Eat"); inventory.interact("Guzzle", "Dwarven rock cake"); } moveMouse(3); timeCanCake = System.currentTimeMillis() + delay; } } } private void moveMouse(int i) { // TODO Auto-generated method stub } private void antiBan() throws InterruptedException { if (random(1, 200) == 1) { setStatus("Anti-ban random mouse movement"); moveMouse(1); } if (random(1, 300) == 1) { moveMouse(2); if (skills.getCombat().getSpecialPercentage() >= 55) { skills.getCombat().toggleSpecialAttack(true); setStatus("Anti-ban special attack activated"); } } if (random(1, 300) == 1) { int random = random(1, 50); if (random <= 5) { absorbtionDosesToDrink = random(1, 2); setStatus("Anti-ban drink abosrbtion"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 25) { attackRandomTarget(); } else if (random <= 30) { getWalking().walk(new Position((myPlayer().getX() - 10) + random(0, 10), (myPlayer().getY() - 10) + random(0, 10), myPlayer().getHeight())); setStatus("Anti-ban walk"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 40) { random = random(1, 10); if (random <= 4) { setStatus("Anti-ban friends"); getTabs().open(Tab.FRIENDS); sleep(random(3000, 10000)); getTabs().open(Tab.INVENTORY); } else if (random <= 7) { setStatus("Anti-ban attack tab"); getTabs().open(Tab.ATTACK); sleep(random(3000, 7000)); getTabs().open(Tab.INVENTORY); } else if (random <= 10) { setStatus("Anti-ban skills tab"); getTabs().open(Tab.SKILLS); sleep(random(4000, 12000)); getTabs().open(Tab.INVENTORY); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 50) { if (System.currentTimeMillis() < timeCanCake) { attackRandomTarget(); return; } if (skills.getDynamic(Skill.HITPOINTS) > 1) { setStatus("Anti-ban eat"); inventory.interact(random(1, 2) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } } } private void attackRandomTarget() throws InterruptedException { List<NPC> allNpcs = npcs.getAll(); for (int index = 0; index < allNpcs.size(); index++) { NPC npc = allNpcs.get(index); if (npc == null) { continue; } if (!npc.exists()) { continue; } if (!npc.isOnScreen()) { continue; } if (random(1, 2) == 1) { continue; } npc.interact("Attack"); setStatus("Anti-ban switch target"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); break; } } private void absorbtion() { if (absorbtionDosesToDrink > 0) { setStatus("Drinking absorbtion"); inventory.interact("Drink", ABSORBTION_POTIONS); moveMouse(10); absorbtionDosesToDrink--; if (absorbtionDosesToDrink == 0) { timeCanCake = System.currentTimeMillis() + random(500, 7000); } } } private void overload() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) < 51) { return; } if (timeToDrinkOverload == 0) { if (skills.getDynamic(Skill.STRENGTH) == skills.getStatic(Skill.STRENGTH)) { setStatus("Will overload shortly"); long delay = random(2000, 20000); if (random(1, 6) == 1) { delay = random(20000, 120000); setStatus("Will overload longly"); } timeToDrinkOverload = System.currentTimeMillis() + delay; } return; } if (System.currentTimeMillis() > timeToDrinkOverload) { setStatus("Drinking overload"); timeCanCake = System.currentTimeMillis() + random(10000, 25000); inventory.interact("Drink", OVERLOAD_POTIONS); timeToDrinkOverload = 0; moveMouse(3); sleep(random(1000, 8000)); absorbtionDosesToDrink = random(2, 7); } } @Override public void onExit() { setStatus("Script ended."); } @Override public void onPaint(Graphics2D g) { int ySize = skillsExperienceGained.size() * 16; g.setColor(BACKGROUND_COLOUR); g.fillRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setColor(BACKGROUND_OUTLINE_CLOUR); g.setStroke(stroke1); g.drawRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setFont(font1); g.setColor(MAIN_TEXT_COLOUR); g.drawString("Duration: " + getRuntime(), 147 + X, 24 + Y); g.drawString("Last action: " + status, 147 + X, 40 + Y); for (int index = 0; index < skillsExperienceGained.size(); index++) { g.drawString(skillsExperienceGained.get(index), 147 + X, 40 + Y + ((index + 1) * 16)); } drawMouse(g); } private void setStatus(String status) { log("Status: " + status); this.status = status; } /** * Get time since script started. */ private String getRuntime() { long seconds = (System.currentTimeMillis() - timeScriptStarted) / 1000; if (seconds < 60) { return seconds + "s"; } else if (seconds < 3600) { int remainder = (int) (seconds / 60); if (60 * remainder < seconds) { remainder = (int) (seconds - (60 * remainder)); } else { remainder = 0; } return (seconds / 60) + "m " + remainder + "s"; } else { int remainderMinutes = (int) seconds / 3600; int seconds1 = 0; if (3600 * remainderMinutes < seconds) { remainderMinutes = (int) (seconds - (3600 * remainderMinutes)); seconds1 = remainderMinutes; remainderMinutes /= 60; int remainder = (int) (seconds1 / 60); if (60 * remainder < seconds1) { remainder = (int) (seconds1 - (60 * remainder)); } else { remainder = 0; } seconds1 = remainder; } else { remainderMinutes = 0; } return (seconds / 3600) + "h " + remainderMinutes + "m " + seconds1 + "s"; } } /** * @return * The number in thousands with k at the end. */ private String getFormattedRunescapeNumber(int amount) { if (amount >= 1000) { return (amount / 1000) + "k"; } else { return amount + ""; } } private void updateExperienceGained() { int index = 0; skillsExperienceGained.clear(); for (Skill data : Skill.values()) { int currentXp = skills.getExperience(data); String[] parse = skillsExperienceStart.get(index).split(":"); int startXp = Integer.parseInt(parse[1]); if (currentXp > startXp) { int totalXp = currentXp - startXp; skillsExperienceGained.add(capitalize(parse[0]) + " xp: " + getFormattedRunescapeNumber(totalXp) + " (" + getFormattedRunescapeNumber(getExperienceperHour(totalXp)) + "/h)"); } index++; } } public int getExperienceperHour(int totalExperienceGained) { int minutes = (int) ((System.currentTimeMillis() - timeScriptStarted) / 60000); int beforeSeconds = 0; double multiplier = 1.0; if (minutes < 60) { beforeSeconds = (int) ((System.currentTimeMillis() - timeScriptStarted) / 1000); multiplier = 3600.0 / (double) beforeSeconds; minutes = 60; } double convert = (double) minutes; convert = convert / 60.0; return (int) ((totalExperienceGained / convert) * multiplier); } /** * Capitalize the first letter and other letters that before it is a space. * @param s * @return */ public static String capitalize(String s) { s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { if (i == 0) { s = String.format("%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1)); } if (!Character.isLetterOrDigit(s.charAt(i))) { if (i + 1 < s.length()) { s = String.format("%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2)); } } } return s; } public boolean areaHasPlayers() { Area area = myPlayer().getArea(10);//create your own area int amount = 0; for (Player player : players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())) { if (area.contains(player)) { amount++; } } } return amount > 0; } public void drawMouse(Graphics g) { ((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point p = mouse.getPosition(); Graphics2D spinG = (Graphics2D) g.create(); Graphics2D spinGRev = (Graphics2D) g.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, p.x, p.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, p.x, p.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } NMZ.jar 2 Quote Link to comment Share on other sites More sharing options...
I need Posted June 13, 2020 Share Posted June 13, 2020 On 5/9/2020 at 9:33 AM, Lol_marcus said: Fixed the script, for anyone who's actively looking for a NMZ script. I had to remove a few things, not sure if they're older code that the client doesn't recognize anymore. I've tested the script for 25 minutes and it works fine. You can find the .jar at the end of the post. package core; import java.awt.BasicStroke; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Point; import java.awt.RenderingHints; import java.util.ArrayList; import java.util.List; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; @ScriptManifest(author = "Mgt Madness", info = "Nightmare Zone", name = "Nmz", version = 1.1, logo = "") public class Main extends Script { private final Color BACKGROUND_COLOUR = new Color(0, 0, 0, 80); private final Color BACKGROUND_OUTLINE_CLOUR = new Color(0, 0, 0, 80); private final Color MAIN_TEXT_COLOUR = new Color(102, 188, 255); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font(Font.SANS_SERIF, 0, 12); private final int X = -134; private final int Y = 85; private final int BOX_ARC_AMOUNT = 8; private final String[] ABSORBTION_POTIONS = {"Absorption (1)", "Absorption (2)", "Absorption (3)", "Absorption (4)"}; private final String[] OVERLOAD_POTIONS = {"Overload (1)", "Overload (2)", "Overload (3)", "Overload (4)"}; private long timeScriptStarted = System.currentTimeMillis(); private String status = ""; private ArrayList<String> skillsExperienceStart = new ArrayList<String>(); private ArrayList<String> skillsExperienceGained = new ArrayList<String>(); private long timeToDrinkOverload; private int absorbtionDosesToDrink; private long timeCanCake; @Override public void onStart() { setStatus("Script started."); for (Skill data : Skill.values()) { skillsExperienceStart.add(data.name() + ":" + skills.getExperience(data)); } } @Override public int onLoop() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) == 0) { setStatus("Player is 0 hp."); } if (areaHasPlayers()) { setStatus("Area has players, stop script"); stop(); } updateExperienceGained(); overload(); absorbtion(); antiBan(); cake(); return random(500, 1000); } private void cake() { if (System.currentTimeMillis() < timeCanCake) { return; } if (System.currentTimeMillis() < timeToDrinkOverload) { return; } if (skills.getDynamic(Skill.STRENGTH) > skills.getStatic(Skill.STRENGTH)) { if (skills.getDynamic(Skill.HITPOINTS) > 2) { setStatus("Eat"); inventory.interact(random(1, 15) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); moveMouse(3); } else if (skills.getDynamic(Skill.HITPOINTS) == 2) { long delay = random(61000, 170000); if (random(1, 7) == 1) { delay = random(170000, 360000); } if (random(1, 6) == 1) { // Do not guzzle. } else { setStatus("Eat"); inventory.interact("Guzzle", "Dwarven rock cake"); } moveMouse(3); timeCanCake = System.currentTimeMillis() + delay; } } } private void moveMouse(int i) { // TODO Auto-generated method stub } private void antiBan() throws InterruptedException { if (random(1, 200) == 1) { setStatus("Anti-ban random mouse movement"); moveMouse(1); } if (random(1, 300) == 1) { moveMouse(2); if (skills.getCombat().getSpecialPercentage() >= 55) { skills.getCombat().toggleSpecialAttack(true); setStatus("Anti-ban special attack activated"); } } if (random(1, 300) == 1) { int random = random(1, 50); if (random <= 5) { absorbtionDosesToDrink = random(1, 2); setStatus("Anti-ban drink abosrbtion"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 25) { attackRandomTarget(); } else if (random <= 30) { getWalking().walk(new Position((myPlayer().getX() - 10) + random(0, 10), (myPlayer().getY() - 10) + random(0, 10), myPlayer().getHeight())); setStatus("Anti-ban walk"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 40) { random = random(1, 10); if (random <= 4) { setStatus("Anti-ban friends"); getTabs().open(Tab.FRIENDS); sleep(random(3000, 10000)); getTabs().open(Tab.INVENTORY); } else if (random <= 7) { setStatus("Anti-ban attack tab"); getTabs().open(Tab.ATTACK); sleep(random(3000, 7000)); getTabs().open(Tab.INVENTORY); } else if (random <= 10) { setStatus("Anti-ban skills tab"); getTabs().open(Tab.SKILLS); sleep(random(4000, 12000)); getTabs().open(Tab.INVENTORY); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 50) { if (System.currentTimeMillis() < timeCanCake) { attackRandomTarget(); return; } if (skills.getDynamic(Skill.HITPOINTS) > 1) { setStatus("Anti-ban eat"); inventory.interact(random(1, 2) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } } } private void attackRandomTarget() throws InterruptedException { List<NPC> allNpcs = npcs.getAll(); for (int index = 0; index < allNpcs.size(); index++) { NPC npc = allNpcs.get(index); if (npc == null) { continue; } if (!npc.exists()) { continue; } if (!npc.isOnScreen()) { continue; } if (random(1, 2) == 1) { continue; } npc.interact("Attack"); setStatus("Anti-ban switch target"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); break; } } private void absorbtion() { if (absorbtionDosesToDrink > 0) { setStatus("Drinking absorbtion"); inventory.interact("Drink", ABSORBTION_POTIONS); moveMouse(10); absorbtionDosesToDrink--; if (absorbtionDosesToDrink == 0) { timeCanCake = System.currentTimeMillis() + random(500, 7000); } } } private void overload() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) < 51) { return; } if (timeToDrinkOverload == 0) { if (skills.getDynamic(Skill.STRENGTH) == skills.getStatic(Skill.STRENGTH)) { setStatus("Will overload shortly"); long delay = random(2000, 20000); if (random(1, 6) == 1) { delay = random(20000, 120000); setStatus("Will overload longly"); } timeToDrinkOverload = System.currentTimeMillis() + delay; } return; } if (System.currentTimeMillis() > timeToDrinkOverload) { setStatus("Drinking overload"); timeCanCake = System.currentTimeMillis() + random(10000, 25000); inventory.interact("Drink", OVERLOAD_POTIONS); timeToDrinkOverload = 0; moveMouse(3); sleep(random(1000, 8000)); absorbtionDosesToDrink = random(2, 7); } } @Override public void onExit() { setStatus("Script ended."); } @Override public void onPaint(Graphics2D g) { int ySize = skillsExperienceGained.size() * 16; g.setColor(BACKGROUND_COLOUR); g.fillRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setColor(BACKGROUND_OUTLINE_CLOUR); g.setStroke(stroke1); g.drawRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setFont(font1); g.setColor(MAIN_TEXT_COLOUR); g.drawString("Duration: " + getRuntime(), 147 + X, 24 + Y); g.drawString("Last action: " + status, 147 + X, 40 + Y); for (int index = 0; index < skillsExperienceGained.size(); index++) { g.drawString(skillsExperienceGained.get(index), 147 + X, 40 + Y + ((index + 1) * 16)); } drawMouse(g); } private void setStatus(String status) { log("Status: " + status); this.status = status; } /** * Get time since script started. */ private String getRuntime() { long seconds = (System.currentTimeMillis() - timeScriptStarted) / 1000; if (seconds < 60) { return seconds + "s"; } else if (seconds < 3600) { int remainder = (int) (seconds / 60); if (60 * remainder < seconds) { remainder = (int) (seconds - (60 * remainder)); } else { remainder = 0; } return (seconds / 60) + "m " + remainder + "s"; } else { int remainderMinutes = (int) seconds / 3600; int seconds1 = 0; if (3600 * remainderMinutes < seconds) { remainderMinutes = (int) (seconds - (3600 * remainderMinutes)); seconds1 = remainderMinutes; remainderMinutes /= 60; int remainder = (int) (seconds1 / 60); if (60 * remainder < seconds1) { remainder = (int) (seconds1 - (60 * remainder)); } else { remainder = 0; } seconds1 = remainder; } else { remainderMinutes = 0; } return (seconds / 3600) + "h " + remainderMinutes + "m " + seconds1 + "s"; } } /** * @return * The number in thousands with k at the end. */ private String getFormattedRunescapeNumber(int amount) { if (amount >= 1000) { return (amount / 1000) + "k"; } else { return amount + ""; } } private void updateExperienceGained() { int index = 0; skillsExperienceGained.clear(); for (Skill data : Skill.values()) { int currentXp = skills.getExperience(data); String[] parse = skillsExperienceStart.get(index).split(":"); int startXp = Integer.parseInt(parse[1]); if (currentXp > startXp) { int totalXp = currentXp - startXp; skillsExperienceGained.add(capitalize(parse[0]) + " xp: " + getFormattedRunescapeNumber(totalXp) + " (" + getFormattedRunescapeNumber(getExperienceperHour(totalXp)) + "/h)"); } index++; } } public int getExperienceperHour(int totalExperienceGained) { int minutes = (int) ((System.currentTimeMillis() - timeScriptStarted) / 60000); int beforeSeconds = 0; double multiplier = 1.0; if (minutes < 60) { beforeSeconds = (int) ((System.currentTimeMillis() - timeScriptStarted) / 1000); multiplier = 3600.0 / (double) beforeSeconds; minutes = 60; } double convert = (double) minutes; convert = convert / 60.0; return (int) ((totalExperienceGained / convert) * multiplier); } /** * Capitalize the first letter and other letters that before it is a space. * @param s * @return */ public static String capitalize(String s) { s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { if (i == 0) { s = String.format("%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1)); } if (!Character.isLetterOrDigit(s.charAt(i))) { if (i + 1 < s.length()) { s = String.format("%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2)); } } } return s; } public boolean areaHasPlayers() { Area area = myPlayer().getArea(10);//create your own area int amount = 0; for (Player player : players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())) { if (area.contains(player)) { amount++; } } } return amount > 0; } public void drawMouse(Graphics g) { ((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point p = mouse.getPosition(); Graphics2D spinG = (Graphics2D) g.create(); Graphics2D spinGRev = (Graphics2D) g.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, p.x, p.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, p.x, p.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } NMZ.jar 7.99 kB · 3 downloads Thank you! 1 Quote Link to comment Share on other sites More sharing options...
itumi Posted July 26, 2022 Share Posted July 26, 2022 Spoiler import java.awt.*; import java.util.ArrayList; import java.util.List; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.Objects; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.ui.RS2Widget; @ScriptManifest(author = "itumi", info = "Nightmare Zone", name = "NMZ", version = 1.2, logo = "") public class NMZ extends Script { private final Color BACKGROUND_COLOUR = new Color(0, 0, 0, 80); private final Color BACKGROUND_OUTLINE_CLOUR = new Color(0, 0, 0, 80); private final Color MAIN_TEXT_COLOUR = new Color(102, 188, 255); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font(Font.SANS_SERIF, 0, 12); private final int X = -134; private final int Y = 85; private final int BOX_ARC_AMOUNT = 8; private final String[] absorption_POTIONS = {"Absorption (1)", "Absorption (2)", "Absorption (3)", "Absorption (4)"}; private final String[] OVERLOAD_POTIONS = {"Overload (1)", "Overload (2)", "Overload (3)", "Overload (4)"}; private long timeScriptStarted = System.currentTimeMillis(); private String status = ""; private ArrayList<String> skillsExperienceStart = new ArrayList<String>(); private ArrayList<String> skillsExperienceGained = new ArrayList<String>(); private long timeToDrinkOverload; private int absorptionDosesToDrink; private long timeCanCake; @Override public void onStart() { setStatus("Script started."); for (Skill data : Skill.values()) { skillsExperienceStart.add(data.name() + ":" + skills.getExperience(data)); } } @Override public int onLoop() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) == 0) { setStatus("Player is 0 hp."); } if (areaHasPlayers()) { setStatus("Area has players, stop script"); stop(); } updateExperienceGained(); overload(); absorption(); antiBan(); cake(); findBoost(); return random(500, 1000); } private void cake() { if (System.currentTimeMillis() < timeCanCake) { return; } if (System.currentTimeMillis() < timeToDrinkOverload) { return; } if (skills.getDynamic(Skill.STRENGTH) > skills.getStatic(Skill.STRENGTH)) { if (skills.getDynamic(Skill.HITPOINTS) > 2) { setStatus("Eat"); inventory.interact(random(1, 15) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); moveMouse(3); } else if (skills.getDynamic(Skill.HITPOINTS) == 2) { long delay = random(61000, 170000); if (random(1, 7) == 1) { delay = random(170000, 360000); } if (random(1, 6) == 1) { // Do not guzzle. } else { setStatus("Eat"); inventory.interact("Guzzle", "Dwarven rock cake"); } moveMouse(3); timeCanCake = System.currentTimeMillis() + delay; } } } private void moveMouse(int i) { // TODO Auto-generated method stub } private void antiBan() throws InterruptedException { if (random(1, 200) == 1) { setStatus("Anti-ban: Random mouse"); moveMouse(1); } if (random(1, 300) == 1) { moveMouse(2); if (skills.getCombat().getSpecialPercentage() >= 55) { skills.getCombat().toggleSpecialAttack(true); setStatus("Anti-ban: Special attack"); } } if (random(1, 300) == 1) { int random = random(1, 50); if (random <= 5) { absorptionDosesToDrink = random(1, 2); setStatus("Anti-ban: Drink absorption"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 25) { attackRandomTarget(); } else if (random <= 30) { getWalking().walk(new Position((myPlayer().getX() - 10) + random(0, 10), (myPlayer().getY() - 10) + random(0, 10), myPlayer().getHeight())); setStatus("Anti-ban: Walk"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 40) { random = random(1, 10); if (random <= 4) { setStatus("Anti-ban: Friends tab"); getTabs().open(Tab.FRIENDS); sleep(random(3000, 10000)); getTabs().open(Tab.INVENTORY); } else if (random <= 7) { setStatus("Anti-ban: Attack tab"); getTabs().open(Tab.ATTACK); sleep(random(3000, 7000)); getTabs().open(Tab.INVENTORY); } else if (random <= 10) { setStatus("Anti-ban: Skills tab"); getTabs().open(Tab.SKILLS); sleep(random(4000, 12000)); getTabs().open(Tab.INVENTORY); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 50) { if (System.currentTimeMillis() < timeCanCake) { attackRandomTarget(); return; } if (skills.getDynamic(Skill.HITPOINTS) > 1) { setStatus("Anti-ban: Eat cake"); inventory.interact(random(1, 2) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } } } private void findBoost() throws InterruptedException { RS2Object zapper = getObjects().closestThatContains("Zapper"); if (zapper != null) { setStatus("Found Zapper"); sleep(random(2000, 10000)); zapper.interact("Activate"); sleep(random(2000, 10000)); } RS2Object recurrent_damage = getObjects().closestThatContains("Recurrent damage"); if (recurrent_damage != null) { setStatus("Found Recurrent damage"); sleep(random(2000, 10000)); recurrent_damage.interact("Activate"); sleep(random(2000, 10000)); } } private void attackRandomTarget() throws InterruptedException { List<NPC> allNpcs = npcs.getAll(); for (NPC npc : allNpcs) { if (npc == null) { continue; } if (!npc.exists()) { continue; } if (!npc.isVisible()) { continue; } if (random(1, 2) == 1) { continue; } npc.interact("Attack"); setStatus("Anti-ban: Switch target"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); break; } } private void absorption() { if (absorptionDosesToDrink > 0) { setStatus("Drinking absorption"); inventory.interact("Drink", absorption_POTIONS); moveMouse(10); absorptionDosesToDrink--; if (absorptionDosesToDrink == 0) { timeCanCake = System.currentTimeMillis() + random(500, 7000); } } } private void overload() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) < 51) { return; } if (timeToDrinkOverload == 0) { if (skills.getDynamic(Skill.STRENGTH) == skills.getStatic(Skill.STRENGTH)) { setStatus("Will overload shortly"); long delay = random(2000, 20000); if (random(1, 6) == 1) { delay = random(20000, 120000); setStatus("Will overload longly"); } timeToDrinkOverload = System.currentTimeMillis() + delay; } return; } if (System.currentTimeMillis() > timeToDrinkOverload) { setStatus("Drinking overload"); timeCanCake = System.currentTimeMillis() + random(10000, 25000); inventory.interact("Drink", OVERLOAD_POTIONS); timeToDrinkOverload = 0; moveMouse(3); sleep(random(1000, 8000)); absorptionDosesToDrink = random(2, 7); } } @Override public void onExit() { setStatus("Script ended."); } @Override public void onPaint(Graphics2D g) { int ySize = skillsExperienceGained.size() * 16; g.setColor(BACKGROUND_COLOUR); g.fillRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setColor(BACKGROUND_OUTLINE_CLOUR); g.setStroke(stroke1); g.drawRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setFont(font1); g.setColor(MAIN_TEXT_COLOUR); g.drawString("Duration: " + getRuntime(), 147 + X, 24 + Y); g.drawString("Last action: " + status, 147 + X, 40 + Y); for (int index = 0; index < skillsExperienceGained.size(); index++) { g.drawString(skillsExperienceGained.get(index), 147 + X, 40 + Y + ((index + 1) * 16)); } drawMouse(g); } private void setStatus(String status) { log("Status: " + status); this.status = status; } /** * Get time since script started. */ private String getRuntime() { long seconds = (System.currentTimeMillis() - timeScriptStarted) / 1000; if (seconds < 60) { return seconds + "s"; } else if (seconds < 3600) { int remainder = (int) (seconds / 60); if (60 * remainder < seconds) { remainder = (int) (seconds - (60 * remainder)); } else { remainder = 0; } return (seconds / 60) + "m " + remainder + "s"; } else { int remainderMinutes = (int) seconds / 3600; int seconds1 = 0; if (3600 * remainderMinutes < seconds) { remainderMinutes = (int) (seconds - (3600 * remainderMinutes)); seconds1 = remainderMinutes; remainderMinutes /= 60; int remainder = (int) (seconds1 / 60); if (60 * remainder < seconds1) { remainder = (int) (seconds1 - (60 * remainder)); } else { remainder = 0; } seconds1 = remainder; } else { remainderMinutes = 0; } return (seconds / 3600) + "h " + remainderMinutes + "m " + seconds1 + "s"; } } /** * @return * The number in thousands with k at the end. */ private String getFormattedRunescapeNumber(int amount) { if (amount >= 1000) { return (amount / 1000) + "k"; } else { return amount + ""; } } private void updateExperienceGained() { int index = 0; skillsExperienceGained.clear(); for (Skill data : Skill.values()) { int currentXp = skills.getExperience(data); String[] parse = skillsExperienceStart.get(index).split(":"); int startXp = Integer.parseInt(parse[1]); if (currentXp > startXp) { int totalXp = currentXp - startXp; skillsExperienceGained.add(capitalize(parse[0]) + " xp: " + getFormattedRunescapeNumber(totalXp) + " (" + getFormattedRunescapeNumber(getExperienceperHour(totalXp)) + "/h)"); } index++; } } public int getExperienceperHour(int totalExperienceGained) { int minutes = (int) ((System.currentTimeMillis() - timeScriptStarted) / 60000); int beforeSeconds = 0; double multiplier = 1.0; if (minutes < 60) { beforeSeconds = (int) ((System.currentTimeMillis() - timeScriptStarted) / 1000); multiplier = 3600.0 / (double) beforeSeconds; minutes = 60; } double convert = (double) minutes; convert = convert / 60.0; return (int) ((totalExperienceGained / convert) * multiplier); } /** * Capitalize the first letter and other letters that before it is a space. * @param s * @return */ public static String capitalize(String s) { s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { if (i == 0) { s = String.format("%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1)); } if (!Character.isLetterOrDigit(s.charAt(i))) { if (i + 1 < s.length()) { s = String.format("%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2)); } } } return s; } public boolean areaHasPlayers() { Area area = myPlayer().getArea(10);//create your own area int amount = 0; for (Player player : players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())) { if (area.contains(player)) { amount++; } } } return amount > 0; } public void drawMouse(Graphics g) { ((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point p = mouse.getPosition(); Graphics2D spinG = (Graphics2D) g.create(); Graphics2D spinGRev = (Graphics2D) g.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, p.x, p.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, p.x, p.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } Fixed the code again, added recurrent damage and zapper pick up function. Spoiler import java.awt.*; import java.util.ArrayList; import java.util.List; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.Objects; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.Player; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.ui.Tab; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.api.ui.RS2Widget; @ScriptManifest(author = "itumi", info = "Nightmare Zone", name = "NMZ", version = 1.2, logo = "") public class NMZ extends Script { private final Color BACKGROUND_COLOUR = new Color(0, 0, 0, 80); private final Color BACKGROUND_OUTLINE_CLOUR = new Color(0, 0, 0, 80); private final Color MAIN_TEXT_COLOUR = new Color(102, 188, 255); private final BasicStroke stroke1 = new BasicStroke(1); private final Font font1 = new Font(Font.SANS_SERIF, 0, 12); private final int X = -134; private final int Y = 85; private final int BOX_ARC_AMOUNT = 8; private final String[] absorption_POTIONS = {"Absorption (1)", "Absorption (2)", "Absorption (3)", "Absorption (4)"}; private final String[] OVERLOAD_POTIONS = {"Overload (1)", "Overload (2)", "Overload (3)", "Overload (4)"}; private long timeScriptStarted = System.currentTimeMillis(); private String status = ""; private ArrayList<String> skillsExperienceStart = new ArrayList<String>(); private ArrayList<String> skillsExperienceGained = new ArrayList<String>(); private long timeToDrinkOverload; private int absorptionDosesToDrink; private long timeCanCake; @Override public void onStart() { setStatus("Script started."); for (Skill data : Skill.values()) { skillsExperienceStart.add(data.name() + ":" + skills.getExperience(data)); } } @Override public int onLoop() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) == 0) { setStatus("Player is 0 hp."); } if (areaHasPlayers()) { setStatus("Area has players, stop script"); stop(); } updateExperienceGained(); overload(); absorption(); antiBan(); cake(); findBoost(); return random(500, 1000); } private void cake() { if (System.currentTimeMillis() < timeCanCake) { return; } if (System.currentTimeMillis() < timeToDrinkOverload) { return; } if (skills.getDynamic(Skill.STRENGTH) > skills.getStatic(Skill.STRENGTH)) { if (skills.getDynamic(Skill.HITPOINTS) > 2) { setStatus("Eat"); inventory.interact(random(1, 15) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); moveMouse(3); } else if (skills.getDynamic(Skill.HITPOINTS) == 2) { long delay = random(61000, 170000); if (random(1, 7) == 1) { delay = random(170000, 360000); } if (random(1, 6) == 1) { // Do not guzzle. } else { setStatus("Eat"); inventory.interact("Guzzle", "Dwarven rock cake"); } moveMouse(3); timeCanCake = System.currentTimeMillis() + delay; } } } private void moveMouse(int i) { // TODO Auto-generated method stub } private void antiBan() throws InterruptedException { if (random(1, 200) == 1) { setStatus("Anti-ban: Random mouse"); moveMouse(1); } if (random(1, 300) == 1) { moveMouse(2); if (skills.getCombat().getSpecialPercentage() >= 55) { skills.getCombat().toggleSpecialAttack(true); setStatus("Anti-ban: Special attack"); } } if (random(1, 300) == 1) { int random = random(1, 50); if (random <= 5) { absorptionDosesToDrink = random(1, 2); setStatus("Anti-ban: Drink absorption"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 25) { attackRandomTarget(); } else if (random <= 30) { getWalking().walk(new Position((myPlayer().getX() - 10) + random(0, 10), (myPlayer().getY() - 10) + random(0, 10), myPlayer().getHeight())); setStatus("Anti-ban: Walk"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 40) { random = random(1, 10); if (random <= 4) { setStatus("Anti-ban: Friends tab"); getTabs().open(Tab.FRIENDS); sleep(random(3000, 10000)); getTabs().open(Tab.INVENTORY); } else if (random <= 7) { setStatus("Anti-ban: Attack tab"); getTabs().open(Tab.ATTACK); sleep(random(3000, 7000)); getTabs().open(Tab.INVENTORY); } else if (random <= 10) { setStatus("Anti-ban: Skills tab"); getTabs().open(Tab.SKILLS); sleep(random(4000, 12000)); getTabs().open(Tab.INVENTORY); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } else if (random <= 50) { if (System.currentTimeMillis() < timeCanCake) { attackRandomTarget(); return; } if (skills.getDynamic(Skill.HITPOINTS) > 1) { setStatus("Anti-ban: Eat cake"); inventory.interact(random(1, 2) == 1 ? "Guzzle" : "Eat", "Dwarven rock cake"); } sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); } } } private void findBoost() throws InterruptedException { RS2Object zapper = getObjects().closestThatContains("Zapper"); if (zapper != null) { setStatus("Found Zapper"); sleep(random(2000, 10000)); zapper.interact("Activate"); sleep(random(2000, 10000)); } RS2Object recurrent_damage = getObjects().closestThatContains("Recurrent damage"); if (recurrent_damage != null) { setStatus("Found Recurrent damage"); sleep(random(2000, 10000)); recurrent_damage.interact("Activate"); sleep(random(2000, 10000)); } } private void attackRandomTarget() throws InterruptedException { List<NPC> allNpcs = npcs.getAll(); for (NPC npc : allNpcs) { if (npc == null) { continue; } if (!npc.exists()) { continue; } if (!npc.isVisible()) { continue; } if (random(1, 2) == 1) { continue; } npc.interact("Attack"); setStatus("Anti-ban: Switch target"); sleep(random(2000, 10000)); skills.getMouse().moveOutsideScreen(); break; } } private void absorption() { if (absorptionDosesToDrink > 0) { setStatus("Drinking absorption"); inventory.interact("Drink", absorption_POTIONS); moveMouse(10); absorptionDosesToDrink--; if (absorptionDosesToDrink == 0) { timeCanCake = System.currentTimeMillis() + random(500, 7000); } } } private void overload() throws InterruptedException { if (skills.getDynamic(Skill.HITPOINTS) < 51) { return; } if (timeToDrinkOverload == 0) { if (skills.getDynamic(Skill.STRENGTH) == skills.getStatic(Skill.STRENGTH)) { setStatus("Will overload shortly"); long delay = random(2000, 20000); if (random(1, 6) == 1) { delay = random(20000, 120000); setStatus("Will overload longly"); } timeToDrinkOverload = System.currentTimeMillis() + delay; } return; } if (System.currentTimeMillis() > timeToDrinkOverload) { setStatus("Drinking overload"); timeCanCake = System.currentTimeMillis() + random(10000, 25000); inventory.interact("Drink", OVERLOAD_POTIONS); timeToDrinkOverload = 0; moveMouse(3); sleep(random(1000, 8000)); absorptionDosesToDrink = random(2, 7); } } @Override public void onExit() { setStatus("Script ended."); } @Override public void onPaint(Graphics2D g) { int ySize = skillsExperienceGained.size() * 16; g.setColor(BACKGROUND_COLOUR); g.fillRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setColor(BACKGROUND_OUTLINE_CLOUR); g.setStroke(stroke1); g.drawRoundRect(143 + X, 8 + Y, 211, 40 + ySize, BOX_ARC_AMOUNT, BOX_ARC_AMOUNT); g.setFont(font1); g.setColor(MAIN_TEXT_COLOUR); g.drawString("Duration: " + getRuntime(), 147 + X, 24 + Y); g.drawString("Last action: " + status, 147 + X, 40 + Y); for (int index = 0; index < skillsExperienceGained.size(); index++) { g.drawString(skillsExperienceGained.get(index), 147 + X, 40 + Y + ((index + 1) * 16)); } drawMouse(g); } private void setStatus(String status) { log("Status: " + status); this.status = status; } /** * Get time since script started. */ private String getRuntime() { long seconds = (System.currentTimeMillis() - timeScriptStarted) / 1000; if (seconds < 60) { return seconds + "s"; } else if (seconds < 3600) { int remainder = (int) (seconds / 60); if (60 * remainder < seconds) { remainder = (int) (seconds - (60 * remainder)); } else { remainder = 0; } return (seconds / 60) + "m " + remainder + "s"; } else { int remainderMinutes = (int) seconds / 3600; int seconds1 = 0; if (3600 * remainderMinutes < seconds) { remainderMinutes = (int) (seconds - (3600 * remainderMinutes)); seconds1 = remainderMinutes; remainderMinutes /= 60; int remainder = (int) (seconds1 / 60); if (60 * remainder < seconds1) { remainder = (int) (seconds1 - (60 * remainder)); } else { remainder = 0; } seconds1 = remainder; } else { remainderMinutes = 0; } return (seconds / 3600) + "h " + remainderMinutes + "m " + seconds1 + "s"; } } /** * @return * The number in thousands with k at the end. */ private String getFormattedRunescapeNumber(int amount) { if (amount >= 1000) { return (amount / 1000) + "k"; } else { return amount + ""; } } private void updateExperienceGained() { int index = 0; skillsExperienceGained.clear(); for (Skill data : Skill.values()) { int currentXp = skills.getExperience(data); String[] parse = skillsExperienceStart.get(index).split(":"); int startXp = Integer.parseInt(parse[1]); if (currentXp > startXp) { int totalXp = currentXp - startXp; skillsExperienceGained.add(capitalize(parse[0]) + " xp: " + getFormattedRunescapeNumber(totalXp) + " (" + getFormattedRunescapeNumber(getExperienceperHour(totalXp)) + "/h)"); } index++; } } public int getExperienceperHour(int totalExperienceGained) { int minutes = (int) ((System.currentTimeMillis() - timeScriptStarted) / 60000); int beforeSeconds = 0; double multiplier = 1.0; if (minutes < 60) { beforeSeconds = (int) ((System.currentTimeMillis() - timeScriptStarted) / 1000); multiplier = 3600.0 / (double) beforeSeconds; minutes = 60; } double convert = (double) minutes; convert = convert / 60.0; return (int) ((totalExperienceGained / convert) * multiplier); } /** * Capitalize the first letter and other letters that before it is a space. * @param s * @return */ public static String capitalize(String s) { s = s.toLowerCase(); for (int i = 0; i < s.length(); i++) { if (i == 0) { s = String.format("%s%s", Character.toUpperCase(s.charAt(0)), s.substring(1)); } if (!Character.isLetterOrDigit(s.charAt(i))) { if (i + 1 < s.length()) { s = String.format("%s%s%s", s.subSequence(0, i + 1), Character.toUpperCase(s.charAt(i + 1)), s.substring(i + 2)); } } } return s; } public boolean areaHasPlayers() { Area area = myPlayer().getArea(10);//create your own area int amount = 0; for (Player player : players.getAll()) { if (player != null && !player.getName().equalsIgnoreCase(myPlayer().getName())) { if (area.contains(player)) { amount++; } } } return amount > 0; } public void drawMouse(Graphics g) { ((Graphics2D) g).setRenderingHints(new RenderingHints(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON)); Point p = mouse.getPosition(); Graphics2D spinG = (Graphics2D) g.create(); Graphics2D spinGRev = (Graphics2D) g.create(); spinG.setColor(new Color(255, 255, 255)); spinGRev.setColor(Color.cyan); spinG.rotate(System.currentTimeMillis() % 2000d / 2000d * (360d) * 2 * Math.PI / 180.0, p.x, p.y); spinGRev.rotate(System.currentTimeMillis() % 2000d / 2000d * (-360d) * 2 * Math.PI / 180.0, p.x, p.y); final int outerSize = 20; final int innerSize = 12; spinG.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinGRev.setStroke(new BasicStroke(1.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND)); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, 100, 75); spinG.drawArc(p.x - (outerSize / 2), p.y - (outerSize / 2), outerSize, outerSize, -100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, 100, 75); spinGRev.drawArc(p.x - (innerSize / 2), p.y - (innerSize / 2), innerSize, innerSize, -100, 75); } } Quote Link to comment Share on other sites More sharing options...
itumi Posted July 26, 2022 Share Posted July 26, 2022 .jar download Quote Link to comment Share on other sites More sharing options...