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.

can i have some help, please

Featured Replies

hello,

 

I'am currently trying to create a more enhanced cow killer,

I've divided the cow field into 3 different area's:

East,

South,

West

 

so say if im in "East", and there is no attackable cow the bot runs to "South" I've created this method:

	public void walkToArea(String area, Player p) throws InterruptedException {
		/* 2 other areas to EAST*/
		methods.safeWalkTo(PathSouthToEast);
		if(area == "East" && whatAreaPlayer(p) == "South") {
			methods.safeWalkTo(PathSouthToEast);
		}
		if(area == "East" && whatAreaPlayer(p) == "West") {
			methods.safeWalkTo(PathWestToEast);
		}
		/*end EAST*/
		
		/* 2 other areas to West*/
		if(area == "West" && whatAreaPlayer(p) == "South") {
			methods.safeWalkTo(PathSouthToWest);
		}
		if(area == "West" && whatAreaPlayer(p) == "East") {
			methods.safeWalkTo(PathEastToWest);
		}
		
		/* 2 other areas to West*/
		if(area == "South" && whatAreaPlayer(p) == "West") {
			methods.safeWalkTo(PathWestToSouth);
		}
		if(area == "South" && whatAreaPlayer(p) == "East") {
			methods.safeWalkTo(PathWestToSouth);
		}
	}

whatAreaPlayer:

	public String whatAreaPlayer(Player p) {
		if (cowFieldSouth.contains(p))
			return "South";
		if (cowFieldEast.contains(p))
			return "East";
		if (cowFieldWest.contains(p))
			return "West";
		return "cant find";
	}

safeWalkTo (thanks to Renegeade)

	public void safeWalkTo(Position[] p) throws InterruptedException {
		this.getLocalWalker().walkPath(p);
		Position lastPos = p[p.length - 1];
		while (true) {
			double lastDistance = distanceSquared(this.myPosition(), lastPos);
			if (lastDistance < 4.5d) {
				break;
			}
			Methods.sleep(3000);
			if (Math.abs(distanceSquared(this.myPosition(), lastPos)
					- lastDistance) < 1.1d) {
				ArrayList<Position> shortenedPath = new ArrayList<Position>();
				boolean startAdding = false;
				for (Position pos : p) {
					if (distanceSquared(this.myPosition(), pos) < 100d) {
						startAdding = true;
					}
					if (startAdding) {
						shortenedPath.add(pos);
					}
				}
				this.getLocalWalker().walkPath(shortenedPath);
			}
		}
	}

	private double distanceSquared(Position p1, Position p2) {
		return Math.pow(p1.getX() - p2.getX(), 2d)
				+ Math.pow(p1.getY() - p2.getY(), 2d);
	}

but now it just wont move...

 

thanks in advance,

Jelleplomp

Edited by jelleplomp

Or use localWalker.walk(area.getRandomPosition))? There's no sense in using paths for every scenario when you can have the walking event auto-generate one using DCPF. 

  • Author

Or use localWalker.walk(area.getRandomPosition))? There's no sense in using paths for every scenario when you can have the walking event auto-generate one using DCPF. 

 

so your telling me i can use a method that generates a path to an area? XD

ffs lol thanks

 

what int do i need to use?

Edited by jelleplomp

so your telling me i can use a method that generates a path to an area? XD

ffs lol thanks

what int do i need to use?

localWalker.walk(MYAREA.getRandomPosition(0));

Is what I'd do.

Sometimes, if your character moves far enough away though, it won't walk back into the area.

There was also a line of code someone posted on here where they filtered out every cow they couldn't attack, then stored it into an array, then rolled a random number that was no greater than the arrays length to pick what cow to attack. On mobile, so I don't want to type it all out.

Edited by twin 763

What do you mean by east, west, and south? Is this all one cow field?

Yeah it is. He broke it into 3 areas to have it run around if there are no attackable cows.
  • Author

getting this error =\

