Alchemy
Loading...
Searching...
No Matches

spoils.c File Reference

The spoils: coins, experience, items and level ups. More...

Go to the source code of this file.

Functions

u32 BattleSpoils_RankItem (u32 inventoryEntry)
 Ranks an item among the spoils, 0 for none: an indispensable item first, then a rare item, then the higher item id.
void BattleSpoils_Clear (void)
 Empties the battle's spoils (BattleWork.spoils) and gGameState.pendingItem.
static __inline__ s32 BattleEnemy_CalculateCoinReward (struct BattleUnit *unit, u16 *reward)
 Returns an enemy's coins with the Djinn bonus: its own, plus a six-sided die for every ten levels and one more, at least 30 percent of its own.
static __inline__ s32 BattleEnemy_CalculateExperienceReward (struct BattleUnit *unit, u16 *reward)
 Returns an enemy's experience with the Djinn bonus: its own, plus a four-sided die for every ten levels and one more, at least 30 percent of its own.
s32 BattleEnemy_RecordDefeat (s32 unitId, s32 djinnBonus)
 Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils.
void Battle_AwardSpoils (void)
 Hands out the spoils after a victory: the experience to each party member still standing, with every level gained and what it brings, then the coins, then the items best first.
void Battle_ReservedNoOp2A08 (void)
 Does nothing; the debug battle menu (DebugBattle_RunMenu) calls it.

Detailed Description

The spoils: coins, experience, items and level ups.

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

Definition in file spoils.c.

Function Documentation

◆ BattleSpoils_RankItem()

u32 BattleSpoils_RankItem ( u32 inventoryEntry)

Ranks an item among the spoils, 0 for none: an indispensable item first, then a rare item, then the higher item id.

The rank's bits: 10 ITEM_INDISPENSABLE | 9 ITEM_RARE | 8..0 the item id. Called by BattleEnemy_RecordDefeat, to keep the best four drops, and by Battle_AwardSpoils, to hand them out best first.

Definition at line 12 of file spoils.c.

Referenced by Battle_AwardSpoils(), BattleEnemy_RecordDefeat(), and BattleSpoils_RankItem().

◆ BattleSpoils_Clear()

void BattleSpoils_Clear ( void )

Empties the battle's spoils (BattleWork.spoils) and gGameState.pendingItem.

Called once by Battle_RunEncounter as the battle opens.

Definition at line 33 of file spoils.c.

Referenced by Battle_RunEncounter(), and BattleSpoils_Clear().

◆ BattleEnemy_CalculateCoinReward()

__inline__ s32 BattleEnemy_CalculateCoinReward ( struct BattleUnit * unit,
u16 * reward )
static

Returns an enemy's coins with the Djinn bonus: its own, plus a six-sided die for every ten levels and one more, at least 30 percent of its own.

Used by BattleEnemy_RecordDefeat.

Definition at line 51 of file spoils.c.

Referenced by BattleEnemy_CalculateCoinReward(), and BattleEnemy_RecordDefeat().

◆ BattleEnemy_CalculateExperienceReward()

__inline__ s32 BattleEnemy_CalculateExperienceReward ( struct BattleUnit * unit,
u16 * reward )
static

Returns an enemy's experience with the Djinn bonus: its own, plus a four-sided die for every ten levels and one more, at least 30 percent of its own.

Used by BattleEnemy_RecordDefeat.

Definition at line 73 of file spoils.c.

Referenced by BattleEnemy_CalculateExperienceReward(), and BattleEnemy_RecordDefeat().

◆ BattleEnemy_RecordDefeat()

s32 BattleEnemy_RecordDefeat ( s32 unitId,
s32 djinnBonus )

Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils.

Returns -1 for a party unit and -2 for a party member fought as an enemy, else 0. It notes the class for the victory message (firstDefeated, defeatState). In a monster battle it adds nothing more; otherwise it sets the class's ENEMY_DEFEATED_FLAG, adds the rewards (with the Djinn bonus, djinnBonus nonzero, the rolls above) and rolls the item: 1 in 2^(itemChance - 1), two powers likelier with the bonus. An item not yet among the four kept replaces the lowest ranked, if it ranks higher. Called as each enemy falls by BattleEv_DispatchQueued and BattleEvent_Playback.

Definition at line 99 of file spoils.c.

Referenced by BattleEnemy_RecordDefeat(), BattleEv_DispatchQueued(), and BattleEvent_Playback().

◆ Battle_AwardSpoils()

void Battle_AwardSpoils ( void )

Hands out the spoils after a victory: the experience to each party member still standing, with every level gained and what it brings, then the coins, then the items best first.

Each level up shows its message, every Psynergy newly learned and each stat that rose. An item the inventory cannot take goes to gOverflowItem and ends the handing out. Called by Battle_RunEncounter once the battle is won. Changes the members' experience, levels and stats, the party's coins and inventory.

Definition at line 194 of file spoils.c.

Referenced by Battle_AwardSpoils(), and Battle_RunEncounter().

◆ Battle_ReservedNoOp2A08()

void Battle_ReservedNoOp2A08 ( void )

Does nothing; the debug battle menu (DebugBattle_RunMenu) calls it.

Definition at line 326 of file spoils.c.

Referenced by Battle_ReservedNoOp2A08(), and DebugBattle_RunMenu().