Page 1 of 1
How would I implement this?
Posted: Wed Jul 14, 2010 11:38 pm
by Genaga
The rate of Pokémon encounter is determined from a simple mathematical formula:
1 in (187.5 / ( x )) per step
Let x equal the a value which determines how rare the Pokémon is. The higher the encounter rate, the more common the Pokémon is.
Encounter-rate table
Encounter Type Encounter Rate
Very Common 10
Common 8.5
Semi-Rare 6.75
Rare 3.33
Very Rare 1.25
But I can't figure out how i would implement this into a game, anyone got an idea on how its done?
Re: How would I implement this?
Posted: Thu Jul 15, 2010 1:39 am
by Jackolantern
Honestly, you already have it all outlined here, but it will be a bit easier if you change your formula a bit. Instead of having the variable in your formula, just make a simple random roll and then check the results (not your specific numbers, but you can easily change them):
Code: Select all
//generate a random number between 1 and 1200
$chance = rand(1, 1200);
//check to the random number for results
if ($chance < 100) {
pullVeryRare();
} else if ($chance < 200) {
pullRare();
} else if ($chance < 300) {
pullSemiRare();
} else if ($chance < 500) {
pullCommon();
} else if ($chance < 800) {
pullVeryCommon();
} else {
//Nothing happens. No pokemon pulled
}
Then you can either have pokemon in separate tables in your database and pull from whichever table is called for, or you can just have rarity stored in one master pokemon table and use a query like:
Code: Select all
SELECT * FROM pokemon WHERE rarity = "verycommon" AND level >= 10 AND level <= 20 LIMIT 1
Of course you would have to calculate the correct levels and use variable, and adjust it any other ways you need to.
Re: How would I implement this?
Posted: Thu Jul 15, 2010 11:15 am
by Genaga
Thanks ;D That probably is the best way to go about it, I couldn't think at all -.-'
I'll try get it done now

Re: How would I implement this?
Posted: Thu Jul 15, 2010 11:18 am
by hallsofvallhalla
you could go a bit deeper to make it even harder to get a rare pokemon..you will find the random system is not as "random" as you might like
Code: Select all
$chance = rand(1, 5);
$secondchance(1,100);
switch ($chance) {
case "1":
if($secondchance < 10){echo "found very-rare";}
else {echo " found common";}
break;
case "2":
if($secondchance < 20){echo "found rare";}
else {echo " found common";}
break;
case "3":
if($secondchance < 30){echo "found semi-rare";}
else {echo " found very common";}
break;
case "4":
if($secondchance < 50){echo "found common";}
else {echo " found very common";}
break;
case "5":
echo "found very common";
break;