[ERROR][Bot #1][03/26 04:18:15 PM]: Error in script executor!
java.lang.NullPointerException
	at Searching.walkToArea(Methods.java:98)
	at JP_COW_KILLER.onLoop(JP_COW_KILLER.java:37)
	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(vk:97)
	at java.lang.Thread.run(Unknown Source)

line : 

getLocalWalker().walk(cowFieldEast.getRandomPosition(0));

getting this error =\

[ERROR][Bot #1][03/26 04:18:15 PM]: Error in script executor!java.lang.NullPointerException	at Searching.walkToArea(Methods.java:98)	at JP_COW_KILLER.onLoop(JP_COW_KILLER.java:37)	at org.osbot.rs07.event.ScriptExecutor$InternalExecutor.run(vk:97)	at java.lang.Thread.run(Unknown Source)
line :
getLocalWalker().walk(cowFieldEast.getRandomPosition(0));

When you're walking to an area or a path, it's localWalker.walk(). You don't need to do getLocalWalker unless you want it to walk to a specific point.

  • Author

When you're walking to an area or a path, it's localWalker.walk(). You don't need to do getLocalWalker unless you want it to walk to a specific point.

thanks man

thanks man

 

Actually to walk a path its localWalker.walkPath(), my bad for the misinformation :(

Here is how I would go about doing this;

 

Entity Cow1 = getNPC.closest(COW_AREA1, "Cow")

Entity Cow2 = getNPC.closest(COW_AREA2, "Cow")

Entity Cow3 = getNPC.closest(COW_AREA3, "Cow")

 

 

if(COW_AREA1.contains(Cow1)) {

   cow1.interact("Attack");

} else if(COW_AREA2.contains(Cow2) && !COW_AREA1.contains(Cow1)) {

   cow2.interact("Attack");

} else if(COW_AREA3.contains(Cow3) && !COW_AREA1.contains(Cow1) && !COW_AREA2.contains(Cow2)){

   cow3.interact("Attack");

 

 

Made a script with similar concept, maybe you get some ideas?

Here is how I would go about doing this;

 

Entity Cow1 = getNPC.closest(COW_AREA1, "Cow")

Entity Cow2 = getNPC.closest(COW_AREA2, "Cow")

Entity Cow3 = getNPC.closest(COW_AREA3, "Cow")

 

 

if(COW_AREA1.contains(Cow1)) {

   cow1.interact("Attack");

} else if(COW_AREA2.contains(Cow2) && !COW_AREA1.contains(Cow1)) {

   cow2.interact("Attack");

} else if(COW_AREA3.contains(Cow3) && !COW_AREA1.contains(Cow1) && !COW_AREA2.contains(Cow2)){

   cow3.interact("Attack");

 

 

Made a script with similar concept, maybe you get some ideas?

 

All this seems really redundant, just get the closest cow and check if its either in the cow pen and under attack.

Area COWAREA = new Area(0,0,0,0)
NPC cow = npcs.closest("Cow");
if(cow!=null)
     if(COWAREA.contains(cow)&&!cow.isUnderAttack())
          cow.interact("Attack");

and if the cow is underattack just do

 

localWalker.walk(COWAREA.getRandomPosition(0)); and it will go to a new area and find new cows.

 

Or you can filter out every cow that is under attack, so the only cows it will think about targetting are ones that aren't under attack.

Edited by twin 763

All this seems really redundant, just get the closest cow and check if its either in the cow pen and under attack.

Area COWAREA = new Area(0,0,0,0)
NPC cow = npcs.closest("Cow");
if(cow!=null)
     if(COWAREA.contains(cow)&&!cow.isUnderAttack())
          cow.interact("Attack");

and if the cow is underattack just do

 

localWalker.walk(COWAREA.getRandomPosition(0)); and it will go to a new area and find new cows.

 

Or you can filter out every cow that is under attack, so the only cows it will think about targetting are ones that aren't under attack.

 

The simpler the less buggy too!

 

I would do same, but he wants a more complex script I guess laugh.png

 

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.