March 24, 201510 yr 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?
March 24, 201510 yr On mobile didn't see full code Never mind me. Edited March 24, 201510 yr by twin 763
March 24, 201510 yr 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 Edited March 24, 201510 yr by Khaleesi
March 24, 201510 yr Author 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 March 24, 201510 yr by Damighty
March 24, 201510 yr Author 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