Jump to content

Grabber script


David Gatward

Recommended Posts

Hi,

Am looking for a script that would:

1. Telegrab a specific ground item until there is none of it left then hop world and repeat this until: x amount of target ground item is in inventory OR run out of law runes in inventory OR cannot cast telegrab and then logout is triggered.

1.1 There would be a way to tell what worlds the bot will hop to through an interface. OR there is the exact same script but with the world hopping variable changed so if one would like the script to hop 451-459 then the specific script for that hopping pattern is loaded in the script selector.

2. The script, on the condition any hp is lost, would need to eat food in the inventory, activate quick pray and run to single-way combat (approx 100 tiles).

2.1 If hp is still being lost when reaching this co-ordinate then it needs to reach lvl 20 wild (approx 800 tiles) where home tele is activated.

2.2 If home tele turns out to be a null action (either through tb or cooldown timer or still in combat) then it will be taken to the wilderness ditch and logout.

With 0 knowledge of Java I've tried making my own script for (1.) and got this far :D:


            Entity naturerune = getObjects().closest("Nature rune");
            if (naturerune != null)  {
                nature rune.interact("Take");
            }

Any help with developing this script would be appreciated.

  • Like 1
Link to comment
Share on other sites

I recently started to script, so probably is broken... but maybe is useful:

Food is not in it, because is easy just have to map which you gonna use...

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@ScriptManifest( name="Shitty Script", author = "OsPlay", version = 0.0, logo = "", info = "Spaghetti code!")
public class Telegrab extends Script {

    public boolean EXIT = false;
    public Area AREA_TO_EXIT = new Area(1,1,1,1);
    public Area AREA_2_TO_EXIT = new Area(1,1,1,1);

    public List<Integer> LIST_OF_WORLDS = new ArrayList<>();

    @Override
    public void onStart() throws InterruptedException {

        String list = JOptionPane.showInputDialog("WORLD TO HOP: AK 509,510,511...");

        for (String world :
                list.split(",")) {
            LIST_OF_WORLDS.add(Integer.parseInt(world));
        }


    }

    @Override
    public int onLoop() throws InterruptedException {

        exitOrChange();

        // check if the player is logged ?
        if(!client.isLoggedIn() && !myPlayer().isOnScreen() && !myPlayer().isVisible()) return 1000;

        // cast the spell and grab
        tryToTeleGrab();

        goOutSide();

        // check if this work, maybe won't D;
        exitOrChange();


        return 0;
    }

    private void exitOrChange() throws InterruptedException {
        if(EXIT || getInventory().isFull()){

            while (getLogoutTab().logOut() == false){
                sleep(100);
            }
            onExit();
        } else {
            // you can add banking?
            switchWorld();
        }
    }

    private void switchWorld() throws InterruptedException {

        if(LIST_OF_WORLDS.size() == 0) {
            EXIT = true;
            exitOrChange();
        }

        int worldId = LIST_OF_WORLDS.get(0);
        LIST_OF_WORLDS.remove(0);
        getWorlds();
        sleep(random(500,2000));
        getWorlds().hop(worldId);

    }

    private boolean tryToTeleGrab() throws InterruptedException {

        boolean NO_MORE_RUNES = false;
		// logic error, do it only if you're not under attack and you have space to grab or runes to cast the spell.
        while (!myPlayer().isUnderAttack() && !NO_MORE_RUNES){
            // check items and inventory to spell cast
            if(!checkItems()) NO_MORE_RUNES = true;

            if(!tryToGetTheRune()) return false;

        }

        return true;
    }

    private boolean tryToGetTheRune() throws InterruptedException {

        GroundItem natureRune = getGroundItems().closest("Nature rune");

        if(natureRune == null) return false;

        //open magic!
        getMagic();
        sleep(random(500,1000));

        // Can't because lvl
        if(!getMagic().castSpell(Spells.NormalSpells.TELEKINETIC_GRAB)) return false;
        sleep(random(500,1000));
        //cast magic
        if(!natureRune.interact("Cast")) return false;

        return true;

    }

