Jump to content

Dealing with box trap animations


Recommended Posts

Posted

Having a problem with box trap animations. From what I experienced the box trap id changes during the animation of something getting in it or trying to. However even when I check for every single box trap id the script still sometimes acts like there wasnt anything on that tile. Heres the code that checks for it:

Entity trapsSpot1 = objects.closest(spotArea[0], new int[]{NORMAL_ID, BROKEN_ID, SHAKING_ID, FAILING, SUCCESS}); //failing and success = the ID's of the animating traps
if(trapsSpot1 == null){
	return State.TRAP1;
}

Is there any way to fix this, as in to check if a certain area contains any entities at all?

Posted (edited)

Can't you just check the Boxtrap on the ground by its name?

Is way more reliable since this will probably break every thursday bcs jagex update...

 

Afterwards check if it has the required action to determine what state it is in?

 

Khaleesi

 

Filter out the objects on the tile.

 

I switched from using id's to names, which should fix the problem with the animation because the name of the animating trap is box trap aswell. But now Im using a filter to declare whats a broken trap, but it tries to go for a trap thats out of the area I checked for even after the check.

RS2Object brokenTrap = objects.closest(new Filter<RS2Object>(){
			   @Override
			   public boolean match(RS2Object o){
			      return o != null && o.getName().equals("Box trap") && o.getActions().equals("Dismantle");
			   }});
if(brokenTrap != null){
	if(huntingArea.contains(brokenTrap)){
		return State.DISMANTLE;
	}
}	
Edited by Damighty
Posted

Fixed the problem I mentioned above, heres the final solution:

RS2Object brokenTrapFilter = getObjects().closest(new Filter<RS2Object>(){
			@Override
			public boolean match(RS2Object o) {
				return o != null && huntingArea.contains(o) && o.getName().equals("Box trap") &&
						o.hasAction("Dismantle") && !o.hasAction("Investigate");
			}
		});

+ using names instead of ID's

Thanks a lot to both of you for the help

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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