I need help with a math formula.
Displaying 1-5 of 5 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
blues_zodiakos

I've broken it down into parts (mainly to help myself). Somewhere, here, something is not going according to plan.

Here's the basic code.


pokemon[0].level=100;
pokemon[0].species=9;
pokemon[0].attackiv=0;
pokemon[0].attackev=0;

int GetBSAttack(int species)
{
int attack;
switch (species)
{
case 9: attack = 83;
}
Return attack;
}

int GetBSDefense(int species)
{
int defense;
switch (species)
{
case 9: defense = 100;
}
Return defense;
}

void stat_calc(int pkmn)
{
// pokemon attack
pokemon[pkmn].attack = GetBSAttack(pokemon[pkmn].species) * 2;
pokemon[pkmn].attack = pokemon[pkmn].attack + (pokemon[pkmn].attackev/4) + pokemon[pkmn].attackiv;
pokemon[pkmn].attack = (pokemon[pkmn].attack * pokemon[pkmn].level) / 100;
pokemon[pkmn].attack += 5;
// pokemon defense
pokemon[pkmn].defense = GetBSDefense(pokemon[pkmn].species) * 2;
pokemon[pkmn].defense = pokemon[pkmn].defense + (pokemon[pkmn].defenseev/4) + pokemon[pkmn].defenseiv;
pokemon[pkmn].defense = (pokemon[pkmn].defense * pokemon[pkmn].level) / 100;
pokemon[pkmn].defense +=5;
}

Now, running Stat_Calc gives:

pokemon[0].attack=190 (should be 171)
pokemon[0].defense=186 (should be 205, should be DEFINITELY higher than attack)

What exactly is wrong with my formulas? I assume that verge is doing rounding for the division, but I can't tell what it's doing exactly. Ideally, the formula should round DOWN for each subtotal, but I can't figure out how to do that.

Note: The above code is excerpts. I think I pasted everything necessary...

Posted on 2004-09-10 17:43:20

blues_zodiakos

Okay, now I feel stupid. I had another function running that mods the pokemon's stats based on their nature. Well, nature 0 changes, appropriately enough, attack and defense (by 1.1 and .9 respectively). Everything now works as it should. :D

Posted on 2004-09-10 18:00:35 (last edited on 2004-09-10 18:08:59)

Wolf

Since the problem seems solved. I'd like to continue on a tangent.
What system/method did you use to calculate damage?
I had a bit trouble with mine. It became a pretty complex function of attack power and defense, with a lot of randomness in it, but within a certain boundary.

I want it to be balanced, but it's difficult to keep it in reasonable proportion when levelling up.

Posted on 2004-09-11 18:01:58

blues_zodiakos

Copied directly from the pokemon_rs_function.txt file from gamefaqs:

(Damage Formula)
Damage HP
= ((((2L / 5 + 2) * A * P / D) / 50) + 2) * S * E * R / 100

L: Attacking pokemon's level
A: Attacking pokemon's Attack/Special Attack
P: Power of Attack used (Physical or Special is all the same)
D: Defense/Special Defense of Pokemon hit by attack
S: STAB (1, 1.5)
E: Effectiveness of attack (0, 0.25, 0.5, 1, 2, 4)
R: Random number between 85 and 100 inclusive

If there is STAB, S = 1.5
If there is no STAB, S = 1

If the attack does not affect the foe, then the value of E is 0.

If the attack does normal damage against the foe, then the value of E is 1.

If the attack is not effective against the foe, then the value of E is 0.5. Sometimes the value of E may be 0.25 if it is a Dual-type pokemon and the attack is not effective against both types.

If the attack is effective against the foe, then the value of E is 2. But sometimes the value of E may be 4 if it is a Dual-type pokemon and the attack used is effective against both types.
---------------

That's the formula I'm using. :D It's the actual formula the games use.

Posted on 2004-09-12 03:55:28

mcgrue

I have printouts of the entire mathematical model behind FF1 and FF4. Dunno if they're on gameFAQs tho... I got them from RPGamer.com back when it was Andrew Vestal's UOSSHP.

Posted on 2004-09-12 04:20:03


Displaying 1-5 of 5 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.