Jump to content

FREE SCRIPt Canifis Rooftop agility


faruk141

Recommended Posts

My second script, so feel free to give ideas to improve my script. Start the script in canifis. Only missinig feature is the looting of the mark of graces. any suggestions?

Quote

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.Entity;
import org.osbot.rs07.api.ui.Skill;
import org.osbot.rs07.script.Script;

import org.osbot.rs07.script.ScriptManifest;

import java.awt.*;

@ScriptManifest(name = "CanifisAgility", author = "faruk141", version = 1.0, info = "", logo = "")

public class Main extends Script {
    private long timeStart;
    private String state = "Cannifis Rooftop Agility";
    

    @Override

    public void onStart() {
        log("Welcome to faruk141 Agility script");
        getExperienceTracker().start(Skill.AGILITY);
        timeStart = System.currentTimeMillis();
    }

    @Override

    public void onExit() {
        log("BYE");

        // Code here will execute after the script ends

    }

    @Override

    public int onLoop() throws InterruptedException {
        final Area area7 = new Area(3509, 3474, 3516, 3484);
        final Area area6 = new Area(3488, 3468, 3504, 3481);
        final Area area5 = new Area(3477, 3481, 3481, 3487);
        final Area area4 = new Area(3474, 3491, 3480, 3500);
        final Area area3 = new Area(3485, 3498, 3493, 3505);
        final Area area1 = new Area(3508, 3491, 3504, 3498);
        final Area area2 = new Area(3496, 3503, 3504, 3507);
        final Area area = new Area(3473, 3461, 3513, 3508);

        area.setPlane(0);
        area7.setPlane(2);
        area6.setPlane(3);
        area5.setPlane(2);

        area4.setPlane(3);
        area3.setPlane(2);
        area2.setPlane(2);
        area1.setPlane(2);
        Entity talltree = objects.closest(10819);
        Entity gap1 = objects.closest(10820);
        Entity gap2 = objects.closest(10821);
        Entity gap3 = objects.closest(10828);
        Entity gap4 = objects.closest(10822);
        Entity gap5 = objects.closest(10831);
        Entity gap6 = objects.closest(10823);
        Entity gap7 = objects.closest(10832);

        if (!area.contains(myPosition())) {
            if (area1.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap1.interact("Jump");
                    sleep(random(2500, 3500));
                }

            } else if (area2.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap2.interact("Jump");
                    sleep(random(2500, 3500));
                }
            } else if (area3.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap3.interact("jump");
                    sleep(random(2500, 3500));
                }
            } else if (area4.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap4.interact("jump");
                    sleep(random(2500, 3500));
                }
            } else if (area5.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap5.interact("Vault");
                    sleep(random(2500, 3500));
                }
                } else if (area6.contains(myPlayer())) {
                    if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                        gap6.interact("jump");
                        sleep(random(2500, 3500));
                    }
                    
                }else if (area7.contains(myPlayer())) {
                    if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                        gap7.interact("jump");
                        sleep(random(2500, 3500));
                        }
                    }
            }
         else {
            getWalking().walk(talltree);
            if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                talltree.interact("Climb");
                sleep(random(2500, 3500));
            }
        }
        
        return random(555, 777);

    }

    @Override

    public void onPaint(Graphics2D g) {long timeElapsed = System.currentTimeMillis() - timeStart;
    long seconds = (timeElapsed / 1000) % 60;
    long minutes = (timeElapsed / (1000 * 60)) % 60;
    long hours = (timeElapsed / (1000 * 60 * 60)) % 24;
    g.setFont(new Font("Trebuchet MS", Font.PLAIN, 14));
    g.setColor(Color.white);
    
    g.drawString("x", (int)getMouse().getPosition().getX() - 4, (int)getMouse().getPosition().getY() + 5);
    g.drawString(state, 8, 50);
    g.drawString("Time Running: " + (hours >= 10 ? "" + hours : "0" + hours) + ":" + (minutes >= 10 ? "" + minutes : "0" + minutes) + ":" + (seconds >= 10 ? "" + seconds : "0" + seconds), 8, 65);
    g.drawString("XP Gained: " + getExperienceTracker().getGainedXP(Skill.AGILITY) + " (" + getExperienceTracker().getGainedLevels(Skill.AGILITY) + ")", 8, 80);
    g.drawString("XP per hour: " + getExperienceTracker().getGainedXPPerHour(Skill.AGILITY), 8, 95);

    }
}

 

 

faruk141_agility.jar

Edited by faruk141
Link to comment
Share on other sites

Great of you for sharing.

First things first

    final Area area7 = new Area(3509, 3474, 3516, 3484);
        final Area area6 = new Area(3488, 3468, 3504, 3481);
        final Area area5 = new Area(3477, 3481, 3481, 3487);
        final Area area4 = new Area(3474, 3491, 3480, 3500);
        final Area area3 = new Area(3485, 3498, 3493, 3505);
        final Area area1 = new Area(3508, 3491, 3504, 3498);
        final Area area2 = new Area(3496, 3503, 3504, 3507);
        final Area area = new Area(3473, 3461, 3513, 3508);

        area.setPlane(0);
        area7.setPlane(2);
        area6.setPlane(3);
        area5.setPlane(2); 