    private void goOutSide() throws InterruptedException {

        // is not the best implementation of walking...
        while (!AREA_TO_EXIT.contains(myPosition().getX(), myPosition().getY())){
            getWalking().webWalk(AREA_TO_EXIT);
            sleep(random(500,1000));
        }
        while (!AREA_2_TO_EXIT.contains(myPosition().getX(), myPosition().getY())){
            getWalking().webWalk(AREA_2_TO_EXIT);
            sleep(random(500,1000));
            // I'm not sure how you wanna implement the teleport (cast spell?)
        }

    }

    private boolean checkItems() {

        // you have space in the inventory.
        if(getInventory().isFull()) return false;
        // check for law rune.
        if(getInventory().getAmount("Law rune") < 1) return false;
        // check for air rune.
        if(getInventory().getAmount("Air rune") < 1) return false;

        return true;
    }
}

i wrote in 1h and doing other stuff so, yeah broken as hell, even i don't know if there's the proper way to do it, due my lack of knowledge in the API.

also you must add if the player is under attack or not when you walk, because will walk anyway to the 2nd place (wich you have to map)

but you can play and test (wich is funny and probably get a ban XDD)

Edited by OsPlay
Link to comment
Share on other sites

10 hours ago, OsPlay said:

I recently started to script, so probably is broken... but maybe is useful:

Food is not in it, because is easy just have to map which you gonna use...


import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@ScriptManifest( name="Shitty Script", author = "OsPlay", version = 0.0, logo = "", info = "Spaghetti code!")
public class Telegrab extends Script {

    public boolean EXIT = false;
    public Area AREA_TO_EXIT = new Area(1,1,1,1);
    public Area AREA_2_TO_EXIT = new Area(1,1,1,1);

    public List<Integer> LIST_OF_WORLDS = new ArrayList<>();

    @Override
    public void onStart() throws InterruptedException {

        String list = JOptionPane.showInputDialog("WORLD TO HOP: AK 509,510,511...");

        for (String world :
                list.split(",")) {
            LIST_OF_WORLDS.add(Integer.parseInt(world));
        }


    }

    @Override
    public int onLoop() throws InterruptedException {

        exitOrChange();

        // check if the player is logged ?
        if(!client.isLoggedIn() && !myPlayer().isOnScreen() && !myPlayer().isVisible()) return 1000;

        // cast the spell and grab
        tryToTeleGrab();

        goOutSide();

        // check if this work, maybe won't D;
        exitOrChange();


        return 0;
    }

    private void exitOrChange() throws InterruptedException {
        if(EXIT || getInventory().isFull()){

            while (getLogoutTab().logOut() == false){
                sleep(100);
            }
            onExit();
        } else {
            // you can add banking?
            switchWorld();
        }
    }

    private void switchWorld() throws InterruptedException {

        if(LIST_OF_WORLDS.size() == 0) {
            EXIT = true;
            exitOrChange();
        }

        int worldId = LIST_OF_WORLDS.get(0);
        LIST_OF_WORLDS.remove(0);
        getWorlds();
        sleep(random(500,2000));
        getWorlds().hop(worldId);

    }

    private boolean tryToTeleGrab() throws InterruptedException {

        boolean NO_MORE_RUNES = false;
		// logic error, do it only if you're not under attack and you have space to grab or runes to cast the spell.
        while (!myPlayer().isUnderAttack() && !NO_MORE_RUNES){
            // check items and inventory to spell cast
            if(!checkItems()) NO_MORE_RUNES = true;

            if(!tryToGetTheRune()) return false;

        }

        return true;
    }

    private boolean tryToGetTheRune() throws InterruptedException {

        GroundItem natureRune = getGroundItems().closest("Nature rune");

        if(natureRune == null) return false;

        //open magic!
        getMagic();
        sleep(random(500,1000));

        // Can't because lvl
        if(!getMagic().castSpell(Spells.NormalSpells.TELEKINETIC_GRAB)) return false;
        sleep(random(500,1000));
        //cast magic
        if(!natureRune.interact("Cast")) return false;

        return true;

    }

    private void goOutSide() throws InterruptedException {

        // is not the best implementation of walking...
        while (!AREA_TO_EXIT.contains(myPosition().getX(), myPosition().getY())){
            getWalking().webWalk(AREA_TO_EXIT);
            sleep(random(500,1000));
        }
        while (!AREA_2_TO_EXIT.contains(myPosition().getX(), myPosition().getY())){
            getWalking().webWalk(AREA_2_TO_EXIT);
            sleep(random(500,1000));
            // I'm not sure how you wanna implement the teleport (cast spell?)
        }

    }

