Alchemy
Loading...
Searching...
No Matches

levels.c File Reference

Actions and Psynergy lists, characters, experience and levelling up. More...

Go to the source code of this file.

Data Structures

struct  LevelUpWork
 Scratch for Owner_LevelUp, in the alternate pool. More...

Macros

#define PSYNERGY_ACTION_AT(slots, index)

Enumerations

enum  { OWNER_ACTION_CLASS = 0x8000 , OWNER_ACTION_ITEM = 0x4000 }
 Marks on an action list entry: learned from the class, or granted by an equipped item. More...

Functions

struct BattleAct * BattleAction_GetDirect (s32 actionId)
 Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.
s32 Unit_KnowsAction (s32 owner, s32 actionId)
 Returns 1 when actionId is in the unit's action list.
s32 Unit_RefreshPsynergy (s32 owner)
 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.
s32 Unit_LearnPsynergy (s32 stateIndex, s32 value)
 Teaches a character action value for good (or makes a class action permanent by clearing its marks), then rebuilds its list.
struct LevelUpResult * Unit_CheckLevelUp (s32 owner, struct LevelUpResult *gains)
 Levels the character up once if it has the experience.
struct CharacterDefinition * Character_GetDefinition (s32 index)
 Returns character index's definition: growth curves, starting level and equipment.
void Party_InitCharacters (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.
UNUSED void Owner_LevelNoOp (void)
 Unused reserved entry; keeps its place in the far-call table.
u32 Unit_GetExperienceForLevel (s32 owner, s32 level)
 Returns the experience a character needs for level (0 for level 0 and below); -1 for an enemy or a level above 99.
struct LevelUpResult * Owner_LevelUp (s32 owner, struct LevelUpResult *gains)
 Raises a character one level (up to 99), adding to each base stat the growth between the two points of its growth curve around the new level (one point every 20 levels), a twentieth of it per level with a random part.
struct LevelUpResult * Unit_TryLevelUp (s32 owner, struct LevelUpResult *gains)
 Levels the character up once if its experience reaches the next level.
void Unit_LevelUpTo (s32 owner, s32 targetLevel)
 Levels character owner up one level at a time until targetLevel, then recomputes its stats.

Detailed Description

Actions and Psynergy lists, characters, experience and levelling up.

Part of game.c, the game object, compiled only through it.

Definition in file levels.c.

Macro Definition Documentation

◆ PSYNERGY_ACTION_AT

#define PSYNERGY_ACTION_AT ( slots,
index )
Value:
(((u16 *)(slots))[(index) * 2])
unsigned short u16
Definition types.h:13

Definition at line 59 of file levels.c.

Referenced by Unit_RefreshPsynergy().

Enumeration Type Documentation

◆ anonymous enum

anonymous enum

Marks on an action list entry: learned from the class, or granted by an equipped item.

Plain entries were taught for good.

Enumerator
OWNER_ACTION_CLASS 
OWNER_ACTION_ITEM 

Definition at line 51 of file levels.c.

Function Documentation

◆ BattleAction_GetDirect()

struct BattleAct * BattleAction_GetDirect ( s32 actionId)

Returns the definition of action actionId (its low 14 bits); an id past the table gives the first.

Reached through GAME.S as BattleActGet, which every bank uses to read an ability.

Definition at line 10 of file levels.c.

Referenced by BattleAction_GetDirect(), and Item_GetTargetMode().

◆ Unit_KnowsAction()

s32 Unit_KnowsAction ( s32 owner,
s32 actionId )

Returns 1 when actionId is in the unit's action list.

Called by the events that check whether a member knows a Psynergy (Event_ValidatePackedId).

Definition at line 29 of file levels.c.

Referenced by Unit_KnowsAction().

◆ Unit_RefreshPsynergy()

s32 Unit_RefreshPsynergy ( s32 owner)

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.

