Skip to Content
The Alchemy Project

struct BATTLE_STATE

The battle's own state: its enemies, units and their battle objects, the turn's actions, the spoils, the background palette, the action under way and the playback. More…

Declared in battle_state.h.

Fields

NameDescription
Sint32formationThe encounter's enemy formation.
Sint16spriteSlots [ENEMY_SPRITE_SLOTS]The unit in each enemy sprite slot, 0 when free.
Uint16enemyKinds [6]The enemies met so far, for their name letters, and the first enemy to fall (firstDefeated).
Uint32nameLetterMasks [6]Name letters in use by each enemy in enemyKinds, a bit per letter.
Sint8lastNameLetter [6]The letter each enemy in enemyKinds gave out last; -1 for none yet.
Uint8unusedAfterNameLetters [2]No code names it.
Uint16firstDefeatedThe enemyKinds index of the first enemy to fall; 6 for none.
Uint16defeatStateDEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER.
Uint8enemyKindCountEnemies listed in enemyKinds, at most 5.
Uint8partyStatusPARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS; the staging draws it less PARTY_STATUS_SHOW_PP, names and HP only.
Uint8layoutThe formation's FORMATION_LAYOUT_; SHUFFLED in a link battle.
Uint8challengeFlagBATTLE_CHALLENGED_PARTY once a party member was challenged; while nonzero, the party cannot run.
Uint8isLink1 in a link battle.
Uint8firstStrikeBATTLE_FIRST_STRIKE: who strikes first.
Uint8fleeFailuresFailed attempts to run; each adds 2000 to the base chance of 5000.
Uint8unusedAfterFleeFailuresNo code names it.
Uint8opponentSlots [8]For each party unit, its slot as a link opponent's enemy, minus FIRST_ENEMY_UNIT; 0xff for none.
Uint8linkSideThis console's multiplayer id.
Uint8linkMissesTicks the link has been down.
Uint8linkPausedSet when the link drops or the console's id changes.
Uint8paddingAfterLinkUp to the word arrowTiles starts on.
Sint32arrowTilesResource entry of the advance arrow's tiles; -1 for none.
Sint16partyUnits [7]Ends with BATTLE_UNIT_LIST_END.
Sint16enemyIds [ENEMY_BATTLE_SIZE + 1]Ends with BATTLE_UNIT_LIST_END.
BATTLE_OBJECTobjects [UNIT_MAX]The units' battle objects, reached through placement (btObjectGet).
Uint8objectIndex [UNIT_MAX]Each unit's index in slots, indexed by party unit id (0 to 7), or 8 + n for enemy unit FIRST_ENEMY_UNIT + n: a party unit's place in the active party, an enemy's own 8 + n; 0xff for a party unit with no battle object.
Uint8unusedAfterPlacement [2]No code names it.
BATTLE_ACTIONactions [BATTLE_ACTION_CAPACITY]The actions chosen for the turn.
Uint8unusedAfterActions [260]No code names it.
BATTLE_SPOILSspoilsWhat the defeated enemies leave; spoils.defeated, their count, is also what btRun returns after a win or a broken link.
Uint16palette [BATTLE_BACKGROUND_COLORS]The battle background's colours, before scaling.
FIXEDbrightnessThe battle background's brightness, 16.16, toFIXED(1) full.
Uint16bgThe battle background's id.
Uint8unusedAfterBg [4]No code names it.
Uint16highlightStepIndex into
Uint16highlightModeBattleHighlightBlendRamp.
Uint8paddingAfterHighlight [2]Up to the word actionRun starts on.
BATTLE_ACTION_RUNactionRunThe action being carried out,
BATTLE_PLAYBACK_STATEplaybackas btActionRunBuild lays it out.
Sint32debugValueA value btAdjustDebugValue edits with the d-pad while Start is held.

Description

The battle's own state: its enemies, units and their battle objects, the turn's actions, the spoils, the background palette, the action under way and the playback.

It lives in the HEAP_SLOT_BATTLE heap slot: btRun takes and zeroes it, sets arrowTiles to -1 and formation, and the next scene change clears the heap. Every battle part reads it through BattleStateWork, and the battle effects read its background id and palette.

struct BATTLE_STATE

Referenced by btAbilityApplyToTarget(), btActionRunBuild(), btAdjustDebugValue(), btAIChooseTarget(), btAppendLinkedActions(), btBackgroundLoad(), btBackgroundSetPaletteLevel(), btBackgroundStepHighlightBlend(), btBuildEnemyActions(), btCameraUpdate(), btEffectDarkenBackgroundStep(), btEffectEndCanvasLayer(), btEffectHideBg1AndRestoreBackdrop(), btEffectOpenCanvasLayer(), btEffectRunCriticalHit(), btEffectRunShatteringOpening(), btEffectSetupBlendedDisplay(), btEffectSetupCanvasTileMap(), btEffectStartCanvasLayer(), btElementGlowPlay(), btEnemyClaimNameLetter(), btEnemyHasSpriteRoom(), btEnemyRecordDefeat(), btEnemyReleaseNameLetter(), btEnemySpriteLoadIntoSlots(), btFindUnitPlace(), btFleeCheckSuccess(), btFormationBuildEnemyList(), btGatherActions(), btGetUnitAtPlace(), btHighlightSetModes(), btIntroAnnounceEncounter(), btLinkBattleSendParty(), btLinkBattleSyncTurn(), btLinkBattleWaitSync(), btObjectGet(), btObjectGetAnchor(), btObjectReleaseSpriteSlots(), btObjectRemoveFromLists(), btPartyAssignOpponentSlots(), btPlacementRelayoutEnemies(), btPlaybackRun(), btProcessTurnEnd(), btRun(), btSpoilsClear(), btStagingDispatchAction(), btStagingRunFlee(), btStagingRunItem(), btTransitionRun(), btUnitCollect() and 9 more.

