March 2, 201511 yr 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!
March 2, 201511 yr health returns a % and only when in combat. best to compare static/dynamic level of hitpoints
March 2, 201511 yr Author health returns a % and only when in combat. best to compare static/dynamic level of hitpoints Why does it only work in combat?
March 2, 201511 yr 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, 201511 yr by Isolate
March 2, 201511 yr Why does it only work in combat? Due to this being pulled from the health bar above your head.
March 2, 201511 yr Author 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.
Create an account or sign in to comment