Jump to content

Player's Health? Bugged?


Varies

Recommended Posts

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!

 

Link to comment
Share on other sites

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
Link to comment
Share on other sites

 

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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