Move all of these outside of onLoop method. There's no need to reinitialize there variables on each loop iteration.

Also can do this in one line

final Area area = new Area(3473, 3461, 3513, 3508).setPlane(0);

Also might want to ditch hardcoded object ids

Entity gap1 = objects.closest(10820);

Maybe replace with Positions or names

Entity gap1 = objects.closest(f -> f.getName().equals("Gap") && f.getPosition().equals(GAP_POSITION));

Also, use conditional sleeps, this is bad

if (area1.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap1.interact("Jump");
                    sleep(random(2500, 3500));
                } 

Can't remember the correct syntax, but this would be much better (sleep until you're in the other area)

if (area1.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap1.interact("Jump");
                    new ConditionalSleep(5000, 250) {
                    	public boolean condition() {
                        	return AREA_TO_GO_TO.contains(myPlayer());
                        }
                    }
                } 

 

  • Like 1
Link to comment
Share on other sites

1 hour ago, nosepicker said:

Great of you for sharing.

First things first


    final Area area7 = new Area(3509, 3474, 3516, 3484);
        final Area area6 = new Area(3488, 3468, 3504, 3481);
        final Area area5 = new Area(3477, 3481, 3481, 3487);
        final Area area4 = new Area(3474, 3491, 3480, 3500);
        final Area area3 = new Area(3485, 3498, 3493, 3505);
        final Area area1 = new Area(3508, 3491, 3504, 3498);
        final Area area2 = new Area(3496, 3503, 3504, 3507);
        final Area area = new Area(3473, 3461, 3513, 3508);

        area.setPlane(0);
        area7.setPlane(2);
        area6.setPlane(3);
        area5.setPlane(2); 

Move all of these outside of onLoop method. There's no need to reinitialize there variables on each loop iteration.

Also can do this in one line


final Area area = new Area(3473, 3461, 3513, 3508).setPlane(0);

Also might want to ditch hardcoded object ids


Entity gap1 = objects.closest(10820);

Maybe replace with Positions or names


Entity gap1 = objects.closest(f -> f.getName().equals("Gap") && f.getPosition().equals(GAP_POSITION));

Also, use conditional sleeps, this is bad


if (area1.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap1.interact("Jump");
                    sleep(random(2500, 3500));
                } 

Can't remember the correct syntax, but this would be much better (sleep until you're in the other area)


if (area1.contains(myPlayer())) {
                if (!myPlayer().isMoving() & !myPlayer().isAnimating()) {
                    gap1.interact("Jump");
                    new ConditionalSleep(5000, 250) {
                    	public boolean condition() {
                        	return AREA_TO_GO_TO.contains(myPlayer());
                        }
                    }
                } 

 

thank you very much for the suggestions. i try to use this in my script.

 

Link to comment
Share on other sites

1 hour ago, nosepicker said:

Great of you for sharing.

First things first


    final Area area7 = new Area(3509, 3474, 3516, 3484);
        final Area area6 = new Area(3488, 3468, 3504, 3481);
        final Area area5 = new Area(3477, 3481, 3481, 3487);
        final Area area4 = new Area(3474, 3491, 3480, 3500);
        final Area area3 = new Area(3485, 3498, 3493, 3505);
        final Area area1 = new Area(3508, 3491, 3504, 3498);
        final Area area2 = new Area(3496, 3503, 3504, 3507);
        final Area area = new Area(3473, 3461, 3513, 3508);

        area.setPlane(0);
        area7.setPlane(2);
        area6.setPlane(3);
        area5.setPlane(2); 

Move all of these outside of onLoop method. There's no need to reinitialize there variables on each loop iteration.

Also can do this in one line


final Area area = new Area(3473, 3461, 3513, 3508).setPlane(0);

 

ok there is a problem. if i move this outside of onLoop then the script stops working..idk why

Link to comment
Share on other sites

public class Main extends Script {
    private long timeStart;
    private String state = "Cannifis Rooftop Agility";
   final Area area7 = new Area(3509, 3474, 3516, 3484);
        final Area area6 = new Area(3488, 3468, 3504, 3481);
        final Area area5 = new Area(3477, 3481, 3481, 3487);

Add those here (class variables). You should get some compiler errors telling you what's wrong if it doesn't work

  • Like 1
Link to comment
Share on other sites

here is a snippet from my tzhaars script:

private void lootTokkul() {
    if (getTokkul() != null) {
        long lastTokkul = getInventory().getAmount("Tokkul");
        if (getTokkul().interact("Take")) {
            new ConditionalSleep(3000, 600) {
                @Override
                public boolean condition() throws InterruptedException {
                    return getInventory().getAmount("Tokkul") > lastTokkul;
                }
            }.sleep();
        }
    }
}

 

then just set getokkul to return true if there is a marks of grace on the floor

and chance tokkul to Marks of grace

  • Like 2
Link to comment
Share on other sites

Instead of calling this line

!myPlayer().isMoving() & !myPlayer().isAnimating()

On every single area type you should just check the statement at the beginning of your loop and return if either is found to be true.

Once you get more java experience you should look into using parallel arrays or creating a class for each area jump action. That way you dont have a long list of if statements. A good way to think of it is what if you had 1000 areas for that course how would you handle it so that you did not have to call 1000 if checks in your main loop.

  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...