Jump to content

Player's Health? Bugged?


Recommended Posts

Posted

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!

 

Posted (edited)

Why does it only work in combat?

Really unsure sorry :s 

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 by Isolate
Posted

 

Really unsure sorry :s 

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

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...