scriptersteve Posted December 24, 2017 Share Posted December 24, 2017 Currently using this as my eating method: but conscious that always eating when health < 50% is very botlike. What is a better way to go about this? Are there any snippet examples that could would be useful? if(myPlayer().getHealthPercent() < 50){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } Quote Link to comment Share on other sites More sharing options...
Muffins Posted December 24, 2017 Share Posted December 24, 2017 14 minutes ago, scriptersteve said: but conscious that always eating when health < 50% is very botlike ... Quote Link to comment Share on other sites More sharing options...
The Undefeated Posted December 24, 2017 Share Posted December 24, 2017 Randomize it? Quote Link to comment Share on other sites More sharing options...
Elysiano Posted December 24, 2017 Share Posted December 24, 2017 Everytime you eat set a new random percentage to eat at (like eat at 40-60%) Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 24, 2017 Author Share Posted December 24, 2017 if(myPlayer().getHealthPercent() < 65 && (Math.random() < 0.1)){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } if(myPlayer().getHealthPercent() < 50 && (Math.random() < 0.2)){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } if(myPlayer().getHealthPercent() < 40 && (Math.random() < 0.25)){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } if(myPlayer().getHealthPercent() < 25){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } something like this? Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 24, 2017 Author Share Posted December 24, 2017 or like this: if(myPlayer().getHealthPercent() < (75*(Math.random())) || myPlayer().getHealthPercent() < 20){ getInventory().interact("Eat", this.config.getFoodName()); new ConditionalSleep(2000,1000){ @ Override public boolean condition() throws InterruptedException { return myPlayer().getAnimation() == 829; } }.sleep(); sleep(random(400, 650)); } Quote Link to comment Share on other sites More sharing options...
Elysiano Posted December 24, 2017 Share Posted December 24, 2017 (edited) Do something simple like: int eatPercentage = 50; //Initial value if(myPlayer().getHealthPercent() < eatPercentage){ //Eat food eatPercentage = random(40,60); //Set new value } Edited December 24, 2017 by Elysiano 1 Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 24, 2017 Author Share Posted December 24, 2017 ah ok - thanks, was wondering the best way to go about doing it Quote Link to comment Share on other sites More sharing options...
Elysiano Posted December 24, 2017 Share Posted December 24, 2017 (edited) I'm not sure if there is ever a 'best' way to do it, but if it is efficient, and it works, then it should do the job ;) Edited December 24, 2017 by Elysiano Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 24, 2017 Author Share Posted December 24, 2017 ok, thanks will it not always be over-written to 50 though: as the only place it seemed to work instanciating it was inside the onloop function? never mind was being a retard was one curly brace out when i tried instanciating it above Quote Link to comment Share on other sites More sharing options...
aftabdear Posted December 24, 2017 Share Posted December 24, 2017 < 50% doesnt mean it will eat at the exact same hp everytime Quote Link to comment Share on other sites More sharing options...
HeyImJamie Posted December 24, 2017 Share Posted December 24, 2017 18 minutes ago, scriptersteve said: ok, thanks will it not always be over-written to 50 though: as the only place it seemed to work instanciating it was inside the onloop function? never mind was being a retard was one curly brace out when i tried instanciating it above int eatAt would be global, it'd then be set again after eating. Quote Link to comment Share on other sites More sharing options...
Lemons Posted December 24, 2017 Share Posted December 24, 2017 The way I handle this is to eat when food will be 100% effective or if the character is under or at a certain threshold (I set this to monsters max hit). So say you eating trout, it heals 7 hp. If we have 25 hp, we heal at 18 hp or less. This keeps us near full HP which is generally what is wanted with food but won't waste food with %s. But say we were fighting something with a max hit of 5, we'd have a minimum threshold of 5 HP, so in case the monster hits us for max damage we can still live. 1 Quote Link to comment Share on other sites More sharing options...
Juggles Posted December 24, 2017 Share Posted December 24, 2017 Use random(int,int); Quote Link to comment Share on other sites More sharing options...
scriptersteve Posted December 24, 2017 Author Share Posted December 24, 2017 yeah smart, thanks for all your replies Quote Link to comment Share on other sites More sharing options...