Chris Posted August 5, 2015 Posted August 5, 2015 Issue Code Source package me.sinatra.machine.Activities; import me.sinatra.machine.util.Activity; import org.osbot.rs07.api.filter.Filter; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.script.Script; /** * Created by Sinatra on 8/5/2015. */ public class attackTarget implements Activity { @Override public boolean shouldDoActivity(Script s) { return ((!s.myPlayer().isAnimating()) && (s.myPlayer().isVisible()) && (!s.myPlayer().isUnderAttack())); } @Override public int doActivity(Script s) throws InterruptedException { final NPC cow = s.npcs.closest(new Filter<NPC>() { @Override public boolean match(NPC npc) { return npc != null && npc.getName().equals("Cow") && !npc.isUnderAttack() && npc.getHealth() > 0 && s.map.canReach(npc); } }); if (!cow.isVisible() || (cow == null)) { s.camera.toEntity(cow); s.sleep(s.random(2000)); } else { cow.interact("Attack"); s.sleep(s.random(300)+3000); } return (s.random(500,2000)); } } Need help
fixthissite Posted August 5, 2015 Posted August 5, 2015 (edited) You are doing !cow.isVisible before checking if cow is null. Change if(!cow.isVisible() || cow == null) to if(cow == null || !cow.isVisible()) Edited August 5, 2015 by fixthissite 1
Apaec Posted August 5, 2015 Posted August 5, 2015 Issue Code Source s.camera.toEntity(cow); from reading the line ref, the npe points to here. you're trying to turn the camera to a null cow hence the npe!
Chris Posted August 5, 2015 Author Posted August 5, 2015 ahh hot damn folks! Sinatra scripter noob did it again! thanks again!
Bobrocket Posted August 5, 2015 Posted August 5, 2015 In this line: if (!cow.isVisible() || (cow == null)) { You're saying if the cow doesn't exist OR it isn't visible, move the camera. Change to: if (cow != null) { if (!cow.isVisible()) s.getCamera().toEntity(cow); cow.interact("Attack"); } 1