src/game/game_levels.c
Actions and Psynergy lists, characters, experience and levelling up. More…
Included by game.c.
Structures
| Name | Description | |
|---|---|---|
struct | LEVEL_UP_STATE | Scratch for gmUnitLevelUp, which takes it from EWRAM first (syHeapAllocateEWRAM) and frees it before returning. |
Macros
| Name | Description | |
|---|---|---|
#define | PSYNERGY_ACTION_AT (slots, index) ((slots)[index].encodedAction) |
Enumerations
| Name | Description | |
|---|---|---|
enum | anonymous enum { PSYNERGY_FROM_CLASS, PSYNERGY_FROM_ITEM } | Marks on an action list entry: learned from the class, or granted by an equipped item. |
Functions
| Name | Description | |
|---|---|---|
ABILITY_DEFINITION * | gmAbilityGetDefinition (Sint32 abilityId) | Returns the definition of ability abilityId (its low 14 bits); an id past the table gives the first. |
Bool | gmUnitKnowsPsynergy (Sint32 unitId, Sint32 abilityId) | Returns 1 when abilityId is in the unit's Psynergy list. |
Sint32 | gmUnitRefreshPsynergy (Sint32 unitId) | Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list, adds every class action learned by its level and the action of each equipped item that grants one, and closes it up again. |
Sint32 | gmUnitLearnPsynergy (Sint32 unitId, Sint32 abilityId) | Teaches a character abilityId for good (or makes a class action permanent by clearing its marks), then rebuilds its list. |
LEVEL_UP_RESULT * | gmUnitCheckLevelUp (Sint32 unitId, LEVEL_UP_RESULT *gains) | Levels the character up once if it has the experience, and returns gains, or NULL. |
const CHARACTER_DEFINITION * | gmCharacterGetDefinition (Sint32 characterId) | Returns character characterId's definition: growth curves, starting level and equipment. |
void | gmPartyInitCharacters (void) | Sets up all eight characters for a new game: names from the message table, starting equipment equipped, class and elements worked out, and levels raised to their starting level. |
void | gmUnitLevelNoOperation (void) | Unused: reserved entry; keeps its place in the stub table. |
Uint32 | gmUnitGetExperienceForLevel (Sint32 unitId, Sint32 level) | Returns the experience a character needs for level (0 for level 0 and below); -1 for an enemy or a level above 99. |
LEVEL_UP_RESULT * | gmUnitLevelUp (Sint32 unitId, LEVEL_UP_RESULT *gains) | Raises a character one level, up to 99, each base stat growing along its curve with a random part. |
LEVEL_UP_RESULT * | gmUnitTryLevelUp (Sint32 unitId, LEVEL_UP_RESULT *gains) | Levels the character up once if its experience reaches the next level, and returns gains, or NULL. |
void | gmUnitLevelUpTo (Sint32 unitId, Sint32 targetLevel) | Levels character unitId up one level at a time until targetLevel, then recomputes its stats. |
Description
Actions and Psynergy lists, characters, experience and levelling up. Part of
game.c.
Macros in detail
PSYNERGY_ACTION_AT
#define PSYNERGY_ACTION_AT(slots, index) ((slots)[index].encodedAction)
#define PSYNERGY_ACTION_AT(slots, index) (((Uint16 *)(slots))[(index) * 2])
Referenced by gmUnitRefreshPsynergy().
Definition at lines 7 and 9 of file game_levels.c.
Enumerations in detail
anonymous enum
enum { PSYNERGY_FROM_CLASS, PSYNERGY_FROM_ITEM }
Marks on an action list entry: learned from the class, or granted by an equipped item. Plain entries were taught for good.
| Enumerator | Value | Description |
|---|---|---|
PSYNERGY_FROM_CLASS | 0x8000 | |
PSYNERGY_FROM_ITEM | 0x4000 |
Definition at line 58 of file game_levels.c.
Functions in detail
gmAbilityGetDefinition
ABILITY_DEFINITION *gmAbilityGetDefinition(Sint32 abilityId)
Returns the definition of ability abilityId (its low 14 bits); an id past
the table gives the first.
References AbilityDefinitions and Sint32.
Referenced by dbIncreaseItemAndLevelSelectAbility() and gmItemGetTargetMode().
Definition at line 14 of file game_levels.c.
gmUnitKnowsPsynergy
Bool gmUnitKnowsPsynergy(Sint32 unitId, Sint32 abilityId)
Returns 1 when abilityId is in the unit's Psynergy list.
References gmUnitGet() and Sint32.
Definition at line 34 of file game_levels.c.
gmUnitRefreshPsynergy
Sint32 gmUnitRefreshPsynergy(Sint32 unitId)
Rebuilds a character's Psynergy list: drops the actions its class and items gave, closes up the list, adds every class action learned by its level and the action of each equipped item that grants one, and closes it up again.
References gmClassGetDefinition(), gmItemGetDefinition(), gmUnitGet() and Sint32.
Referenced by gmInventoryEquip(), gmUnitLearnPsynergy(), gmUnitLevelUp() and gmUnitUpdateClass().
Definition at line 67 of file game_levels.c.
gmUnitLearnPsynergy
Sint32 gmUnitLearnPsynergy(Sint32 unitId, Sint32 abilityId)
Teaches a character abilityId for good (or makes a class action permanent
by clearing its marks), then rebuilds its list. Returns the action's place in
the list, or -1 when the list is full.
References gmUnitGet(), gmUnitRefreshPsynergy() and Sint32.
Referenced by gmPartyEndChildhood().
Definition at line 205 of file game_levels.c.
gmUnitCheckLevelUp
LEVEL_UP_RESULT *gmUnitCheckLevelUp(Sint32 unitId, LEVEL_UP_RESULT *gains)
Levels the character up once if it has the experience, and returns gains, or
NULL.
References gmUnitTryLevelUp() and Sint32.
Definition at line 260 of file game_levels.c.
gmCharacterGetDefinition
const CHARACTER_DEFINITION *gmCharacterGetDefinition(Sint32 characterId)
Returns character characterId's definition: growth curves, starting level
and equipment.
References CharacterDefinitionTable and Sint32.
Referenced by gmPartyInitCharacters(), gmUnitGetElementLevels() and gmUnitLevelUp().
Definition at line 267 of file game_levels.c.
gmPartyInitCharacters
void gmPartyInitCharacters(void)
Sets up all eight characters for a new game: names from the message table, starting equipment equipped, class and elements worked out, and levels raised to their starting level.
References CharacterNewGameIds, gmCharacterGetDefinition(), gmInventoryAddItem(), gmInventoryEquip(), gmUnitCalculate(), gmUnitGet(), gmUnitLevelUpTo(), gmUnitUpdateClass(), mnMessageDecodeRawUnboundedStub() and Sint32.
Referenced by gmMainRoutineStateInitDefaults().
Definition at line 278 of file game_levels.c.
gmUnitLevelNoOperation
void gmUnitLevelNoOperation(void)
Unused: reserved entry; keeps its place in the stub table.
Definition at line 342 of file game_levels.c.
gmUnitGetExperienceForLevel
Uint32 gmUnitGetExperienceForLevel(Sint32 unitId, Sint32 level)
Returns the experience a character needs for level (0 for level 0 and
below); -1 for an enemy or a level above 99.
References CharacterLevelExpTable, gmUnitGet() and Sint32.
Referenced by gmUnitLevelUp() and gmUnitTryLevelUp().
Definition at line 348 of file game_levels.c.
gmUnitLevelUp
LEVEL_UP_RESULT *gmUnitLevelUp(Sint32 unitId, LEVEL_UP_RESULT *gains)
Raises a character one level, up to 99, each base stat growing along its curve with a random part. Returns gains.
References gmCharacterGetDefinition(), gmUnitCalculate(), gmUnitGet(), gmUnitGetExperienceForLevel(), gmUnitRefreshPsynergy(), Sint32, state, syHeapAllocateEWRAM() and syHeapRelease().
Referenced by gmUnitLevelUpTo() and gmUnitTryLevelUp().
Definition at line 369 of file game_levels.c.
gmUnitTryLevelUp
LEVEL_UP_RESULT *gmUnitTryLevelUp(Sint32 unitId, LEVEL_UP_RESULT *gains)
Levels the character up once if its experience reaches the next level, and
returns gains, or NULL.
References gmUnitGet(), gmUnitGetExperienceForLevel(), gmUnitLevelUp() and Sint32.
Referenced by gmUnitCheckLevelUp().
Definition at line 460 of file game_levels.c.
gmUnitLevelUpTo
void gmUnitLevelUpTo(Sint32 unitId, Sint32 targetLevel)
Levels character unitId up one level at a time until targetLevel, then
recomputes its stats.
References gmUnitCalculate(), gmUnitGet(), gmUnitLevelUp() and Sint32.
Referenced by dbIncreaseItemAndLevelRaiseMemberLevel(), dbMenuTestRaisePartyLevels(), gmPartyInitCharacters() and scInit().
Definition at line 476 of file game_levels.c.