Jump to content
View in the app

A better way to browse. Learn more.

OSBot :: 2007 OSRS Botting

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Breaking walkPath when there is a player nearby?

Featured Replies

This is what i use to detect if a player is nearby that can attack me and is wearing certain gear. Works great if anyone needs it . 

   public boolean nearbyThreat() {
        int wildernessLevel = map.getWildernessLevel();
        int myCombatLevel = myPlayer().getCombatLevel();
        List<Player> nearbyPlayers = getPlayers().filter(p -> p != null && !p.equals(myPlayer()) && p.getPosition().distance(myPlayer().getPosition()) <= 25);
        for (Player player : nearbyPlayers) {
            int playerCombatLevel = player.getCombatLevel();
            int combatLevelDiff = myCombatLevel - playerCombatLevel;
            if (Math.abs(combatLevelDiff) <= wildernessLevel) {
                String equipment = getOthersEquipment(player);
                if (equipment.contains("Staff") ||
                        equipment.contains("cape") ||
                        equipment.contains("Dark") ||
                        equipment.contains("Mystic") ||
                        equipment.contains("Xerix") ||
                        equipment.contains("Occult") ||
                        player.isInteracting(myPlayer())) {
                    log("Player " + player.getName() + " has equipment: " + equipment);
                    imInDanger = true;
                    return true; // found a nearby player who is a threat
                }
            }
        }
        imInDanger = false;
        return false; // no nearby player is a threat
    }

Current issue im having, cant seem to break my pathwalk if a threat is nearby. It will always finish the walk before teleporting. I have nearbyThreat running constantly in onLoop.

 

if (!atDestination()) {
                    try {
                        walking.walkPath(areasAndPaths.pathToDestination);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                Util.Sleep.sleepUntil(() -> atDestination() || nearbyThreat(), 5000);
            }

Also tried using a while loop.

7 hours ago, saintpaul1 said:

This is what i use to detect if a player is nearby that can attack me and is wearing certain gear. Works great if anyone needs it . 

   public boolean nearbyThreat() {
        int wildernessLevel = map.getWildernessLevel();
        int myCombatLevel = myPlayer().getCombatLevel();
        List<Player> nearbyPlayers = getPlayers().filter(p -> p != null && !p.equals(myPlayer()) && p.getPosition().distance(myPlayer().getPosition()) <= 25);
        for (Player player : nearbyPlayers) {
            int playerCombatLevel = player.getCombatLevel();
            int combatLevelDiff = myCombatLevel - playerCombatLevel;
            if (Math.abs(combatLevelDiff) <= wildernessLevel) {
                String equipment = getOthersEquipment(player);
                if (equipment.contains("Staff") ||
                        equipment.contains("cape") ||
                        equipment.contains("Dark") ||
                        equipment.contains("Mystic") ||
                        equipment.contains("Xerix") ||
                        equipment.contains("Occult") ||
                        player.isInteracting(myPlayer())) {
                    log("Player " + player.getName() + " has equipment: " + equipment);
                    imInDanger = true;
                    return true; // found a nearby player who is a threat
                }
            }
        }
        imInDanger = false;
        return false; // no nearby player is a threat
    }

Current issue im having, cant seem to break my pathwalk if a threat is nearby. It will always finish the walk before teleporting. I have nearbyThreat running constantly in onLoop.

 

if (!atDestination()) {
                    try {
                        walking.walkPath(areasAndPaths.pathToDestination);
                    } catch (InterruptedException e) {
                        throw new RuntimeException(e);
                    }
                }
                Util.Sleep.sleepUntil(() -> atDestination() || nearbyThreat(), 5000);
            }

Also tried using a while loop.

I believe the walking code is a event and no other code of yours gets executed until it's done. If you print out some logs you can see that :)

What you can do is create your own walkingevent: (Rough guess)

WalkingEvent event = new WalkingEvent();
event.setPath(areasAndPaths.pathToDestination);
event.setHighBreakPriority(true);
event.setBreakCondition(new Condition() {
    @Override
    public boolean evaluate() {
        return atDestination() || nearbyThreat();
    }
 });


 

  • Author
2 hours ago, Khaleesi said:

I believe the walking code is a event and no other code of yours gets executed until it's done. If you print out some logs you can see that :)

What you can do is create your own walkingevent: (Rough guess)

WalkingEvent event = new WalkingEvent();
event.setPath(areasAndPaths.pathToDestination);
event.setHighBreakPriority(true);
event.setBreakCondition(new Condition() {
    @Override
    public boolean evaluate() {
        return atDestination() || nearbyThreat();
    }
 });


 

Ah brill thank you ! Walking event is what i needed :) much appreciated

  • 2 weeks later...
  • Author
On 4/25/2023 at 5:45 AM, Khaleesi said:

I believe the walking code is a event and no other code of yours gets executed until it's done. If you print out some logs you can see that :)

What you can do is create your own walkingevent: (Rough guess)

WalkingEvent event = new WalkingEvent();
event.setPath(areasAndPaths.pathToDestination);
event.setHighBreakPriority(true);
event.setBreakCondition(new Condition() {
    @Override
    public boolean evaluate() {
        return atDestination() || nearbyThreat();
    }
 });


 

Hey khal just coming back to this. The walkEvent breaks easily if a threat is nearby which is great. The issue i have with walkEvent is when walking sometimes it gets to the next tile in the path and then clicks the same tile again or takes a step backwards or to the side and then carrys on walking.

 

I also had this issue with walkPath but i used a custom walk method, to keep walking before it reached the next tile. Not sure how to do this with walkEvent if its even possible? If you have any ideas i would be graetful.

On 5/4/2023 at 10:35 PM, saintpaul1 said:

Hey khal just coming back to this. The walkEvent breaks easily if a threat is nearby which is great. The issue i have with walkEvent is when walking sometimes it gets to the next tile in the path and then clicks the same tile again or takes a step backwards or to the side and then carrys on walking.

 

I also had this issue with walkPath but i used a custom walk method, to keep walking before it reached the next tile. Not sure how to do this with walkEvent if its even possible? If you have any ideas i would be graetful.

I have no idea about that, 'm not sure how the inner mechanics of the walkingevent works, you can tweak it some with other option you can add like minimapdistance, ... maybe that helps for you?

  • Author
2 hours ago, Khaleesi said:

I have no idea about that, 'm not sure how the inner mechanics of the walkingevent works, you can tweak it some with other option you can add like minimapdistance, ... maybe that helps for you?

Thanks for replying, i managed to sort it by creating a new path and setting distances to 0.

 

:)

Create an account or sign in to comment

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.