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