Varies Posted March 2, 2015 Share Posted March 2, 2015 Hey all, again I come with a question that needs answering. So for some odd reason, the script I am developing is having some issues eating. At first I thought the problem lied within the id but that wasn't the case, nor was it the case with the functions I have created and how they are formatted inside my code. I have found the source of the problem and was wondering if anyone could tell me on whats happening or how I could fix it. if(myPlayer().getHealth() < randomHealth) { this.log("Trying to eat"); Item food = inventory.getItem(Library.foodId); food.interact("Eat"); } The integer randomHealth is capped at 30 for the testing and it still doesn't work, thoughts anyone? It's been returning 39 hp when I'm actually at 36. Thanks! Quote Link to comment Share on other sites More sharing options...
Isolate Posted March 2, 2015 Share Posted March 2, 2015 health returns a % and only when in combat. best to compare static/dynamic level of hitpoints Quote Link to comment Share on other sites More sharing options...
Varies Posted March 2, 2015 Author Share Posted March 2, 2015 health returns a % and only when in combat. best to compare static/dynamic level of hitpoints Why does it only work in combat? Quote Link to comment Share on other sites More sharing options...
Isolate Posted March 2, 2015 Share Posted March 2, 2015 (edited) Why does it only work in combat? Really unsure sorry int currentHealth(){ int percperone = (100 / skills.getStatic(Skill.HITPOINTS)); return (percperone * skills.getDynamic(Skill.HITPOINTS)); } I think would do it or just int currentHealth(){ return ((100 / skills.getStatic(Skill.HITPOINTS)) * skills.getDynamic(Skill.HITPOINTS)); } Edited March 2, 2015 by Isolate Quote Link to comment Share on other sites More sharing options...
Extreme Scripts Posted March 2, 2015 Share Posted March 2, 2015 http://osbot.org/api/ Quote Link to comment Share on other sites More sharing options...
Lemons Posted March 2, 2015 Share Posted March 2, 2015 Why does it only work in combat? Due to this being pulled from the health bar above your head. Quote Link to comment Share on other sites More sharing options...
Varies Posted March 2, 2015 Author Share Posted March 2, 2015 Really unsure sorry int currentHealth(){ int percperone = (100 / skills.getStatic(Skill.HITPOINTS)); return (percperone * skills.getDynamic(Skill.HITPOINTS)); } I think would do it or just int currentHealth(){ return ((100 / skills.getStatic(Skill.HITPOINTS)) * skills.getDynamic(Skill.HITPOINTS)); } Thanks a lot bro Due to this being pulled from the health bar above your head. That makes sense, thanks a lot too. Quote Link to comment Share on other sites More sharing options...