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 org.tribot.api.Timing;
- import org.tribot.api.General;
- import org.tribot.api2007.Screen;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.types.RSGroundItem;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import org.tribot.script.interfaces.Pausing;
- import org.tribot.script.interfaces.RandomEvents;
- @ScriptManifest(authors = { "Okokokok" }, category = "ok_StarterPack", name = "ok_StarterFisher")
- public class ok_StarterFisher extends Script implements Painting, Pausing, RandomEvents {
- boolean paused,
- bank = false,
- drop = true;
- private int plane = Player.getPosition().getPlane();
- final int planes = Player.getPosition().getPlane();
- private double version = 1.00;
- private final String netName = "Small fishing net",
- fishingSpotName = "Fishing spot",
- fishingSpotOption = "Net",
- shrimpName = "Raw shrimps",
- anchoviesName = "Raw anchovies",
- stairsName = "Staircase",
- stairsUpOption = "Climb-up",
- stairsDownOption = "Climb-down",
- takeOption = "Take";
- private final String[] fishNames = {shrimpName, anchoviesName};
- public RSArea deathArea = new RSArea(new RSTile(3216, 3208, 0), new RSTile(3226, 3224, 0)),
- bankArea = new RSArea(new RSTile(3207, 3215, 2), new RSTile(3210, 3221, 2)),
- fishingArea = new RSArea(new RSTile(3236, 3140, 0), new RSTile(3247, 3161, 0)),
- stairArea = new RSArea(new RSTile(3204, 3207), new RSTile(3209, 3211)),
- walkArea = new RSArea(new RSTile(3204, 3140, 0), new RSTile(3246, 3227, 0)),
- noFishArea = new RSArea(new RSTile(3244, 3156, 0), new RSTile(3245, 3158, 0));
- private final RSTile noFishTile = new RSTile(3246, 3157, 0),
- netsTile = new RSTile(3243, 3155, 0);
- private final RSTile[] stairsPathUp = new RSTile[] {new RSTile(3207, 3219, 2),
- new RSTile(3206, 3216, 2),
- new RSTile(3205, 3210, 2)},
- fishingSpotPath = new RSTile[] {new RSTile(3207, 3209, 0),
- new RSTile(3209, 3210, 0),
- new RSTile(3214, 3211, 0),
- new RSTile(3214, 3216, 0),
- new RSTile(3219, 3219, 0),
- new RSTile(3228, 3217, 0),
- new RSTile(3232, 3215, 0),
- new RSTile(3234, 3210, 0),
- new RSTile(3235, 3206, 0),
- new RSTile(3239, 3199, 0),
- new RSTile(3241, 3193, 0),
- new RSTile(3243, 3186, 0),
- new RSTile(3243, 3179, 0),
- new RSTile(3243, 3173, 0),
- new RSTile(3243, 3167, 0),
- new RSTile(3243, 3159, 0),
- new RSTile(3245, 3156, 0)};
- // MISC METHODS
- public boolean waitFor(Condition c, long timeout) {
- Timer t = new Timer(timeout);
- while (t.isRunning()) {
- if (c.active()) {
- return true;
- }
- sleep(60, 80);
- }
- return false;
- }
- public boolean loggedOut() {
- return (Login.getLoginState() == Login.STATE.LOGINSCREEN)
- && (!Screen.getColorAt(100, 200).equals(new Color(0, 0, 0)));
- }
- public boolean logout() {
- if (Login.getLoginState() == Login.STATE.INGAME)
- {
- Login.logout();
- for(int x = 0; x < 6; x++)
- {
- if(loggedOut())
- {
- return true;
- }
- sleep(490,510);
- }
- }
- return false;
- }
- public void antiBan(int rotation) {
- int number = General.random(1, 500);
- sleep(200);
- switch (number) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
- break;
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
- sleep(200);
- break;
- case 50:
- GameTab.open(TABS.INVENTORY);
- sleep(200);
- break;
- case 75:
- case 76:
- break;
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- case 95:
- case 96:
- case 97:
- case 98:
- case 99:
- case 100:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- }
- }
- // NET AND BANKING METHODS
- private void openBank(){
- RSTile myPos = Player.getPosition();
- if (bankArea.contains(myPos)){
- if (!Banking.isBankScreenOpen()){
- Banking.openBankBooth();
- }
- if (Banking.isBankScreenOpen()){
- sleep(20, 30);
- }
- }
- }
- private void closeBank(){
- if (Banking.isBankScreenOpen()){
- Banking.close();
- }
- }
- private void depositFish(){
- RSItem[] fish = Inventory.find(fishNames);
- if (fish != null && fish.length > 0){
- Banking.depositAllExcept(netName);
- }
- }
- private boolean haveNet(){
- RSItem[] net = Inventory.find(netName);
- return net != null && net.length > 0;
- }
- private boolean isNetOnground(){
- RSGroundItem[] net = GroundItems.findNearest(netName);
- return net != null && net.length > 0 && net[0].isOnScreen();
- }
- private void pickingUpNet(){
- RSGroundItem[] net = GroundItems.findNearest(netName);
- if (net != null && net.length > 0){
- if (net[0].click(takeOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return haveNet();
- }
- }, 4000);
- }
- }
- }
- // FISHING METHODS
- private boolean isFishSpot(){
- RSNPC[] spot = NPCs.findNearest(fishingSpotName);
- return spot != null && spot.length > 0 && spot[0].isOnScreen();
- }
- private RSTile fishingPosition(){
- RSNPC[] spot = NPCs.findNearest(fishingSpotName);
- if (spot != null && spot.length > 0){
- return spot[0].getPosition();
- }
- return null;
- }
- private void startFishing(){
- RSNPC[] spot = NPCs.findNearest(fishingSpotName);
- if (spot != null && spot.length > 0){
- if (DynamicClicking.clickRSNPC(spot[0], fishingSpotOption)){
- sleep(500, 600);
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return !Player.isMoving() && Player.getAnimation() == -1 || Inventory.isFull();
- }
- }, 20000);
- }
- }
- }
- // RAW FISH METHODS
- private boolean haveFish(){
- RSItem[] fish = Inventory.find(fishNames);
- return fish != null && fish.length > 0;
- }
- private void dropFish(){
- String[] netName = {"Small fishing net", "Fishing"};
- RSItem[] fish = Inventory.find(fishNames);
- if (fish != null && fish.length > 0){
- Inventory.dropAllExcept(netName);
- }
- }
- // WALK METHODS
- private void toFishingSpot(){
- final RSTile myPos = Player.getPosition();
- if (!fishingArea.contains(myPos)){
- if (Walking.walkPath(fishingSpotPath)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return fishingArea.contains(myPos) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- }
- private void toNets(){
- final RSTile myPos = Player.getPosition();
- if (myPos.distanceTo(netsTile) > 3){
- if (Walking.walkTo(netsTile)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return myPos.distanceTo(netsTile) < 3 && !Player.isMoving();
- }
- }, 10000);
- }
- }
- }
- private void toSpot(){
- final RSTile myPos = Player.getPosition();
- if (myPos.distanceTo(fishingPosition()) > 3){
- if (Walking.walkTo(fishingPosition())){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return myPos.distanceTo(fishingPosition()) < 3 && !Player.isMoving();
- }
- }, 10000);
- }
- }
- }
- private void toSpot2(){
- final RSTile myPos = Player.getPosition();
- if (myPos.distanceTo(new RSTile(3241, 3149, 0)) > 3){
- if (Walking.walkTo(new RSTile(3241, 3149, 0))){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return myPos.distanceTo(new RSTile(3241, 3149, 0)) < 3 && !Player.isMoving();
- }
- }, 10000);
- }
- }
- }
- private void toBank(){
- final RSTile myPos = Player.getPosition();
- if (!bankArea.contains(myPos)){
- if (Walking.walkPath(Walking.invertPath(stairsPathUp))){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return bankArea.contains(myPos) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- }
- private void toStairs(){
- final RSTile myPos = Player.getPosition();
- if (!stairArea.contains(myPos)){
- if (Walking.walkPath(stairsPathUp)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return stairArea.contains(myPos) && !Player.isMoving();
- }
- }, 4000);
- }
- }
- }
- // STAIR METHODS
- private void climbUp(){
- RSObject[] stairs = Objects.findNearest(10, stairsName);
- int plane = Player.getPosition().getPlane();
- final int planes = Player.getPosition().getPlane();
- if (stairs != null && stairs.length > 0){
- if (plane == 0){
- if (DynamicClicking.clickRSObject(stairs[0], stairsUpOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return planes == 1;
- }
- }, 3000);
- }
- }
- if (plane == 1){
- if (DynamicClicking.clickRSObject(stairs[0], stairsUpOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return planes == 2;
- }
- }, 3000);
- }
- }
- if (plane == 2){
- sleep (20, 30);
- }
- }
- }
- private void climbDown(){
- RSObject[] stairs = Objects.findNearest(10, stairsName);
- int plane = Player.getPosition().getPlane();
- final int planes = Player.getPosition().getPlane();
- if (stairs != null && stairs.length > 0){
- if (plane == 2){
- if (DynamicClicking.clickRSObject(stairs[0], stairsDownOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return planes == 1;
- }
- }, 3000);
- }
- }
- if (plane == 1){
- if (DynamicClicking.clickRSObject(stairs[0], stairsDownOption)){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return planes == 0;
- }
- }, 3000);
- }
- }
- if (plane == 0){
- sleep (20, 30);
- }
- }
- }
- // STATES
- public enum State{
- OPENING_BANK, BANKING_FISH, DROPPING_FISH,
- FISHING, WALKING_TO_FISHING_SPOT, WALKING_TO_BANK,
- PICKING_UP_FISHING_NET, WALKING_TO_SPOT, WALKING_TO_SPOT2,
- WALKING_TO_STAIRS, CLIMBING_DOWN, CLIMBING_UP,
- CLOSING_BANK, WALKING_TO_NETS, LOGING_OUT;
- }
- private State getState(){
- RSTile myPos = Player.getPosition();
- if (walkArea.contains(myPos) && fishingArea.contains(myPos)){
- if (fishingPosition().equals(noFishTile)){
- return State.WALKING_TO_SPOT2;
- }
- if (!Inventory.isFull() && haveNet() && isFishSpot()){
- return State.FISHING;
- }
- if (!Inventory.isFull() && haveNet() && !isFishSpot()){
- return State.WALKING_TO_SPOT;
- }
- if (!Inventory.isFull() && !haveNet() && isNetOnground()){
- return State.PICKING_UP_FISHING_NET;
- }
- if (!Inventory.isFull() && !haveNet() && !isNetOnground()){
- return State.WALKING_TO_NETS;
- }
- if (Inventory.isFull() && bank && !drop){
- return State.WALKING_TO_BANK;
- }
- if (Inventory.isFull() && !bank && drop){
- return State.DROPPING_FISH;
- }
- }
- if (walkArea.contains(myPos) && !fishingArea.contains(myPos) && !stairArea.contains(myPos)){
- if (!Inventory.isFull()){
- return State.WALKING_TO_FISHING_SPOT;
- }
- if (Inventory.isFull()){
- return State.WALKING_TO_BANK;
- }
- }
- if (walkArea.contains(myPos) && stairArea.contains(myPos)){
- if (Inventory.isFull() && plane != 2){
- return State.CLIMBING_UP;
- }
- if (Inventory.isFull() && plane == 2 && !bankArea.contains(myPos)){
- return State.WALKING_TO_BANK;
- }
- if (!Inventory.isFull() && plane != 0){
- return State.CLIMBING_DOWN;
- }
- if (!Inventory.isFull() && plane == 0){
- return State.WALKING_TO_FISHING_SPOT;
- }
- }
- if (walkArea.contains(myPos) && bankArea.contains(myPos) && plane == 2){
- if (!Banking.isBankScreenOpen() && Inventory.isFull()){
- return State.OPENING_BANK;
- }
- if (Banking.isBankScreenOpen() && haveFish()){
- return State.BANKING_FISH;
- }
- if (Banking.isBankScreenOpen() && !haveFish()){
- return State.CLOSING_BANK;
- }
- }
- return State.LOGING_OUT;
- }
- @Override
- public void onRandom(RANDOM_SOLVERS arg0) {
- paused = true;
- }
- @Override
- public boolean randomFailed(RANDOM_SOLVERS arg0) {
- paused = false;
- return false;
- }
- @Override
- public void randomSolved(RANDOM_SOLVERS arg0) {
- paused = false;
- }
- @Override
- public void onPause() {
- paused = true;
- while (paused){
- sleep(100, 200);
- }
- }
- @Override
- public void onResume() {
- sleep(2000, 3000);
- paused = false;
- }
- private static final long startTime = System.currentTimeMillis();
- Font font = new Font("Calibri", Font.BOLD, 16);
- private State SCRIPT_STATE = getState();
- @SuppressWarnings("deprecation")
- private final int startXP = Skills.getXP("fishing");
- private int START_XP;
- @SuppressWarnings("deprecation")
- @Override
- public void onPaint(Graphics g) {
- long timeRan = System.currentTimeMillis() - startTime;
- double multiplier = timeRan / 3600000D;
- int xpGained = Skills.getXP("fishing") - START_XP;
- g.setFont(font);
- g.setColor(new Color(255, 255, 255));
- g.drawString("ok_StarterFishing V" + version, 558, 220);
- g.drawString("Action: " + SCRIPT_STATE, 558, 235);
- g.drawString("Time running: " + Timing.msToString(timeRan), 558, 250);
- g.drawString("XP Gained p/h: " + (int) (xpGained / multiplier), 558, 265);
- g.drawString("XP Gained: " + (int) xpGained, 558, 280);
- }
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- println("Started ok_StarterCombat from the StarterPack");
- START_XP = startXP;
- super.setRandomSolverState(true);
- Walking.setControlClick(true);
- while(true){
- if (loggedOut()) {
- super.setLoginBotState(active);
- } else {
- while (!loggedOut()) {
- SCRIPT_STATE = getState();
- int mSpeed = General.random(180, 200);
- Mouse.setSpeed(mSpeed);
- Walking.setControlClick(true);
- switch (SCRIPT_STATE) {
- case BANKING_FISH:
- depositFish();
- sleep(100, 200);
- break;
- case CLIMBING_DOWN:
- climbDown();
- sleep(100, 200);
- break;
- case CLIMBING_UP:
- climbUp();
- sleep(100, 200);
- break;
- case DROPPING_FISH:
- dropFish();
- sleep(100, 200);
- break;
- case FISHING:
- int rotation5 = General.random(90, 200);
- antiBan(rotation5);
- startFishing();
- sleep(100, 200);
- break;
- case LOGING_OUT:
- logout();
- stopScript();
- break;
- case OPENING_BANK:
- openBank();
- sleep(100, 200);
- break;
- case PICKING_UP_FISHING_NET:
- pickingUpNet();
- sleep(100, 200);
- break;
- case WALKING_TO_BANK:
- toBank();
- sleep(100, 200);
- break;
- case WALKING_TO_FISHING_SPOT:
- toFishingSpot();
- sleep(100, 200);
- break;
- case WALKING_TO_SPOT:
- toSpot();
- sleep(100, 200);
- break;
- case WALKING_TO_STAIRS:
- toStairs();
- sleep(100, 200);
- break;
- case CLOSING_BANK:
- closeBank();
- sleep(100, 200);
- break;
- case WALKING_TO_SPOT2:
- toSpot2();
- sleep(100, 200);
- break;
- case WALKING_TO_NETS:
- toNets();
- sleep(150, 200);
- break;
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement