BotScaper Posted March 10, 2017 Share Posted March 10, 2017 (edited) So I took the skeleton from the topic in tutorials and I wanted to know what I have to do to make my bot eat under a certain hp This is the snippet of code. NPC kurask = npcs.closest("Kurask"); if(kurask != null){ kurask.interact("Attack"); getGroundItems().closest(loot).interact("Take"); if (getSkills().getDynamic(Skill.HITPOINTS) > random(20,getSkills().getStatic(Skill.HITPOINTS)-22)){ Also if you know a formula that works well for calculating what hp to eat at I would love to know. Edited March 10, 2017 by BotScaper Quote Link to comment Share on other sites More sharing options...
Muffins Posted March 10, 2017 Share Posted March 10, 2017 snippet section is your friend Quote Link to comment Share on other sites More sharing options...
Juggles Posted March 10, 2017 Share Posted March 10, 2017 (edited) WTF First of all, why is your code in the onStart LOL. Go learn java before trying to write a script Edited March 10, 2017 by Juggles 2 Quote Link to comment Share on other sites More sharing options...
BotScaper Posted March 10, 2017 Author Share Posted March 10, 2017 I am taking a java course thats halfway done the semester I just wanted to try my hand at something different Quote Link to comment Share on other sites More sharing options...
Keven Posted March 10, 2017 Share Posted March 10, 2017 getInventory().interact("Eat", "Foodname"); 1 Quote Link to comment Share on other sites More sharing options...
BotScaper Posted March 10, 2017 Author Share Posted March 10, 2017 (edited) 7 minutes ago, Keven said: getInventory().interact("Eat", "Foodname"); thank you! I can turn foodname into a list to provide multiple options right? Edited March 10, 2017 by BotScaper Quote Link to comment Share on other sites More sharing options...
Keven Posted March 10, 2017 Share Posted March 10, 2017 10 minutes ago, BotScaper said: thank you! I can turn foodname into a list to provide multiple options right? yes Quote Link to comment Share on other sites More sharing options...
BotScaper Posted March 10, 2017 Author Share Posted March 10, 2017 I think I fixed my code up if anyone would like to check, I have everything up to Banking done (which is just eat, loot, and attack) Quote Link to comment Share on other sites More sharing options...
Prolax Posted March 10, 2017 Share Posted March 10, 2017 This is not enough: if(kurask != null){ Should check if your player is not interacting, not in combat, etc. Quote Link to comment Share on other sites More sharing options...
BotScaper Posted March 10, 2017 Author Share Posted March 10, 2017 7 minutes ago, Prolax said: This is not enough: if(kurask != null){ Should check if your player is not interacting, not in combat, etc. would this work? if(kurask != null && !players.myPlayer().isUnderAttack()){ Quote Link to comment Share on other sites More sharing options...
Prolax Posted March 10, 2017 Share Posted March 10, 2017 - Check if npc is visible - Check if npc not is null - Check if myplayer not in combat - Check if myplayer not interacting That should be it, just look in the API for the methods. Quote Link to comment Share on other sites More sharing options...
BotScaper Posted March 10, 2017 Author Share Posted March 10, 2017 36 minutes ago, Prolax said: - Check if npc is visible - Check if npc not is null - Check if myplayer not in combat - Check if myplayer not interacting That should be it, just look in the API for the methods. if(kurask != null && !players.myPlayer().isUnderAttack()||!players.myPlayer().isAnimating()||kurask.isVisible()){ Quote Link to comment Share on other sites More sharing options...
Prolax Posted March 10, 2017 Share Posted March 10, 2017 if(kurask != null && !players.myPlayer().isUnderAttack() && !players.myPlayer().isAnimating() && kurask.isVisible()){ 1 Quote Link to comment Share on other sites More sharing options...