mrbankseed 0 Posted March 1, 2023 import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.container.bank.Bank; import org.dreambot.api.methods.container.inventory.Inventory; import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Map; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.methods.skills.SkillTracker; import org.dreambot.api.methods.tabs.Tab; import org.dreambot.api.methods.walking.pathfinding.impl.web.WebPathFinder; import org.dreambot.api.methods.walking.web.node.impl.bank.WebBank; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.GameObject; @ScriptManifest(author = "YourName", name = "FishingScript", version = 1.0) public class FishingScript extends AbstractScript { // Areas and objects needed for the script private Area karamjaFishingArea = new Area(2852, 3142, 2871, 3161); private Area portSarimBankArea = new Area(3044, 3234, 3048, 3242); private GameObject karamjaFishingSpot; private GameObject portSarimDepositBox; // Fish to be caught private String[] fishToCatch = {"Lobster", "Tuna", "Swordfish"}; @Override public int onLoop() { // Check if the player has the required fishing level if (getSkills().getRealLevel(Skill.FISHING) < 40) { log("You need a fishing level of 40 to fish in Karamja."); stop(); } // Check if the player has a lobster cage or harpoon if (!Inventory.contains("Lobster cage") && !Inventory.contains("Harpoon")) { log("You need a lobster cage or harpoon to fish in Karamja."); stop(); } // Check if the player is at the fishing spot if (!karamjaFishingArea.contains(getLocalPlayer())) { getWalking().walk(new WebBank().getNearestBankLocation().getWebPath()); sleepUntil(() -> Bank.isOpen(), Calculations.random(2000, 3000)); Bank.open(Tab.INVENTORY); Bank.withdraw("Lobster cage", 1); Bank.withdraw("Harpoon", 1); Bank.close(); getWalking().walk(karamjaFishingArea.getRandomTile()); } // Check if the fishing spot is available if (karamjaFishingSpot == null || !karamjaFishingSpot.exists()) { karamjaFishingSpot = GameObjects.closest("Fishing spot"); } // Fish at the fishing spot if it is available if (karamjaFishingSpot != null && karamjaFishingSpot.exists())
holic 238 Posted March 1, 2023 Why are you calling getWalking instead of just Walking? Also in the future you should post what you need help with, not just post all your code and hope someone finishes it for you
Aeglen 423 Posted March 1, 2023 That code is just the right amount of incoherent and dated I'd be willing to bet it was written by ChatGPT
una_maquina 36 Posted March 3, 2023 You're using dreambot 2 API, instead of dreambot 3 which is the latest. In the current API you don't need to call methods using getWalking#walk, for example, you just do Walking#walk(tile). Same for, "getSkills().getRealLevel(Skill.FISHING) < 40", instead you just do Skills.getRealLevel(Skill.FISHING)
mrbankseed 0 Author Posted March 4, 2023 Here's another one for you guys to roast me about: import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.script.Category; import org.dreambot.api.wrappers.interactive.GameObject; @ScriptManifest(author = "You", name = "Varrock Agility Course", version = 1.0, description = "Completes the Varrock Agility Course", category = Category.AGILITY) public class VarrockAgilityCourse extends AbstractScript { private static final int OBSTACLE_PIPE_ID = 14929; private static final int ZIP_LINE_ID = 14832; private static final int WALL_CLIMB_ID = 14898; private static final int BALANCING_LEDGE_ID = 14903; private static final int STEPPING_STONES_ID = 14897; private static final int ROPE_SWING_ID = 14897; private static final int LOG_BALANCE_ID = 14922; private static final int RUN_ENERGY_THRESHOLD = 20; private static final int REST_TIME_MS = 2000; private static final int COURSE_START_X = 3204; private static final int COURSE_START_Y = 3416; private static final int COURSE_START_Z = 0; private static final int[] OBSTACLE_ORDER = { WALL_CLIMB_ID, ROPE_SWING_ID, STEPPING_STONES_ID, LOG_BALANCE_ID, OBSTACLE_PIPE_ID, BALANCING_LEDGE_ID, ZIP_LINE_ID }; private int getNextObstacle() { for (int id : OBSTACLE_ORDER) { GameObject obstacle = getGameObjects().closest(id); if (obstacle != null && obstacle.isOnScreen()) { return id; } } return -1; } @Override public void onStart() { log("Starting Varrock Agility Course script..."); } @Override public int onLoop() { int energy = getWalking().getRunEnergy(); if (energy < RUN_ENERGY_THRESHOLD) { log("Energy is low, resting for " + REST_TIME_MS / 1000 + " seconds..."); sleep(REST_TIME_MS); } else { int nextObstacle = getNextObstacle(); if (nextObstacle == -1) { log("Unable to find any obstacles. Ending script."); stop(); return -1; } else { log("Next obstacle: " + nextObstacle); getGameObjects().closest(nextObstacle).interact(); } } return Calculations.random(500, 1000); } @Override public void onExit() { log("Stopping Varrock Agility Course script..."); } @Override public void onPaint(Graphics graphics) { // Optional: Add paint } }
Recommended Posts
Archived
This topic is now archived and is closed to further replies.