Shunrai 0 Posted March 13, 2021 Hello lads! I am quite new to scripting in Java and DreamBot but I made a simple Kebab Buyer and Banker today and decided to share it with you for feedback, even though it's not something special and I feel quite embarrassed for even posting it, here it is! It has a camera randomizer (Made in a quite basic way, there's probably a more efficient one) when it gets to Karim, will sometimes afk based on the randomizer I implemented in it. package DonerFinesser; import org.dreambot.api.Client; import org.dreambot.api.input.Mouse; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.MethodProvider; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.Shop; import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.dialogues.Dialogues; import org.dreambot.api.methods.input.Camera; import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.Timer; import org.dreambot.api.wrappers.interactive.NPC; import javax.imageio.ImageIO; import java.awt.*; import java.io.IOException; import java.net.URL; @ScriptManifest(category = Category.MONEYMAKING, name = "Kebab Finesser", author = "Shunrai#4174", version = 1.0) public class KebabFinesser extends AbstractScript { int karimcam = 0; int bruh = 0; int bruh2 = 0; int bruh3 = 0; int bruh4 = 0; int kebabsfinessed = 0; private Timer timer; private Image image; @Override public void onStart() { timer = new Timer(); try { image = ImageIO.read(new URL("https://i.imgur.com/CIL79ag.png")); } catch(IOException e){ log("Failed to load image"); } log("Hi"); } @Override public void onPaint(Graphics g) { if (image != null) { g.drawImage(image, 0, 430, null); g.setColor(Color.RED); g.setFont(new Font( "Times New Roman", Font.BOLD, 16)); g.drawString("Shunrai go BRRRRrrrrr....", 5, 482); g.drawString("Kebabs Finessed:" + kebabsfinessed, 5, 522); g.drawString("Time:" + timer.formatTime(), 5, 552); } } @Override public int onLoop() { NPC karim; Area area = new Area(3271, 3182, 3275, 3179); if (Inventory.isFull()) { log("Attempting to bank"); if (!Bank.isOpen()) { Bank.openClosest(); return(Calculations.random(765, 1892)); } if(Bank.isOpen()) { if(Inventory.isFull()) { Bank.depositAllExcept(995); } } } if(Bank.isOpen() && !Inventory.contains(1971)) { Bank.close(); karimcam = 1; ///random breaks bruh3++; if (bruh3 > 10){ bruh4++; if (bruh4 < (Calculations.random(-5, 11)) || bruh4 > 11){ bruh3 = 0; bruh4 = 0; return(Calculations.random(30000, 70000)); } } /// return (Calculations.random(765, 1892)); } if (!area.contains(Players.localPlayer().getTile())) { Walking.walk(area.getRandomTile()); return(Calculations.random(800, 2000)); } if (karimcam == 0) { Tile karimTile = NPCs.closest("Karim").getTile(); Camera.mouseRotateToTile((new Tile(karimTile.getX() + Calculations.random(-2, 3), karimTile.getY() + Calculations.random(-2, 3)))); karimcam = 1; } if (!Dialogues.inDialogue()) { karim = NPCs.closest("Karim"); if (karim != null && karim.exists()) { karim.interact("Talk-to"); Mouse.move(); sleepUntil(() -> getLocalPlayer().getHealthPercent() < 25 || Dialogues.inDialogue(), 6000); return(Calculations.random(200, 500)); } } if (Dialogues.inDialogue()){ log("In dialogue boi"); if (Dialogues.canContinue()){ Dialogues.continueDialogue(); return(Calculations.random(200, 500)); } if (Dialogues.getOptions() != null){ Dialogues.typeOption(2); ///random breaks bruh++; if (bruh > 40){ bruh2++; if (bruh2 < (Calculations.random(-5, 11)) || bruh2 > 11){ bruh = 0; bruh2 = 0; return(Calculations.random(10000, 20000)); } } /// kebabsfinessed++; return(Calculations.random(100, 400)); } } else { log("Not in dialog"); } return 400; } }
mad man 1 Posted March 15, 2021 Not sure what your script do (Don't know what's the deal with the Kebab. I am also new here so, but I have experience as a programmer, so my comments are more about design. Always assume that someone else need to read your code and understand it. Why? Think about you in a year, will you remember everything here? for example this 'Bank.depositAllExcept(995);'? When you work with others, you save them a lot of time when your code is clear and understandable. Use global constants for .. constants What you need to do? More comments. I have no clue what the randoms breaks do. Better naming (area of what? what is it bruh?). Extract to global constant: area (And give it a clear name), dialog option (With Name of what this option do), action 'Talk-to', every inventory item (You can use strings, but even if you use string extract it to global), Maybe also Karim himself. You wrote everything in a big loop, you can extract some of it to functions that can be reusable in other places. For example depositToBank(Bank bank, List<Item> ItemsToKeep) which can be reusable in many scripts. It's looks cool in general, and you getting good skills here, good job and good luck
Shunrai 0 Author Posted March 15, 2021 1 hour ago, mad man said: Not sure what your script do (Don't know what's the deal with the Kebab. I am also new here so, but I have experience as a programmer, so my comments are more about design. Always assume that someone else need to read your code and understand it. Why? Think about you in a year, will you remember everything here? for example this 'Bank.depositAllExcept(995);'? When you work with others, you save them a lot of time when your code is clear and understandable. Use global constants for .. constants What you need to do? More comments. I have no clue what the randoms breaks do. Better naming (area of what? what is it bruh?). Extract to global constant: area (And give it a clear name), dialog option (With Name of what this option do), action 'Talk-to', every inventory item (You can use strings, but even if you use string extract it to global), Maybe also Karim himself. You wrote everything in a big loop, you can extract some of it to functions that can be reusable in other places. For example depositToBank(Bank bank, List<Item> ItemsToKeep) which can be reusable in many scripts. It's looks cool in general, and you getting good skills here, good job and good luck Oh, I din't think about any of this. Thank you! Will try naming my stuff and labeling it better if I post something next time!
Recommended Posts
Archived
This topic is now archived and is closed to further replies.