tmp 4 Share Posted April 17, 2020 I have this script with two if statements and I need one to override the other asap when it happens The problem im having is that when eatFood() function is happening, it cant execute anything inside the other if -statement. e.g. if the bot is currently eating food, I need it to stop eating and skip to getting the animation of the NPC When the eatFood() is over, the animation has already ended, and it skips the getAnimation if (xNPC != null) { if (context.getCombat().getHealthPercent() <= 70) { eatFood(); } else if (xNPC.getAnimation == 1000) { //Do something important stuff } } private void eatFood() { Item food = context.getInventory().get(item -> item != null && item.getName().contains("Shark")); if (food != null) { food.interact("Eat"); sleepUntil(() -> context.getCombat().getHealthPercent() > 70, 1500); } } I'd appreciate if you guys would guide me towards right path Link to comment Share on other sites More sharing options...
Pseudo 179 Share Posted April 17, 2020 The way your logic is structured is flawed for what you want. The if statement in regards to the npc anim won't fire if the health is below your value, and that may take a tick to register it isn't after the eat food method is triggered due to your else statement. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.