Jump to content

What are the percentages of these?


Recommended Posts

My brains not working as well as it should be at the moment, and I can't figure out the percentages these equal to:


if($survival <= 100 && $survival >= 60){$code;} //high HP
elseif($survival < 60 && $survival >= 20){$code;} //medium HP
elseif($survival < 20 && $survival >= 10){$even_more_code;} //low HP
elseif($survival < 10 && $survival >= 1){$hey_look_some_code;} // very low HP

This is what I got:

  • High HP (80-100) - 50%
  • Med HP (50-70) - 30%
  • Low HP (20-50) - 10%
  • Very Low HP (0-20) - 10%

But I'm pretty sure that's not as accurate as it could be.

Link to comment
Share on other sites

I think you may need to give some more information, but given what you have listed.

The high hp section is 100 to 60, that means it's 40 out of the whole assuming it is out of 100 (i.e. 100-60=40). The medium goes from 20-59, it goes into the low hp section when survival is 10-19, and otherwise 1-9 goes into the low. 

But if survival is HP, then it's not exactly a percentage, because it's not going to go into high health 40% of the time. It's going to into anytime health is high. This would only happen 40% if survival is a random number from 1-100. 

Maybe you could clarify what you are trying to do a bit and I may be able to help better.

Link to comment
Share on other sites

Oof, sorry. $survival is a random number between 1 and 100:

$survival = mt_rand(1,100);

However, health is it's own variable. I probably should've included it before, but this would be the whole thing:

//survival rate
	$survival = mt_rand(1,100);
	$highhp = mt_rand(80,100);
	$medhp = mt_rand(50,70);
	$lowhp = mt_rand(20,50);
	$vlowhp = mt_rand(0,20);
	if($survival <= 100 && $survival > 60){$health = $highhp; $illness = "none";}
	elseif($survival <= 60 && $survival > 20){$health = $medhp; $illness = "none";}
	elseif($survival <= 20 && $survival > 10){$health = $lowhp; $illness = "none";}
	elseif($survival <= 10 && $survival >= 1){$health = $vlowhp; $illness = "runt";}
//survival rate end!


Link to comment
Share on other sites

Ah okay, that makes now. 

Well the numbers you put below are a little off. The high and medium are about 40/40% each based on what you have listed (give or take a percent depending on the >=). If you want it to be 50/30 then you'll want to set the 60 to 50 instead. Since 100-50 = 50, that would give land you in that bracket about 50% of the time, and then 50-20 = 30 giving you about 30% for the second one. 

Hope that helps!

  • Thanks 1
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.

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.

  • Create New...