Skip to Content
The Alchemy Project

struct UNIT

A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and statuses.

Declared in battle_unit.h.

Fields

NameDescription
Uint8name [UNIT_NAME_SIZE]One byte a character, ending in 0.
Uint8level1 to 99 for a character.
Sint16baseHpThe base stats, from here to baseElement:
Sint16basePpthe unit's own, before its equipment, Djinn, class and battle stages, which gmUnitCalculate adds to make the stats in play below.
Sint16hpGaugehp / hpMax in 0..UNIT_GAUGE_FULL; 1 while any HP remains
Sint16ppGaugepp / ppMax in 0..UNIT_GAUGE_FULL; 1 while any PP remains
Uint16baseAttack
Uint16baseDefense
Uint16baseAgility
Uint8baseLuck
Uint8baseActionCountActions a turn.
Uint8baseHpRegenHP and PP regained at
Uint8basePpRegeneach turn's end.
Uint8baseUnused [2]No code names it.
BATTLE_ELEMENT_STATSbaseElement [ELEMENT_COUNT]Power and resistance: an enemy's from its element preset, a character's from its element levels (gmUnitCalculateBaseElements).
Sint16hpMaxThe stats in play (gmUnitCalculate), with the HP and PP the unit has left; hp is 0 when it is downed.
Sint16ppMax
Sint16hp
Sint16pp
Uint16attack
Uint16defense
Uint16agility
Uint8luck
Uint8actionsPerTurn
Uint8hpRegen
Uint8ppRegen
Uint8unused [2]No code names it, as baseUnused.
BATTLE_ELEMENT_STATSelement [ELEMENT_COUNT]Power and resistance in each element after equipment, element levels and Resistance stages (gmUnitCalculate).
PSYNERGY_ENTRYpsynergy [PSYNERGY_SLOTS]The action list: Psynergy taught for good, then the class's and the equipment's.
Uint16inventory [INVENTORY_SLOTS]Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*).
Uint8paddingBeforeDjinn [2]Up to the word djinnHeld starts on.
Uint32djinnHeld [ELEMENT_COUNT]The Djinn held, one bit per Djinni (by its index) in each element's word.
Uint32djinnSet [ELEMENT_COUNT]The Djinn set, one bit per Djinni.
Uint8djinnHeldCounts [ELEMENT_COUNT]The Djinn held in each element.
Uint8djinnSetCounts [ELEMENT_COUNT]The Djinn set in each element.
BATTLE_AI_STATEaiStateCleared when an enemy is set up.
Uint32experienceA character's experience points.
Uint8idA character's id (ISAAC to PIERS, below 8), written at a new game: the equipment masks and the battle presentation read it.
Uint8classIdThe character's class, worked out from its Djinn (gmUnitUpdateClass); CLASS_NONE marks an enemy, and code throughout tests it to tell the two apart.
Uint8sideA BATTLE_SIDE.
Uint8defendLevel0 to 4: each guard effect raises it to its own level and no lower; Defend's is 1.
Sint8summonBoost [ELEMENT_COUNT]A summon's boost to the user's power in each element: how many of the element's Djinn its summons have used, four at most (btUnitProcessActionEnd).
Sint8curseThe curse: nonzero shows it in the menus and lets the sanctum remove it.
Sint8poison1 poisoned, 2 deadly poison.
Uint8attackTurnsEach stat change: the turns it has left, and its stage.
Sint8attackStage
Uint8defenseTurns
Sint8defenseStage
Uint8resistanceTurns
Sint8resistanceStage
Uint8delusionDelusion to sleep: the turns each status has left, 7 when it lands.
Sint8confusion
Uint8charm
Uint8stun
Uint8sleep
Uint8psySealPsynergy is sealed while any bit is set: Luff's seal above PSY_SEAL_BIND_MASK, Bind's turns within it.
Uint8regenerateHP regeneration's turns left, 5 when cast.
Sint8reflectReflect's turns left, 7 when cast.
Uint8hauntSet while an evil spirit grips the unit.
Uint8grimReaperThe Grim Reaper's countdown, 7 when cursed.
Uint8equipBonus [2][0] the EQUIP_EFFECT_ADD_UNLEASH_CHANCE total gmUnitCalculate sums, which nothing reads (gmEquipmentGetUnleashRateBonus sums it afresh); [1] set by ABILITY_EFFECT_COUNTER while the unit is ready to counterattack, for the rest of the turn.
Uint8readyThe extra action: 2 when cast, down one at each turn's end.
Uint8immobileSet by ABILITY_EFFECT_GROUND.
Uint8agilityTurnsThe Agility change's turns left, 5 when cast.
Sint8agilityStageThe Agility stage, -4 to 8 (twice the Agility).
Sint8challengeSet by ABILITY_EFFECT_CHALLENGE, which no ability has: the unit will not flee.
Uint8paddingBeforeEnemyIdUp to the halfword enemyId starts on.
Uint16enemyIdWho the unit is: an enemy's id (gmBattleUnitSet), or a character's id (copied from id at a new game) for gmUnitUpdateClass and the experience table.

