sacred brids 1 Posted April 14, 2017 I'm currently working on a Fisher as my first script. How would I move my character to the closet Fishing Spot and start fishing at it after the one it's at goes away? Also how would I stop it from spamming the fishing spot? Also it doesn't seem to even start fishing my code is below. package fisher; import org.dreambot.api.methods.Calculations; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.wrappers.interactive.NPC; @ScriptManifest(author = "Untouchable", name = "Untouchable Barb Fisher", version = 1.1, description = "Barbian Rod Fishing", category = Category.FISHING) public class main extends AbstractScript { public void onStart() { log("Welcome to Barbian Rod Fishing by Untouchable."); log("Starting Advanced Antiban System"); log("Starting to Power Fish on Your Account Now!"); } private enum State { FISH, DROP, WAIT }; private State getState() { if (!getInventory().onlyContains("Barbarian rod", "Fishing bait") && (getInventory().contains("Leaping trout") || getInventory().contains("Leaping salmon"))) return State.DROP; else if ( !getLocalPlayer().isAnimating() && getInventory().contains("Barbarian rod") && getInventory().contains("Fishing bait")) return State.FISH; else return State.WAIT; } public void onExit() { } @Override public int onLoop() { switch (getState()) { case FISH: NPC fishingSpot = getNpcs().closest("Fishing spot"); boolean one = fishingSpot !=null; log("1" + one); if (fishingSpot != null ) { log("4"); fishingSpot.interact("Use-rod"); sleep(600); } break; case DROP: log("2"); if (getInventory().contains("Leaping trout")) getInventory().dropAll("Leaping trout"); if (getInventory().contains("Leaping salmon")) getInventory().dropAll("Leaping salmon"); break; case WAIT: log("3"); sleep(300); break; } return Calculations.random(500, 600); } }
Donald Trump 333 Posted April 14, 2017 Not sure if this is good or not but this is how I would do it. Hope it helps anyone at least but please just read the API it's easier unless you're not at that stage yet. GameObject FISH_SPOT = getGameObjects().closest("Fishing Spot"); FISH_SPOT.interact("Net"); sleepUntil(() -> !FISH_SPOT.isOnScreen() || getInventory().isFull(), Calculations.random(100, 150)); if (getInventory().isFull()) { getInventory().dropAllExcept("Small fishing net"); }
sacred brids 1 Author Posted April 14, 2017 Not sure if this is good or not but this is how I would do it. Hope it helps anyone at least but please just read the API it's easier unless you're not at that stage yet. GameObject FISH_SPOT = getGameObjects().closest("Fishing Spot"); FISH_SPOT.interact("Net"); sleepUntil(() -> !FISH_SPOT.isOnScreen() || getInventory().isFull(), Calculations.random(100, 150)); if (getInventory().isFull()) { getInventory().dropAllExcept("Small fishing net"); } That would only work if it was on screen. I'm doing a Barb Fisher so sometimes the next fishing spot that's closest is not on screen.
Zibele 18 Posted April 14, 2017 If the fishing spots have different ID's you could use the ID's,if they don't you could use the coordinates of the fishing spot object/npc. And you can just null check the fishing spot,if it is null switch to next available spot.
Genius 50 Posted April 16, 2017 That would only work if it was on screen. I'm doing a Barb Fisher so sometimes the next fishing spot that's closest is not on screen. Building off of Donald Trump's example.. GameObject FISH_SPOT = getGameObjects().closest(f -> f != null && f.getName().equals("Fishing Spot"); //you can also use IDs here instead (f.getID() == 123) where 123 is the ID you want if (FISH_SPOT.isOnScreen()) { FISH_SPOT.interact("Net"); sleepUntil(() -> getLocalPlayer().isAnimating(), Calculations.Random(2500,5000); do { //antiban here sleep(500,2000); } while (!getInventory().isFull() && getLocalPlayer().isAnimating()); //there might be a better way than isAnimating, I'm typing this on the forums so I don't have access to the API } else { getWalking().walk(FISH_SPOT.getTile()); } if (getInventory().isFull()) { getInventory().dropAllExcept("Small fishing net"); }
sacred brids 1 Author Posted April 17, 2017 Building off of Donald Trump's example.. GameObject FISH_SPOT = getGameObjects().closest(f -> f != null && f.getName().equals("Fishing Spot"); //you can also use IDs here instead (f.getID() == 123) where 123 is the ID you want if (FISH_SPOT.isOnScreen()) { FISH_SPOT.interact("Net"); sleepUntil(() -> getLocalPlayer().isAnimating(), Calculations.Random(2500,5000); do { //antiban here sleep(500,2000); } while (!getInventory().isFull() && getLocalPlayer().isAnimating()); //there might be a better way than isAnimating, I'm typing this on the forums so I don't have access to the API } else { getWalking().walk(FISH_SPOT.getTile()); } if (getInventory().isFull()) { getInventory().dropAllExcept("Small fishing net"); } So I would have to define a Tile for the Fishing Spot if I were to use this right?
Genius 50 Posted April 17, 2017 So I would have to define a Tile for the Fishing Spot if I were to use this right? No, the client automatically gets the GameObject's tile for you. an example: //this will find the closest game object that isn't null (it's fishable) and whose name equals Fishing spot. Call this using nodes or in a method in your loop so that it is updated in real time. GameObject spot= getGameObjects().closest(i -> i != null && i.getName().equals("Fishing spot")); log(String.valueOf(spot.getTile())); //prints the not-null fishing spot's tile to the debug console. if (!spot.isOnScreen()) { getWalking().walk(spot.getTile()); } else { //put your fishing method here. } If you look at the API for GameObjects you will see that there is a lot of information that the client can give you about various objects/items. If you need more help, shoot me a PM.
sacred brids 1 Author Posted April 17, 2017 No, the client automatically gets the GameObject's tile for you. an example: //this will find the closest game object that isn't null (it's fishable) and whose name equals Fishing spot. Call this using nodes or in a method in your loop so that it is updated in real time. GameObject spot= getGameObjects().closest(i -> i != null && i.getName().equals("Fishing spot")); log(String.valueOf(spot.getTile())); //prints the not-null fishing spot's tile to the debug console. if (!spot.isOnScreen()) { getWalking().walk(spot.getTile()); } else { //put your fishing method here. } If you look at the API for GameObjects you will see that there is a lot of information that the client can give you about various objects/items. If you need more help, shoot me a PM. Awesome going to try this and see if I can get it working. If I need help I'll shoot you a pm.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.