Jump to content

Dealing with box trap animations


Trivial

Recommended Posts

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?

Link to comment
Share on other sites

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
Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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