libSPEC
Pokemon Save Editing Library
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Pages
Enumerations | Functions | Variables
stat.h File Reference

Contains functions for calculating the stats of pokemon. More...

#include "types.h"

Enumerations

enum  stat_nature_t {
  NATURE_HARDY = 0,
  NATURE_LONELY = 1,
  NATURE_BRAVE = 2,
  NATURE_ADAMANT = 3,
  NATURE_NAUGHTY = 4,
  NATURE_BOLD = 5,
  NATURE_DOCILE = 6,
  NATURE_RELAXED = 7,
  NATURE_IMPISH = 8,
  NATURE_LAX = 9,
  NATURE_TIMID = 10,
  NATURE_HASTY = 11,
  NATURE_SERIOUS = 12,
  NATURE_JOLLY = 13,
  NATURE_NAIVE = 14,
  NATURE_MODEST = 15,
  NATURE_MILD = 16,
  NATURE_QUIET = 17,
  NATURE_BASHFUL = 18,
  NATURE_RASH = 19,
  NATURE_CALM = 20,
  NATURE_GENTLE = 21,
  NATURE_SASSY = 22,
  NATURE_CAREFUL = 23,
  NATURE_QUIRKY = 24
}
 List of natures by index.
 
enum  stat_stat_t {
  STAT_HP = 0,
  STAT_ATTAK = 1,
  STAT_DEFENSE = 2,
  STAT_SPEED = 3,
  STAT_SP_ATTACK = 4,
  STAT_SP_DEFENSE = 5
}
 
enum  stat_bonus_t {
  STAT_BONUS_NONE,
  STAT_BONUS_POSITIVE,
  STAT_BONUS_NEGATIVE
}
 Enum to tell the stat functions if a nature is beneficial or otherwise. More...
 
enum  stat_growth_rate_t {
  STAT_GROWTH_RATE_ERRATIC = 0,
  STAT_GROWTH_RATE_FAST = 1,
  STAT_GROWTH_RATE_MEDIUM_FAST = 2,
  STAT_GROWTH_RATE_MEDIUM_SLOW = 3,
  STAT_GROWTH_RATE_SLOW = 4,
  STAT_GROWTH_RATE_FLUCTUATING = 5
}
 

Functions

stat_bonus_t stat_get_bonus (stat_nature_t, stat_stat_t)
 
stat_nature_t stat_get_nature (uint32_t pid)
 
uint8_t stat_get_level (stat_growth_rate_t, uint32_t exp)
 
uint16_t gb_calc_stat (uint8_t, uint8_t, uint8_t, uint16_t)
 Used to calculate a non-HP stat for a pokemon from generation 1 or 2. More...
 
uint16_t gb_calc_hp_stat (uint8_t, uint8_t, uint8_t, uint16_t)
 Used to calculate the HP stat for a pokemon from generation 1 or 2. More...
 
uint16_t gba_calc_stat (uint8_t, uint8_t, uint8_t, uint8_t, stat_bonus_t)
 Used to calculate a non-HP stat for a pokemon from generation 3. More...
 
uint16_t gba_calc_hp_stat (uint8_t, uint8_t, uint8_t, uint8_t)
 Used to calculate the HP stat for a pokemon from generation 3. More...
 
uint16_t nds_calc_stat (uint8_t level, uint8_t base_stat, uint8_t iv, uint8_t ev, stat_bonus_t)
 Used to calculate a non-HP stat for a pokemon from generation 4. More...
 
uint16_t nds_calc_hp_stat (uint8_t, uint8_t, uint8_t, uint8_t)
 Used to calculate the HP stat for a pokemon from generation 4. More...
 
uint16_t dsi_calc_stat (uint8_t level, uint8_t base_stat, uint8_t iv, uint8_t ev, stat_bonus_t)
 Used to calculate a non-HP stat for a pokemon from generation 5. More...
 
uint16_t dsi_calc_hp_stat (uint8_t, uint8_t, uint8_t, uint8_t)
 Used to calculate the HP stat for a pokemon from generation 5. More...
 

Variables

const uint32_t STAT_TOTAL_EXP_ERRATIC [100]
 Erratic Experience Table, indexed 0 to 99 for levels 1 to 100.
 
const uint32_t STAT_TOTAL_EXP_FAST [100]
 Fast Experience Table, indexed 0 to 99 for levels 1 to 100.
 
const uint32_t STAT_TOTAL_EXP_MEDIUM_FAST [100]
 Medium Fast Experience Table, indexed 0 to 99 for levels 1 to 100.
 
const uint32_t STAT_TOTAL_EXP_MEDIUM_SLOW [100]
 Medium Slow Experience Table, indexed 0 to 99 for levels 1 to 100.
 
const uint32_t STAT_TOTAL_EXP_SLOW [100]
 Slow Experience Table, indexed 0 to 99 for levels 1 to 100.
 
const uint32_t STAT_TOTAL_EXP_FLUCTUATING [100]
 Fluctuating Experience Table, indexed 0 to 99 for levels 1 to 100.
 

Detailed Description

Contains functions for calculating the stats of pokemon.

Enumeration Type Documentation

List of stats by index.

Enum to tell the stat functions if a nature is beneficial or otherwise.

Enumerator
STAT_BONUS_NONE 

A neutral bonus for the given stat.

STAT_BONUS_POSITIVE 

A beneficial bonus for the given stat.

STAT_BONUS_NEGATIVE 

A harmful bonus for the given stat.

Function Documentation

uint16_t gb_calc_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint16_t  stat_exp 
)

Used to calculate a non-HP stat for a pokemon from generation 1 or 2.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
stat_expThe pokemon's stat experience.
Returns
The value for the pokemons stat.
uint16_t gb_calc_hp_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint16_t  stat_exp 
)

Used to calculate the HP stat for a pokemon from generation 1 or 2.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
stat_expThe pokemon's stat experience.
Returns
The value for the pokemons stat.
uint16_t gba_calc_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev,
stat_bonus_t  bonus 
)

Used to calculate a non-HP stat for a pokemon from generation 3.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
bonusThe bonus from nature for the given stat.
Returns
The value for the pokemons stat.
uint16_t gba_calc_hp_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev 
)

Used to calculate the HP stat for a pokemon from generation 3.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
Returns
The value for the pokemons stat.
uint16_t nds_calc_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev,
stat_bonus_t  bonus 
)

Used to calculate a non-HP stat for a pokemon from generation 4.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
bonusThe bonus from nature for the given stat.
Returns
The value for the pokemons stat.
uint16_t nds_calc_hp_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev 
)

Used to calculate the HP stat for a pokemon from generation 4.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
Returns
The value for the pokemons stat.
uint16_t dsi_calc_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev,
stat_bonus_t  bonus 
)

Used to calculate a non-HP stat for a pokemon from generation 5.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
bonusThe bonus from nature for the given stat.
Returns
The value for the pokemons stat.
uint16_t dsi_calc_hp_stat ( uint8_t  level,
uint8_t  base_stat,
uint8_t  iv,
uint8_t  ev 
)

Used to calculate the HP stat for a pokemon from generation 5.

Parameters
levelThe pokemon's level.
base_statThe base stat we are claculating.
ivThe pokemon's iv for the given stat.
evThe pokemon's effort value for the given stat.
Returns
The value for the pokemons stat.