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.

npcs.closest lag

Featured Replies

NPC beast = npcs.closest("beast name");

does this lag for someone else?

It uses alot of cpu power sad.png

 

 

or it is this method

interact.beast("Attack");

full code

public boolean killbeast() throws InterruptedException {


NPC beast = npcs.closest("beast");
// Player p = myPlayer();
Mylog("2");
loot();
Mylog("3");
if (combat.isFighting()) {
Mylog("4");
Mylog("Already attacking beast");
spec(10);
if (random(100) == 1) {
combat.getFighting().interact("Attack");
}
if (fillLootingBag()) {
lootingBagEmpty = false;
}
return true;
}
Mylog("5");
if (!beast.isVisible()) {
camera.toEntity(beast, true);
}
Mylog("6");
if (beast.isVisible()){
return public boolean killbeast() throws InterruptedException {


NPC beast = npcs.closest("beast");
// Player p = myPlayer();
Mylog("2");
loot();
Mylog("3");
if (combat.isFighting()) {
Mylog("4");
Mylog("Already attacking beast");
spec(10);
if (random(100) == 1) {
combat.getFighting().interact("Attack");
}
if (fillLootingBag()) {
lootingBagEmpty = false;
}
return true;
}
Mylog("5");
if (!beast.isVisible()) {
camera.toEntity(beast, true);
}
Mylog("6");
if (beast.isVisible()){
return beast.interact("Attack");
}


return false;
}

Edited by fre024

I know objects.closest() uses many CPU - because there can be 1000s objects loaded.

Check NPC amount npcs.getAll() - if they're a little - then i think it should'nt consume much.

And you can just call getAll() and then iterate yourself and compare CPU usage.

Edited by darkxor

It does use quite a bit of processing power, make sure you're not doing that every loop, because you'll notice a big hit in performance.

 

Only use it when you have to :)

Shouldn't noticable really. Can we see the code where the issue occurs? I have a feeling that you may be calling the method more often than required.. Eg. with no sleep inbetween. This would make it noticable.

  • Author


public boolean killbeast() throws InterruptedException {

NPC beast = npcs.closest("beast");

// Player p = myPlayer();

Mylog("2");

loot();

Mylog("3");

if (combat.isFighting()) {

Mylog("4");

Mylog("Already attacking beast");

spec(10);

if (random(100) == 1) {

combat.getFighting().interact("Attack");

}

if (fillLootingBag()) {

lootingBagEmpty = false;

}

return true;

}

Mylog("5");

if (!beast.isVisible()) {

camera.toEntity(beast, true);

}

Mylog("6");

if (beast.isVisible()){

return beast.interact("Attack");

}

return false;

}

Edited by fre024

First and foremost, help us help you by formatting your code in a readable fashion:

public boolean killbeast() throws InterruptedException {
	NPC beast = npcs.closest("beast");
	// Player p = myPlayer();
	Mylog("2");
	loot();
	Mylog("3");
	if (combat.isFighting()) {
		Mylog("4");
		Mylog("Already attacking beast");
		spec(10);
		if (random(100) == 1) {
			combat.getFighting().interact("Attack");
		}
		if (fillLootingBag()) {
			lootingBagEmpty = false;
		}
		return true;
	}
	Mylog("5");
	if (!beast.isVisible()) {
		camera.toEntity(beast, true);
	}
	Mylog("6");
	if (beast.isVisible()){
		return beast.interact("Attack");
	}
	return false;
}

You don't appear to have any sleeps, so that's not exactly helping your cpu usage.

 

 

You should find your target NPC in a seperate method from the one you use for interaction, as your target shouldn't be changing between interaction loops (assuming the first was successful), i.e. 

NPC beast;

if(!beast.isAValidTarget) {
beast = npcs.getClosest("beast");
}
killBeast(beast);

Edited by adc

  • Author

Thx for the reply.

I 'll keep in mind to formatting the code.

 

I find the target in a seperate method now, still the same lag :(

The script runs fine, just want to reduce cpu usage.

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.