Jump to content

need coding help and don't know where else to put this.


Rot8er_ConeX

Recommended Posts

I'm trying to make a Pokemon fan game, and one of the features of the Pokedex is the stats page, which shows species/form-specific stats that are normally invisible to players - the base stats, EV yield, base happiness (which is referred to in game as "initial friendliness"), egg steps to hatch (for Pokemon that have eggs), etc.


One of the things posted in this page of the Pokedex is the Capture Rate. I have the "rareness" numbers in their most up-to-date forms. These numbers display as both a number and a bar as if from a bar graph. But I'd also like to display a "using a Pokeball, while the Pokemon is at max health" kind of number, like the percents that Bulbapedia has in their capture rate sections. Upon browsing their links, I eventually found a link to this lovely algorithm.


I want these "likelihood of capture" percentages to work under the following assumptions, which are the same ones that Bulba used for theirs:

- The player is throwing an ordinary Poke Ball (Ball Modifier of 1)

- The Pokemon trying to escape is at full health (so HP(max)*3-HP(current)*2 becomes just HP(max)*1 and therefore the two HP(max)es on either side of the fraction cancel each other out).

- The Pokemon trying to escape does not have a status affliction (Status Modifier of 1)

- No O-Powers or Pass Powers will be used, because they don't exist in my game.

- No "mystery grass" modifier.

- A Critical Capture won't happen. (so that CC/255 is 0 and that 1-(CC/255) is 1)


Which means that:

X=((3M-2H)*G*C*B/3M)*S*O

X=((3M-2M)*1*C*1/3M)*1*1

X=((M)*C/3M)

X=C/3


Y remains as it is:

Y=65,536/((255/X)^(3/16))


Now, here's where I'm confused. How do I convert this number Y into a meaningful percent? I tried the formula given on that calculation page ((Y/65,536)^4, with a multiplication by 100 in order to turn it into a percent rather than a decimal. I am now getting percents that are slightly higher than those displayed on Bulbapedia, or on this calculator. Is this merely because I'm disregarding critical captures?


In case anyone's curious, here's my actual code, in Ruby:

   catchPercentX=catchRate/3
catchPercentY= 65536 / ((255/catchPercentX)**0.1875)
catchPercent=((catchPercentY/65536)**4)*10000

The resulting number is then divided by 100 to create a percent that has two decimal places.

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.

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...