Definition at line 126 of file battle_state.h.

Fields in detail

formation

Sint32 formation

The encounter's enemy formation.

spriteSlots

Sint16 spriteSlots[ENEMY_SPRITE_SLOTS]

The unit in each enemy sprite slot, 0 when free.

enemyKinds

Uint16 enemyKinds[6]

The enemies met so far, for their name letters, and the first enemy to fall (firstDefeated).

nameLetterMasks

Uint32 nameLetterMasks[6]

Name letters in use by each enemy in enemyKinds, a bit per letter.

lastNameLetter

Sint8 lastNameLetter[6]

The letter each enemy in enemyKinds gave out last; -1 for none yet.

unusedAfterNameLetters

Uint8 unusedAfterNameLetters[2]

No code names it.

firstDefeated

Uint16 firstDefeated

The enemyKinds index of the first enemy to fall; 6 for none.

defeatState

Uint16 defeatState

DEFEAT_ONE, DEFEAT_SEVERAL or DEFEAT_BY_PARTY_MEMBER.

enemyKindCount

Uint8 enemyKindCount

Enemies listed in enemyKinds, at most 5.

partyStatus

Uint8 partyStatus

PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS; the staging draws it less PARTY_STATUS_SHOW_PP, names and HP only.

layout

Uint8 layout

The formation's FORMATION_LAYOUT_; SHUFFLED in a link battle.

challengeFlag

Uint8 challengeFlag

BATTLE_CHALLENGED_PARTY once a party member was challenged; while nonzero, the party cannot run.

Uint8 isLink

1 in a link battle.

firstStrike

Uint8 firstStrike

BATTLE_FIRST_STRIKE: who strikes first.

fleeFailures

Uint8 fleeFailures

Failed attempts to run; each adds 2000 to the base chance of 5000.

unusedAfterFleeFailures

Uint8 unusedAfterFleeFailures

No code names it.

opponentSlots

Uint8 opponentSlots[8]

For each party unit, its slot as a link opponent's enemy, minus FIRST_ENEMY_UNIT; 0xff for none.

linkSide

Uint8 linkSide

This console's multiplayer id.

linkMisses

Uint8 linkMisses

Ticks the link has been down.

linkPaused

Uint8 linkPaused

Set when the link drops or the console's id changes.

Uint8 paddingAfterLink

Up to the word arrowTiles starts on.

arrowTiles

Sint32 arrowTiles

Resource entry of the advance arrow's tiles; -1 for none.

partyUnits

Sint16 partyUnits[7]

Ends with BATTLE_UNIT_LIST_END.

enemyIds

Sint16 enemyIds[ENEMY_BATTLE_SIZE + 1]

Ends with BATTLE_UNIT_LIST_END.

objects

BATTLE_OBJECT objects[UNIT_MAX]

The units' battle objects, reached through placement (btObjectGet).

objectIndex

Uint8 objectIndex[UNIT_MAX]

Each unit's index in slots, indexed by party unit id (0 to 7), or 8 + n for enemy unit FIRST_ENEMY_UNIT

  • n: a party unit's place in the active party, an enemy's own 8 + n; 0xff for a party unit with no battle object.

unusedAfterPlacement

Uint8 unusedAfterPlacement[2]

No code names it.

actions

BATTLE_ACTION actions[BATTLE_ACTION_CAPACITY]

The actions chosen for the turn.

unusedAfterActions

Uint8 unusedAfterActions[260]

No code names it.

spoils

BATTLE_SPOILS spoils

What the defeated enemies leave; spoils.defeated, their count, is also what btRun returns after a win or a broken link.

palette

Uint16 palette[BATTLE_BACKGROUND_COLORS]

The battle background's colours, before scaling.

brightness

FIXED brightness

The battle background's brightness, 16.16, toFIXED(1) full.

bg

Uint16 bg

The battle background's id.

unusedAfterBg

Uint8 unusedAfterBg[4]

No code names it.

highlightStep

Uint16 highlightStep

Index into

highlightMode

Uint16 highlightMode

BattleHighlightBlendRamp.

Nonzero while the units are highlighted.

paddingAfterHighlight

Uint8 paddingAfterHighlight[2]

Up to the word actionRun starts on.

actionRun

BATTLE_ACTION_RUN actionRun

The action being carried out,

playback

BATTLE_PLAYBACK_STATE playback

as btActionRunBuild lays it out.

debugValue

Sint32 debugValue

A value btAdjustDebugValue edits with the d-pad while Start is held.