Saiyan Posted August 31, 2016 Posted August 31, 2016 This may possibly be a stupid question but why is it that some people store RS2Objects/NPC's i.e I've always wondered is this bad coding or is there any benefit at all in doing this? public class ClassName extends Script { private NPC npcName; @[member=Override] public void onStart() { npcName = getNpcs().closest(npc -> npc.getName().equals("Name") && npc.hasAction("Attack") && npc.getHealthPercent() > 0 && !npc.isUnderAttack()); } @[member=Override] public int onLoop() throws InterruptedException { if(npcName != null && !getCombat().isFighting() && !myPlayer().isUnderAttack() && !myPlayer().isInteracting(npcName)) { npcName.interact("Attack"); //cond sleep etc } else { //else stuff } return int of choice; } I've seen some people doing this and from my understanding, they store the NPC name/filter conditions into the NPC variable that they create but in the onLoop() they'll call the variable and the pre-set filter conditions? (Sorry if that doesn't make sense) TLDR; why would people do this?
Saiyan Posted August 31, 2016 Author Posted August 31, 2016 There's no benefit, that's just bad coding Thanks senpai.