Description

A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and statuses.

struct UNIT

Referenced by btAbilityApplyToTarget(), btActionRunBuild(), btAIChooseAction(), btAIChooseTarget(), btAutoBattleApplyDamage(), btAutoBattleBuildActions(), btAutoBattleRunAction(), btAutoBattleShowDefend(), btAwardSpoils(), btBuildEnemyActions(), btDebugParamSetLoad(), btEffectRunAttackSlash(), btEffectRunTwistingColumn(), btEnemyAdjustLevel(), btEnemyCalculateCoinReward(), btEnemyCalculateExperienceReward(), btEnemyLetterFirstOfKind(), btEnemyRecordDefeat(), btEnemyReleaseNameLetter(), btEnemySpriteLoadIntoSlots(), btFormationBuildEnemyList(), btGatherActions(), btLinkBattleReceiveParty(), btLinkBattleSendParty(), btMotionShowDowned(), btObjectMake(), btObjectUpdatePose(), btPartyClearBattleStatuses(), btPartyClearGuards(), btPlacementLayoutEnemies(), btPlaybackRun(), btProcessTurnEnd(), btScriptedBattleRestoreUnits(), btScriptedBattleSaveUnits(), btStagingDispatchAction(), btStagingRunAttack(), btStagingRunFlee(), btStagingRunItem(), btSummonUpdateAvailability(), btUnitBuildStatusFlags(), btUnitClearStatuses(), btUnitCountDownAgilityStage(), btUnitCountDownAttackStage(), btUnitCountDownCharm(), btUnitCountDownConfusion(), btUnitCountDownDefenseStage(), btUnitCountDownDelusion(), btUnitCountDownPsynergySeal(), btUnitCountDownRegenerate(), btUnitCountDownResistanceStage() and 146 more.

Definition at line 358 of file battle_unit.h.

Fields in detail

name

Uint8 name[UNIT_NAME_SIZE]

One byte a character, ending in 0.

level

Uint8 level

1 to 99 for a character.

baseHp

Sint16 baseHp

The base stats, from here to baseElement:

basePp

Sint16 basePp

the unit's own, before its equipment, Djinn, class and battle stages, which gmUnitCalculate adds to make the stats in play below.

hpGauge

Sint16 hpGauge

hp / hpMax in 0..UNIT_GAUGE_FULL; 1 while any HP remains

ppGauge

Sint16 ppGauge

pp / ppMax in 0..UNIT_GAUGE_FULL; 1 while any PP remains

baseAttack

Uint16 baseAttack

baseDefense

Uint16 baseDefense

baseAgility

Uint16 baseAgility

baseLuck

Uint8 baseLuck

baseActionCount

Uint8 baseActionCount

Actions a turn.

baseHpRegen

Uint8 baseHpRegen

HP and PP regained at

basePpRegen

Uint8 basePpRegen

each turn's end.

baseUnused

Uint8 baseUnused[2]

No code names it.

baseElement

BATTLE_ELEMENT_STATS baseElement[ELEMENT_COUNT]

Power and resistance: an enemy's from its element preset, a character's from its element levels (gmUnitCalculateBaseElements).

hpMax

Sint16 hpMax

The stats in play (gmUnitCalculate), with the HP and PP the unit has left; hp is 0 when it is downed.

ppMax

Sint16 ppMax

hp

Sint16 hp

pp

Sint16 pp

attack

Uint16 attack

defense

Uint16 defense

agility

Uint16 agility

luck

Uint8 luck

actionsPerTurn

Uint8 actionsPerTurn

hpRegen

Uint8 hpRegen

ppRegen

Uint8 ppRegen

unused

Uint8 unused[2]

No code names it, as baseUnused.

element

BATTLE_ELEMENT_STATS element[ELEMENT_COUNT]

Power and resistance in each element after equipment, element levels and Resistance stages (gmUnitCalculate).

