Skip to Content
The Alchemy Project

src/battle/battle_spoils.c

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

Included by battle.c.

Macros

NameDescription
#defineSPOILS_RANK_CEILING (1 << 30)Above every item's rank: the search for the lowest of the spoils' four starts here.
#definePSYNERGY_FROM_CLASS_SHIFT 15PSYNERGY_ENTRY.encodedAction's top bit: the action comes from the class.

Functions

NameDescription
Uint32btSpoilsRankItem (Uint32 inventoryEntry)Returns an item's rank among the spoils: an indispensable item first, then a rare one, then the higher item id; 0 for none.
voidbtSpoilsClear (void)Empties the battle's spoils (BATTLE_STATE.spoils) and MainRoutineStateWork.pendingItem.
static __inline__ Sint32btEnemyCalculateCoinReward (UNIT *unit, const Uint16 *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__ Sint32btEnemyCalculateExperienceReward (UNIT *unit, const Uint16 *reward)Returns an enemy's experience with the Djinn bonus: its own plus a die for every ten levels, at least 30 percent more.
Sint32btEnemyRecordDefeat (Sint32 unitId, Sint32 djinnBonus)Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils, more with the Djinn bonus.
voidbtAwardSpoils (void)Hands out the spoils after a victory: experience to each party member still standing, with every level gained, then the coins, then the items best first.
voidbtDebugSelectNoOperation (void)Does nothing; the debug battle menu (btDebugBattleRunMenu) calls it.

Description

The spoils: coins, experience, items and level ups. Part of battle.c.

Macros in detail

SPOILS_RANK_CEILING

#define SPOILS_RANK_CEILING (1 << 30)

Above every item's rank: the search for the lowest of the spoils' four starts here.

Referenced by btEnemyRecordDefeat().

Definition at line 29 of file battle_spoils.c.

PSYNERGY_FROM_CLASS_SHIFT

#define PSYNERGY_FROM_CLASS_SHIFT 15

PSYNERGY_ENTRY.encodedAction's top bit: the action comes from the class.

Referenced by btAwardSpoils().

Definition at line 31 of file battle_spoils.c.

Functions in detail

btSpoilsRankItem

Uint32 btSpoilsRankItem(Uint32 inventoryEntry)

Returns an item's rank among the spoils: an indispensable item first, then a rare one, then the higher item id; 0 for none.

References gmItemGetDefinitionStub().

Referenced by btAwardSpoils() and btEnemyRecordDefeat().

Definition at line 7 of file battle_spoils.c.

btSpoilsClear

void btSpoilsClear(void)

Empties the battle's spoils (BATTLE_STATE.spoils) and MainRoutineStateWork.pendingItem.

References MainRoutineStateWork and Sint32.

Referenced by btRun().

Definition at line 35 of file battle_spoils.c.

btEnemyCalculateCoinReward

static __inline__ Sint32 btEnemyCalculateCoinReward(UNIT *unit, const Uint16 *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.

References Sint32.

Referenced by btEnemyRecordDefeat().

Definition at line 53 of file battle_spoils.c.

btEnemyCalculateExperienceReward

static __inline__ Sint32 btEnemyCalculateExperienceReward(UNIT *unit, const Uint16 *reward)

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

References Sint32.

Referenced by btEnemyRecordDefeat().

Definition at line 72 of file battle_spoils.c.

btEnemyRecordDefeat

Sint32 btEnemyRecordDefeat(Sint32 unitId, Sint32 djinnBonus)

Counts a fallen enemy and adds its coins, experience and perhaps its item to the spoils, more with the Djinn bonus. Returns -1 for a party unit, -2 for a party member fought as an enemy, else 0.

References btEnemyCalculateCoinReward(), btEnemyCalculateExperienceReward(), btSpoilsRankItem(), gmBattleRandomStub(), gmEnemyGetDefinitionStub(), gmFlagGetStub(), gmFlagSetStub(), gmUnitGetStub() and Sint32.

Referenced by btPlaybackRun() and btPlaybackRunAll().

Definition at line 92 of file battle_spoils.c.

btAwardSpoils

void btAwardSpoils(void)

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

References btMessageWaitForAdvance(), btSpoilsRankItem(), btUnitListLiving(), gmPartyAdjustCoinsStub(), gmPartyInventoryAddStub(), gmUnitGetStub(), gmUnitTryLevelUpStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentClearAllStub(), mnMessageArgumentPushStub(), OverflowItem, Sint32, syHeapAllocateEWRAM(), syHeapRelease(), sySoundPlayStub() and syWordsCopy().

Referenced by btRun().

Definition at line 179 of file battle_spoils.c.

btDebugSelectNoOperation

void btDebugSelectNoOperation(void)

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

Referenced by btDebugBattleRunMenu().

Definition at line 349 of file battle_spoils.c.