I don't think you understand what you are trying to do yourself at this point.
You are trying to fix something thats completely misdesigned, it's like putting boat parts in a car and expecting it to work
I also said to post some code, then you post 5 lines of code which could be anything in the world and you expect to get a proper answer -_-OOP
I suggest you to learn java OOP properly to begin with
What I hear from this is that your design is not correct, scripts made in java just follow the general java conventions.
Like when you are programming OOP, there should be 0 reason to call a method from the object to where you instanced the object.
Without showing any code it;s kinda hard to see what you are trying to do. so enlighten us and we will see what I can do for you
Because you are loading the cloest cow with this code, that won't always be the cow you are fighting if another ones get into the same range as the one you are already fighting.
NPC cow = main.getNpcs().closest(npc -> npc.getName().startsWith("cow") && npc.isAttackable());
What you can do is check if you are under attack by a cow, if so don't do anything, else attack a new one
NPC npcAttackingMe = script.getNpcs().closest(npc -> npc.isInteracting(script.myPlayer()) && npc.hasAction("Attack") && npc.getHealthPercent() > 0 && script.getMap().canReach(npc));
I believe the walking code is a event and no other code of yours gets executed until it's done. If you print out some logs you can see that
What you can do is create your own walkingevent: (Rough guess)
WalkingEvent event = new WalkingEvent();
event.setPath(areasAndPaths.pathToDestination);
event.setHighBreakPriority(true);
event.setBreakCondition(new Condition() {
@Override
public boolean evaluate() {
return atDestination() || nearbyThreat();
}
});
hmm stramge, if you see tyhis again, please grab a screenshot so I can see where it is, script status, how the inventory looks and that kind of stuff
Or ring of dueling to ferox, free health and run restore ^^