psynergy

PSYNERGY_ENTRY psynergy[PSYNERGY_SLOTS]

The action list: Psynergy taught for good, then the class's and the equipment's. An empty entry is 0.

inventory

Uint16 inventory[INVENTORY_SLOTS]

Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*). An empty entry is 0.

paddingBeforeDjinn

Uint8 paddingBeforeDjinn[2]

Up to the word djinnHeld starts on.

djinnHeld

Uint32 djinnHeld[ELEMENT_COUNT]

The Djinn held, one bit per Djinni (by its index) in each element's word.

djinnSet

Uint32 djinnSet[ELEMENT_COUNT]

The Djinn set, one bit per Djinni.

djinnHeldCounts

Uint8 djinnHeldCounts[ELEMENT_COUNT]

The Djinn held in each element.

djinnSetCounts

Uint8 djinnSetCounts[ELEMENT_COUNT]

The Djinn set in each element.

aiState

BATTLE_AI_STATE aiState

Cleared when an enemy is set up. During a battle the enemy's action choice keeps its place in its action list here (btAIChooseAction).

experience

Uint32 experience

A character's experience points.

id

Uint8 id

A character's id (ISAAC to PIERS, below 8), written at a new game: the equipment masks and the battle presentation read it. Who any unit is, character or enemy, is enemyId.

classId

Uint8 classId

The character's class, worked out from its Djinn (gmUnitUpdateClass); CLASS_NONE marks an enemy, and code throughout tests it to tell the two apart.

side

Uint8 side

A BATTLE_SIDE. gmBattleUnitSet puts the Djinn the party fights (enemies 9 to 66 and 369 to 377) on the party's side.

defendLevel

Uint8 defendLevel

0 to 4: each guard effect raises it to its own level and no lower; Defend's is 1.

summonBoost

Sint8 summonBoost[ELEMENT_COUNT]

A summon's boost to the user's power in each element: how many of the element's Djinn its summons have used, four at most (btUnitProcessActionEnd). Break and the battle's end clear it.

curse

Sint8 curse

The curse: nonzero shows it in the menus and lets the sanctum remove it.

poison

Sint8 poison

1 poisoned, 2 deadly poison.

attackTurns

Uint8 attackTurns

Each stat change: the turns it has left, and its stage. Stages run -4 to 4 and last 7 turns.

attackStage

Sint8 attackStage

defenseTurns

Uint8 defenseTurns

defenseStage

Sint8 defenseStage

resistanceTurns

Uint8 resistanceTurns

resistanceStage

Sint8 resistanceStage

delusion

Uint8 delusion

Delusion to sleep: the turns each status has left, 7 when it lands.

confusion

Sint8 confusion

charm

Uint8 charm

stun

Uint8 stun

sleep

Uint8 sleep

psySeal

Uint8 psySeal

Psynergy is sealed while any bit is set: Luff's seal above PSY_SEAL_BIND_MASK, Bind's turns within it.

regenerate

Uint8 regenerate

HP regeneration's turns left, 5 when cast.

reflect

Sint8 reflect

Reflect's turns left, 7 when cast.

haunt

Uint8 haunt

Set while an evil spirit grips the unit.

grimReaper

Uint8 grimReaper

The Grim Reaper's countdown, 7 when cursed.

equipBonus

Uint8 equipBonus[2]

[0] the EQUIP_EFFECT_ADD_UNLEASH_CHANCE total gmUnitCalculate sums, which nothing reads (gmEquipmentGetUnleashRateBonus sums it afresh); [1] set by ABILITY_EFFECT_COUNTER while the unit is ready to counterattack, for the rest of the turn.

ready

Uint8 ready

The extra action: 2 when cast, down one at each turn's end.

immobile

Uint8 immobile

Set by ABILITY_EFFECT_GROUND.

agilityTurns

Uint8 agilityTurns

The Agility change's turns left, 5 when cast.

agilityStage

Sint8 agilityStage

The Agility stage, -4 to 8 (twice the Agility).

challenge

Sint8 challenge

Set by ABILITY_EFFECT_CHALLENGE, which no ability has: the unit will not flee.

paddingBeforeEnemyId

Uint8 paddingBeforeEnemyId

Up to the halfword enemyId starts on.

enemyId

Uint16 enemyId

Who the unit is: an enemy's id (gmBattleUnitSet), or a character's id (copied from id at a new game) for gmUnitUpdateClass and the experience table.