    private boolean checkItems() {

        // you have space in the inventory.
        if(getInventory().isFull()) return false;
        // check for law rune.
        if(getInventory().getAmount("Law rune") < 1) return false;
        // check for air rune.
        if(getInventory().getAmount("Air rune") < 1) return false;

        return true;
    }
}

i wrote in 1h and doing other stuff so, yeah broken as hell, even i don't know if there's the proper way to do it, due my lack of knowledge in the API.

also you must add if the player is under attack or not when you walk, because will walk anyway to the 2nd place (wich you have to map)

but you can play and test (wich is funny and probably get a ban XDD)

hahahaha, this post may help?

So I copy and pasted this code into Intellij Idea and build artifact --> build.
Was expecting the script to then load in Osbot once I click refresh but didn't turn up...

Would it be possible to convert this into a java executable file then I could drag and drop into my osbot scripts folder to test it? I've done that before with @Explv's updated AIO script.

----------------------------------------------------------------------------------------------

Maybe to start with it's just important to get the script to telegrab nature runes and hop specified f2p worlds (497 to 504) until no law runes are left.

The other elements that are to protect the bot from dying and get it out the wilderness can be added in later? Maybe it's important the bot can at least eat Jug'o'wine.

Also, the character will be wielding an air staff so there's no need to check for air runes in inventory :D


-----------------------------------------------------------------------------------------------

Tysm for your help amigo :)

Edited by David Gatward
Link to comment
Share on other sites

8 minutes ago, ProjectPact said:

You could use Script Factory to make this :) 

you need 0 programming knowledge and can build flawless scripts within minutes! 

Does it include randomisation? like, will it click the same tile on the same pixel every time? Otherwise cool, you don't offer trial do you?

Link to comment
Share on other sites

Just now, David Gatward said:

Does it include randomisation? like, will it click the same tile on the same pixel every time? Otherwise cool, you don't offer trial do you?

It has the ability to click the same tile if you make your script in a way to use x, y positions, however by using normal interactions, it uses completely random pixels :) it has a lot of anti ban prebuilt into the script by default. Someone managed to run a script almost 13 days straight. 

Link to comment
Share on other sites

import org.osbot.rs07.api.map.Area;
import org.osbot.rs07.api.model.GroundItem;
import org.osbot.rs07.api.ui.Spells;
import org.osbot.rs07.script.Script;
import org.osbot.rs07.script.ScriptManifest;

import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
@ScriptManifest( name="Shitty Script", author = "OsPlay", version = 0.0, logo = "", info = "Spaghetti code!")
abstract class Telegrab extends Script {

    public boolean EXIT = false;
    public Area AREA_TO_EXIT = new Area(1,1,1,1);
    public Area AREA_2_TO_EXIT = new Area(1,1,1,1);

    public List<Integer> LIST_OF_WORLDS = new ArrayList<>();

    @Override
    public void onStart() throws InterruptedException {

        String list = JOptionPane.showInputDialog("WORLD TO HOP: AK 509,510,511...");

        for (String world :
                list.split(",")) {
            LIST_OF_WORLDS.add(Integer.parseInt(world));
        }
    }

    private boolean tryToGetTheRune() throws InterruptedException {

        GroundItem natureRune = getGroundItems().closest("Nature rune");

        if(natureRune == null) return false;

        //open magic!
        getMagic();
        sleep(random(500,1000));

        // Can't because lvl
        if(!getMagic().castSpell(Spells.NormalSpells.TELEKINETIC_GRAB)) return false;
        sleep(random(500,1000));
        //cast magic
        if(!natureRune.interact("Cast")) return false;

        return true;

    }

    private boolean checkItems() {

        // you have space in the inventory.
        if(getInventory().isFull()) return false;
        // check for law rune.
        if(getInventory().getAmount("Law rune") < 1) return false;
        // check for air rune.
        if(getInventory().getAmount("Air rune") < 1) return false;

        return true;
    }
}
Edited by David Gatward
I got this script to get into the osbot script selector but I click play on it and nothing happens and kinda breaks the client :D
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...