Writes only the unit's actionSlots; enemies (class 0) are left alone. Called whenever the class, level or equipment changes: Inventory_Equip, Unit_UpdateClass, Owner_LevelUp, Unit_LearnPsynergy and the item menu.

Definition at line 68 of file levels.c.

Referenced by Inventory_Equip(), Owner_LevelUp(), Unit_LearnPsynergy(), Unit_RefreshPsynergy(), and Unit_UpdateClass().

◆ Unit_LearnPsynergy()

s32 Unit_LearnPsynergy ( s32 stateIndex,
s32 value )

Teaches a character action value 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. Called by the events that teach Psynergy, the prologue's end, the debug presets and the debug shortcut menu.

Definition at line 188 of file levels.c.

Referenced by Party_EndChildhood(), and Unit_LearnPsynergy().

◆ Unit_CheckLevelUp()

struct LevelUpResult * Unit_CheckLevelUp ( s32 owner,
struct LevelUpResult * gains )

Levels the character up once if it has the experience.

Returns gains filled with the gains, or NULL. Only GAME.S's bare veneer reaches it; nothing calls it by name.

Definition at line 235 of file levels.c.

Referenced by Unit_CheckLevelUp().

◆ Character_GetDefinition()

struct CharacterDefinition * Character_GetDefinition ( s32 index)

Returns character index's definition: growth curves, starting level and equipment.

Definition at line 242 of file levels.c.

Referenced by Character_GetDefinition(), Owner_LevelUp(), Party_InitCharacters(), and Unit_GetElementLevels().

◆ Party_InitCharacters()

void Party_InitCharacters ( 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.

Called by GameState_InitDefaults.

Definition at line 252 of file levels.c.

Referenced by GameState_InitDefaults(), and Party_InitCharacters().

◆ Owner_LevelNoOp()

UNUSED void Owner_LevelNoOp ( void )

Unused reserved entry; keeps its place in the far-call table.

Definition at line 309 of file levels.c.

Referenced by Owner_LevelNoOp().

◆ Unit_GetExperienceForLevel()

u32 Unit_GetExperienceForLevel ( s32 owner,
s32 level )

Returns the experience a character needs for level (0 for level 0 and below); -1 for an enemy or a level above 99.

Called by the levelling code and by the two status screens to show the experience to the next level.

Definition at line 314 of file levels.c.

Referenced by Owner_LevelUp(), Unit_GetExperienceForLevel(), and Unit_TryLevelUp().

◆ Owner_LevelUp()

struct LevelUpResult * Owner_LevelUp ( s32 owner,
struct LevelUpResult * gains )

Raises a character one level (up to 99), adding to each base stat the growth between the two points of its growth curve around the new level (one point every 20 levels), a twentieth of it per level with a random part.

Writes the unit's level, base stats and, if short, its experience, then rebuilds its Psynergy and stats. The gains go to gains, which is returned.

Definition at line 334 of file levels.c.

Referenced by Owner_LevelUp(), Unit_LevelUpTo(), and Unit_TryLevelUp().

◆ Unit_TryLevelUp()

struct LevelUpResult * Unit_TryLevelUp ( s32 owner,
struct LevelUpResult * gains )

Levels the character up once if its experience reaches the next level.

Returns gains filled with the gains, or NULL. Called after a battle by Battle_AwardSpoils, once for each level a member reaches.

Definition at line 414 of file levels.c.

Referenced by Unit_CheckLevelUp(), and Unit_TryLevelUp().

◆ Unit_LevelUpTo()

void Unit_LevelUpTo ( s32 owner,
s32 targetLevel )

Levels character owner up one level at a time until targetLevel, then recomputes its stats.

Called by Party_InitCharacters for the starting levels, and by the debug menus and presets.

Definition at line 429 of file levels.c.

Referenced by CommandTable_ConfigureCommandList(), DebugMenu_RaisePartyLevels(), ItemLevel_AdjustOwnerLevel(), Party_InitCharacters(), and Unit_LevelUpTo().