Jump to content

Hovering over next NPC?


Trivial

Recommended Posts

Im trying to get my fishing script to hover over the next fishing spot to interact with.

 

I use josedpay's hovering snippet from this thread:

http://osbot.org/forum/topic/54533-hovering-snippet-osbot-2/

 

Heres what im currently working with, but it only very rarely hovers over fishing spots.

NPC Fishing_spot = npcs.closest(FISHING_ID);
if(myPlayer().isAnimating()){
	int playerX = myPlayer().getPosition().getX() + 2;
	int playerY =  myPlayer().getPosition().getY() + 2;
	int playerX2 =  myPlayer().getPosition().getX() - 2;
	int playerY2 =  myPlayer().getPosition().getY() - 2;
	Area NearPlayer = new Area(playerX, playerY, playerX2, playerY2);
	if(Docks1.contains(myPlayer())){
		if(Docks1.contains(Fishing_spot)){
			if(!NearPlayer.contains(Fishing_spot)){
				if(Fishing_spot.isVisible()){
					hover(Fishing_spot);
				} else {
					camera.toEntity(Fishing_spot);
				}
			}	
		}
	} else if(Docks2.contains(myPlayer())){
		if(Docks2.contains(Fishing_spot)){
			if(!NearPlayer.contains(Fishing_spot)){
				if(Fishing_spot.isVisible()){
					hover(Fishing_spot);
				} else {
			                camera.toEntity(Fishing_spot);
				}
			}
		}
	}
}
Link to comment
Share on other sites

you can hover with entity#hover()

you can get player area player#getArea(radius);

 

filter entity, using name, if entity not interacting with you, and within your area.

 

base snippet

	public boolean hoverNextEntity(String name)	{
		 RS2Object entity = objects.closest(new Filter<RS2Object>()	{
			@Override
			public boolean match(RS2Object o) {
				//filter them out
				return true;
			}
		});			
		 return entity.hover();
	}
Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...