Skip 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.

Who is interacting with me ? (OSB2)

Featured Replies

Mainly useful for combat situations with aggressive monsters:

package myplayer.Botrepreneur;

import java.util.ArrayList;
import java.util.List;
import java.util.Random;

import org.osbot.rs07.api.model.NPC;
import org.osbot.rs07.script.Script;

public class WhoIsInteractingWithMe {

	/**
	 * @author Botrepreneur
	 * @Version: 00.21
	 */

	public static List<NPC> getList(Script script) {
		List<NPC> returnList = new ArrayList<NPC>();
		List<NPC> allList = script.npcs.getAll();
		if (allList != null && !allList.isEmpty()) {
			for (NPC npc : allList) {
				if (npc != null && npc.getInteracting() != null && npc.getInteracting().getName().equals(script.myPlayer().getName())) {
					returnList.add(npc);
				}
			}
		}
		return returnList;
	}

	public static NPC getRandom(Script script) {
		List<NPC> list = WhoIsInteractingWithMe.getList(script);
		return list != null && !list.isEmpty() ? list.get(new Random().nextInt(list.size()) - 1) : null;
	}

	public static NPC getClosest(Script script) {
		double lowestDistance = Double.MAX_VALUE;
		List<NPC> allList = script.npcs.getAll();
		List<NPC> closestList = new ArrayList<NPC>();
		if (allList != null && !allList.isEmpty()) {
			for (NPC npc : allList) {
				if (npc == null || !npc.exists() || npc.getInteracting() == null || !npc.getInteracting().getName().equals(script.myPlayer().getName())) {
					continue;
				}
				if (npc.getPosition().distance(script.myPosition()) < lowestDistance) {
					closestList.clear();
					closestList.add(npc);
					lowestDistance = npc.getPosition().distance(script.myPosition());
				} else if (npc.getPosition().distance(script.myPosition()) == lowestDistance) {
					closestList.add(npc);
				}
			}
		}
		return closestList != null && !closestList.isEmpty() ? closestList.get(new Random().nextInt(closestList.size()) - 1) : null;
	}

}

Edited by Botrepreneur

Or can't you just do player/character.getInteracting()?

 

No, he wants to get all the NPCs attacking him, useful when you've got a lot of them and they're agressive.

 

player get interacting wouldn't do the job, because: 1. you may not be interacting 2. if interacting, it's one NPC, and it's not used for the same purpose.

  • 2 weeks later...

Possible solutions:
Mulit area:

A filter all npcs that are interacting with you, when you're not interacting any and you're under attack.
A result - the npc you want to attack first.

B filter all npcs that are interacting you, when you're attacking npc.

B result - now you have npc that you want to attack next (after killing the current one)

 

Single area
A simply filter all npcs that are interacting with you when you're not interacting any and you're under attack.
A result - the npc you want to attack, or run away from it.


You want to make such things in other thread.

  • 3 weeks later...
  • 3 weeks later...
Guest
This topic is now closed to further replies.

Recently Browsing 0

  • No registered users viewing this page.

Account

Navigation

Search

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.