August 5, 201510 yr 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
August 5, 201510 yr 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, 201510 yr by fixthissite
August 5, 201510 yr 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!
August 5, 201510 yr 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"); }
Create an account or sign in to comment