Alchemy

battle

games/tbs/include/battle on GitHub

b5_context.h

games/tbs/include/battle/b5_context.h

Structures

B5Context

struct B5Context

The object context a battle routine reads; most of its fields are still unnamed.

FieldDeclared as
objectvoid *object
padding04u8 padding04[8]
word0cs32 word0c
word10s32 word10
padding14u8 padding14[0x0c]
excluded20void *excluded20
excluded24void *excluded24
padding28u8 padding28[2]
suppressUpdatess16 suppressUpdates

Line 14

battle.h

games/tbs/include/battle/battle.h

Structures

CameraWork

struct CameraWork

The battle camera (struct BattleCamera) as the effects that swing it see it.

FieldDeclared as
unk00u8 unk00[0x36]BattleCamera's eye to pitch; not named in this view
scrollu16 scrollthe camera's yaw, in 1/65536 turns

Used by BattleFx_RunPlasma, BattleFx_RunSparkGroups.

Line 68

EffectVector

struct EffectVector

A world position, as Camera_WorldToScreen converts it to the screen.

FieldDeclared as
xs32 x16.16 fixed-point pixels
ys32 y16.16 fixed-point pixels
zs32 z16.16 fixed-point pixels

Used by AltmillerCave_ReleaseWallBurst, BattleEffect_RunFallbackObjectTransition, BattleEffect_UpdatePhasedRadialParticle, BattleFx_CheckRaisedTargetCollision, BattleFx_GetPositionAboveActor, BattleFx_RunAngledApproachPhases, BattleFx_RunMercuryDjinnCapture, BattleFx_RunVenusDjinnCapture, BattleFx_SpawnFallingParticles, BattleFx_SteerLiftedTarget, BattleFx_SteerPushedTarget, BattleFx_UpdateDescendingOrbitObject, BattleFx_UpdateItemBreakFragment, BattleFx_UpdateOrbitAndReturn, BattleFx_UpdateRadialBurst, BattleFx_UpdateRadialCamera, BattleFx_UpdateRadialLaunch, BattleFx_UpdateRadialSpread, BattleFx_UpdateRandomTargetParticle, BattleFx_UpdateShrinkingOrbitObject, Djinn_RunJupiterJoinEffect, Djinn_RunMarsJoinEffect, FieldFx_RunDouse, FieldFx_RunForce, FieldFx_RunFrost, FieldFx_RunRetreat, FieldFx_RunWhirlwind, FieldFx_UpdateMindReadWave, FieldFx_UpdateSpiralParticle, Marker_MoveLeaderAway, SpawnHeavyImpactEffect.

Line 73

Ring

struct Ring

One of the star field's three rings, moving outward on the effect canvas.

FieldDeclared as
xs32 x1/1024 canvas pixels
ys32 y1/1024 canvas pixels
velXs32 velX1/1024 canvas pixels per frame
velYs32 velY1/1024 canvas pixels per frame
ages32 ageframes

Line 79

ScatterPosition

struct ScatterPosition

The position an item-break effect spawns its objects and shards from.

FieldDeclared as
xs32 x16.16 fixed-point pixels
ys32 y16.16 fixed-point pixels
zs32 z16.16 fixed-point pixels

Line 87

Enumerations

BattlePose

enum BattlePose

The battle sprites' animations (AnimationObjects_SelectAnimation numbers) that the battle code picks by name.

Value=
POSE_ENEMY_HELD0an enemy asleep, stunned or held
POSE_STANDING1
POSE_PARTY_HELD4asleep, stunned or held; also a downed member
POSE_DAMAGE5taking damage
POSE_ENEMY_DOWN5a downed enemy stays in its damage pose

Line 172

Macros, without a comment: BATTLE_H.

Globals, without a comment: gBattleFx_CyclePatternWords, gBattleFx_RandomChildValues, gBattlePlacement_StepPairs, gPlayerObjectId, gResource_SlotAssignments, gAnimation_ChildPaletteCycle, gBattleCommand_SelectionWeights, gBattleFx_ArcSparkTiles, gBattleFx_BurstParticleObjectScript, gBattleFx_DefinitionTable, gBattleFx_LinkedObjectScript, gBattleFx_MarkerParticleScript, gBattleFx_ParticleEmitterScript, gBattleFx_ParticleScript, gBattleFx_PulseScales, gBattleFx_SourceHoldScript, gBattleFx_TargetRangeByMode, gBattleFx_UntargetedObjectScript, gBattleMotion_VariantAcceleration, gBattleMotion_VariantDistancePercent, gBattleMotion_VariantSpeedLimit, gBattleMotion_VariantVelocityY, gBattleParty_CenterOrderOffsets, gBattleParty_RoundEndGroupOrder, gBattlePres_ActorObjectScript, gBattlePres_AdvanceArrowTiles, gBattlePres_CurtainTiles, gBattlePres_TileVariants, gBattleUnit_WeaponAnimsClass1, gBattleUnit_WeaponAnimsClass2, gBattleUnit_WeaponAnimsClass3, gBattleUnit_WeaponAnimsClass5, BitDecoder_Size, gCamera_FlagTransformWork, gBattleFx_SparkTiles, gBattleFx_QuadrantModes, gBattleFx_TargetColors, gBattleFx_StarWorkOffsets, gBattleFx_StarSizes, gBattleFx_RingFrameOffsets, gBattleFx_HighlightBlendRamp, gEncounter_EnemyGroupTable, gFieldFx_GroundParticleFrames, gFieldFx_GroundParticleTiles, gBattleBgFxWork, gBattleFxWork, gBattleOwnerStates, gRandomSeed, gTransitionWork, gObjectMotion_LinkedActionScript, gParty_PairResolveRules, gBattleFx_RisingPulseScript, gBattleUnit_WeaponAnimsClass0, gBattleFormation_LevelMatchedEnemies, gBattle_BackdropScenes, BattleFx_Composite, gUi_RenderResultValues, gWorldMap_CursorDirectionAngles, gWorldMap_MarkerBlendCycle, gWorldMap_PlaceMarkers.

Declarations, without a comment: __udivsi3, _call_via_r0, Animation_ApplyChildArgumentFar, BitDecoder_DecodeImage, FarCall_WindowTable, GetBattleEffectObject, ItemIcon_LoadTilesFar, Object_InitializeMode.

battle_calc.h

games/tbs/include/battle/battle_calc.h

Globals, without a comment: gHitTable, gPpLossTable, gHpRecoveryTable, gPpDmgTable, gHpDmgTable5, gHpDmgTable8, gHpDmgTable6, gPpRecoveryTable, gHpDmgTable.

battle_display.h

games/tbs/include/battle/battle_display.h

Structures

BattleCamera

struct BattleCamera

The battle camera: its eye, the focus it turns about, and its pitch, yaw and distance. It lives in the HEAP_SLOT_CAMERA work slot.

FieldDeclared as
eyes32 eye[3]The eye, 16.16 fixed-point pixels: written each frame distance behind the focus along the turned view.
poss32 pos[3]the focus, 16.16 fixed-point pixels
unk18s32 unk18cleared beside followPos; not read by name in TBS
followPoss32 *followPoswhen set, the focus followed instead of pos
distances32 distanceeye to focus, 16.16 fixed-point pixels
unk24u8 unk24[16]not named by TBS code
pitchu16 pitch1/65536 turns
yawu16 yaw1/65536 turns
unk38u8 unk38[20]not named by TBS code

Used by BattleCamera_SetRange, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunCastingImpact, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFroth, BattleFx_RunGatheringLights, BattleFx_RunGround, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunJudgment, BattleFx_RunLobbedShells, BattleFx_RunMoteFountain, BattleFx_RunOrbitingSkulls, BattleFx_RunOrbitingSpirals, BattleFx_RunPaletteParticles, BattleFx_RunParticleStreams, BattleFx_RunPlanetDiver, BattleFx_RunPrism, BattleFx_RunProcne, BattleFx_RunProjectileVolley, BattleFx_RunQuake, BattleFx_RunRingAndSparkScene, BattleFx_RunRushingStrike, BattleFx_RunShiningStar, BattleFx_RunSleep, BattleFx_RunStatBoost and 20 more.

Line 18

BattlePresentationTransition

struct BattlePresentationTransition

The battle background's work slot as the camera reads it: the yaw the camera eases toward and the frames left to ease it.

FieldDeclared as
targetYaws32 targetYaw1/65536 turns
framess32 framesframes left to ease the yaw, a sixteenth a frame
unk08u8 unk08[8]BattleBackgroundView's mode and secondMode
actives32 activeBattleBackgroundView's busy, at the same offset
flags32 flag0 lets the camera update set the background's range each frame; 1 for a critical hit's zoom and once a round's view is set.
unk18s32 unk18cleared when the battle starts; not read by name in TBS
unk1cs32 unk1ccleared when the battle starts; not read by name in TBS

Used by BattleFx_RunJudgment, BattleFx_RunParticleStreams, BattlePres_RunAction, BattlePres_RunAttack, BattlePres_RunEscape, BattlePres_RunItem, BattlePres_RunPlainAttack, BattlePres_RunPsynergyCast, BattlePres_RunUnitAction, BattlePresentation_DispatchAction, BattlePresentation_RunPairedUnitTransition, BattlePresentation_RunUnitTransition, BattlePresentation_UpdateCamera, Battle_RunEncounter, Camera_ConfigureScene, gTransitionWork.

Line 42

BattlePresentationWork

struct BattlePresentationWork

The effect updates its command while the presentation keeps animation state.

FieldDeclared as
effectstruct BattleEffectArgument effect
savedAnimationParametersu8 savedAnimationParameters[8][4]Each target's animation entries' param, saved before the effect.

Used by BattlePres_RunApproachAction, BattlePres_RunAttack, BattlePres_RunEntryTransition, BattlePres_RunItem, BattlePres_RunPlainAttack, BattlePres_RunPsynergyCast, BattlePres_RunUnitAction, BattlePresentation_RunPairedUnitTransition, BattlePresentation_RunUnitTransition, offsetof.

Line 55

BattleBackgroundView

struct BattleBackgroundView

The battle background's work slot as the background code reads it: its display mode (2 draws it as an affine perspective plane).

FieldDeclared as
unk00u8 unk00[8]BattlePresentationTransition's targetYaw and frames
modes32 mode2 draws the affine plane; 1 sets BG1's scroll too
secondModes32 secondMode1 also sets BG1's scroll; one effect sets it
busys32 busywhile set, BattleCamera_SetRange leaves BG1's scroll

Used by BattleBackground_Load, BattleCamera_SetRange, BattleFx_BeginCanvasLayer, BattleFx_HideBg1AndRestoreBackdrop, BattleFx_OpenCanvasLayer, BattleFx_RunAtalanta, BattleFx_RunKirin, BattleFx_RunNeptune, BattleFx_RunShatteringOpening, BattleFx_RunThor, BattleFx_SetupCanvasTileMap, BattlePres_RunEntryTransition, BattlePres_UpdateHBlankScroll, BattlePresentation_ConfigurePaletteFade, BattlePresentation_InitializeWorkAndResetState.

Line 68

BattleAffine

struct BattleAffine

The battle background's affine parameters and reference point, copied whole to the BG2PA registers.

FieldDeclared as
pa, pb, pc, pdu16 pa, pb, pc, pd
x, ys32 x, y

Used by BattleCamera_SetRange.

Line 77

BattleAffineHdma

struct BattleAffineHdma

The battle background's scanline work in heap slot 10: two pages of per-line BG2CNT values, swapped each frame, and the affine parameters.

FieldDeclared as
pageu32 pagethe page of lines shown; the other one is built
unk04u8 unk04[12]not named by TBS code
affinestruct BattleAffine affine
linesu16 lines[2][160]

Used by BattleCamera_SetRange, BattlePres_UpdateHBlankScroll, BattlePresentation_InitializeWorkAndResetState.

Line 84

Globals, without a comment: gCameraWork, offsetof.

battle_effect.h

games/tbs/include/battle/battle_effect.h

Types, without a comment: BattleEffectDrawRectangle, DrawRectangle, DrawRectangleFn.

battle_effect_argument.h

games/tbs/include/battle/battle_effect_argument.h

Structures

BattleEffectArgument

struct BattleEffectArgument

The command shared by an effect's caller, dispatcher and handlers.

FieldDeclared as
kinds32 kindhandler table index; 200 more for a critical hit
sides32 side1 when the targets are the party, 0 for enemies
actors32 actorthe user's unit id
firstTargets32 firstTargetthe action's first target, standing or not
ranges32 rangeforwarded action range, otherwise initialized to 1
counts32 counttargets in actors, at least 1
variants32 variantthe ability's size, from 0 (Quake, then Earthquake)
preludes32 prelude1 plays a prelude: in some effects a Djinni appears
unk0020s32 unk0020not named by TBS code
actorss16 actors[8]the targets' unit ids, count of them

Used by BattleFx_DispatchByIdRange, BattleFx_ProbeKeysForExtendedActor, BattleFx_RunAcidBite, BattleFx_RunAcidBlessing, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBacteriaRush, BattleFx_RunBansheeHowl, BattleFx_RunBeamSequence, BattleFx_RunBearClaw, BattleFx_RunBerserk, BattleFx_RunBind, BattleFx_RunBladeRain, BattleFx_RunBlast, BattleFx_RunBlizzard, BattleFx_RunBolt, BattleFx_RunBoneCharge, BattleFx_RunBoneChiller, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunBruteForce, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCannibalFang, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunCrazyVoice, BattleFx_RunCure, BattleFx_RunCurePoison, BattleFx_RunCuttingEdge, BattleFx_RunCybele, BattleFx_RunDarkBlessing, BattleFx_RunDeadlyGas, BattleFx_RunDeathPlunge, BattleFx_RunDecompose, BattleFx_RunDelude, BattleFx_RunDemonFire, BattleFx_RunDemonNight, BattleFx_RunDew and 158 more.

Line 12

Macros

DEFINE_EFFECT_KIND

#define DEFINE_EFFECT_KIND(name, runner, arg)

Defines the battle effect kind name as a call of a shared runner with one fixed argument, its style or variant. The strike, volley, shower, mote and stat-change families each have one runner and a kind like this for each ability that uses it.

Line 33

EFFECT_FOR_EACH_TARGET

#define EFFECT_FOR_EACH_TARGET(i, effect)

Loops i over the effect's targets, effect->actors[0] to effect->actors[effect->count - 1]: the loops that flash, shake, strike or aim at each target in turn.

Used by BattleFx_RunBolt, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunCybele, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDouse, BattleFx_RunDrain, BattleFx_RunEruption, BattleFx_RunFrost, BattleFx_RunFroth, BattleFx_RunGaia, BattleFx_RunGatheringLights, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunIce, BattleFx_RunJudgment, BattleFx_RunJupiter, BattleFx_RunKirin, BattleFx_RunLobbedShells, BattleFx_RunMars, BattleFx_RunMercury, BattleFx_RunMoteFountain, BattleFx_RunNeptune, BattleFx_RunNereid, BattleFx_RunOrbitingSkulls, BattleFx_RunPaletteParticles, BattleFx_RunPlasma, BattleFx_RunPrism, BattleFx_RunProcne, BattleFx_RunProjectileVolley, BattleFx_RunQuake, BattleFx_RunRagnarok, BattleFx_RunRamses, BattleFx_RunRay, BattleFx_RunShiningStar, BattleFx_RunSleep, BattleFx_RunSparkGroups, BattleFx_RunSpiderWeb, BattleFx_RunSpire and 12 more.

Line 39

battle_effect_chance.h

games/tbs/include/battle/battle_effect_chance.h

battle_effect_work.h

games/tbs/include/battle/battle_effect_work.h

Structures

BattleCanvasOrigin

struct BattleCanvasOrigin

Two adjacent affine background coordinates, queued together for BG2X/BG2Y.

FieldDeclared as
xs32 xBG2X, 8 fractional bits
ys32 yBG2Y, 8 fractional bits
unk_08s32 unk_08Written after staging the coordinates; no reader has been identified.

Line 16

BattleEffectWork

struct BattleEffectWork

The running battle effect's work: its canvas image, 64 particles, the display registers it stages and its animation objects. It lives in the HEAP_SLOT_BATTLE_EFFECT work slot.

FieldDeclared as
sheet, bg2xLines, unk_6c00, imageStorage, image, origin, trackedCanvasunion { struct { u8 sheet[0x6980]; ///< the effect's decoded pictures, at fixed offsets s32 bg2xLines[160]; ///< BG2X for each scanline, for an HBlank DMA u8 unk_6c00[0x480]; ///< not named by TBS code }; u8 imageStorage[0x7080]; /// The tracked elemental scene stages its origin inside the image area. struct { u8 image[0x13c4]; struct BattleCanvasOrigin origin; } trackedCanvas; }Images and scanline tables reuse the storage before the particles. The tile-animation mask extends beyond sheet into the table area.
particlesstruct EffectStep particles[64]free while variant is -1
transferModes32 transferModeHow the canvas transfer callbacks treat the canvas after each copy (enum CanvasTransferMode in effect_internal.h).
transferValues32 transferValueThe transfer mode's argument: the fill value, the share kept (50 or 75 percent) or the darken or brighten amount.
unk_7788s32 unk_7788not named by TBS code
frames32 frameframe counter some effects keep, from 0
scrollTimers32 scrollTimerframes since the last interval scroll step
scrollIntervals32 scrollIntervalframes between interval scroll steps
scrollStepXs32 scrollStepXadded to BG1 or BG2 x at each step
scrollStepYs32 scrollStepYadded to BG1 or BG2 y at each step
savedBg1Xs32 savedBg1XBG1 scroll restored when a shake ends
savedBg1Ys32 savedBg1YBG1 scroll restored when a shake ends
shakeFramess32 shakeFramesshake frames left; Camera_ApplyShake counts down
cameraDeltas32 cameraDeltacamera yaw turned per effect frame
cameraPhases32 cameraPhaseThe effect sets 1 after a frame; Camera_ApplyPhasedDelta then turns the whole cameraDelta and sets 0, else turns half and toggles 0 and 2.
fadeFramess32 fadeFramesbackdrop fade frames left (Palette_StepFadeTransfer)
fadeSteps32 fadeStepCANVAS_FADE_STEPs the backdrop has darkened so far
win0hu16 win0hWindow, display and blend registers, which Graphics_ApplyWindowBlendRegisters writes all at once. @{
win0vu16 win0v
win1hu16 win1h
win1vu16 win1v
wininu16 winin
winoutu16 winout
dispcntu16 dispcnt
bldcntu16 bldcnt
bldalphau16 bldalpha
unk_77ceu16 unk_77ce@} not named by TBS code
bg2xs32 bg2xBG2's reference point, written to BG2X and BG2Y by Display_ApplyBg2Reference and BattleFx_AdvanceBg2OnInterval. @{
bg2ys32 bg2y
objectsstruct AnimationObject *objects[16]@} the effect's animation objects
actorTimersu8 actorTimers[8]Each target's flash timer in frames, for effect->actors[n]: set by ObjectGroup_UpdateMembers, counted down by ObjectGroup_TickMemberTimers.
framesSinceTransfers32 framesSinceTransfer1 on a canvas copy's frame, then counts up
transferPendings32 transferPending1 once the effect has drawn a frame (EFFECT_PRESENT_FRAME); the canvas transfer callback copies the canvas and clears it.
effectstruct BattleEffectArgument *effectthe command being run

Used by BattleFx_AdvanceBg2OnInterval, BattleFx_AdvanceScrollOnInterval, BattleFx_ArmBg2AffineHBlankDma, BattleFx_ArmPaletteHBlankDma, BattleFx_BeginCanvasLayer, BattleFx_ClearActorTimers, BattleFx_DispatchByIdRange, BattleFx_DrawStreaks, BattleFx_EndCanvasLayer, BattleFx_FlushPendingGraphicsTransfer, BattleFx_OpenCanvasLayer, BattleFx_PlaceFormationObjects, BattleFx_ProbeKeysForExtendedActor, BattleFx_ProcessPendingGraphicsTransfer, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunAtalanta, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBladeRain, BattleFx_RunBolt, BattleFx_RunBoreas, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunBurstShower, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDouse, BattleFx_RunDragonCloud, BattleFx_RunDrain, BattleFx_RunElementBurst, BattleFx_RunElementPillar, BattleFx_RunEruption, BattleFx_RunFire, BattleFx_RunFlare and 82 more.

Line 29

Globals, without a comment: offsetof.

battle_escape.h

games/tbs/include/battle/battle_escape.h

battle_event.h

games/tbs/include/battle/battle_event.h

Structures

BattleEventQueue

struct BattleEventQueue

The battle event queue: up to 64 events, each an opcode (enum BattleEventOpcode) and one operand, in the order they play.

FieldDeclared as
opcodesu8 opcodes[BATTLE_EVENT_CAPACITY]
operandsu32 operands[BATTLE_EVENT_CAPACITY]
targetIndexs32 targetIndexthe plan's next target to resolve
counts32 countevents queued

Used by BattleEvPush, BattleEv_DispatchQueued.

Line 25

Enumerations

BattlePlaybackPhase

enum BattlePlaybackPhase

BattleEventState.phase: how far BattleEvent_Playback has got through the plan's targets. Its message phases (PLAY_MESSAGE and the like) are private to playback.c.

Value=
BATTLE_PLAYBACK_IDLE0paused until the effect resumes it
BATTLE_PLAYBACK_RESOLVE_TARGET1resolves the next target's events
BATTLE_PLAYBACK_DISPATCH2plays the queued events in order
BATTLE_PLAYBACK_READY4every target has been played

Line 16

BattleEventOpcode

enum BattleEventOpcode

The battle events BattleEvPush queues, each with one operand, for BattleEvent_Playback (or BattleEv_DispatchQueued) to play in order. The names, numbers and messages build what the player reads: the arguments first, then the message that shows them.

Value=
BATTLE_EVENT_UNIT_NAME0a unit's name for the next message
BATTLE_EVENT_NUMBER1a number for the next message
BATTLE_EVENT_ITEM_NAME2an item's name for the next message
BATTLE_EVENT_ABILITY_NAME3an ability's name for the next message
BATTLE_EVENT_MESSAGE4a message, waiting for the player
BATTLE_EVENT_MESSAGE_NO_WAIT5a message, going straight on
BATTLE_EVENT_MARK6sets gBattleDisplayWork->marked
BATTLE_EVENT_CLEAR_ARGUMENTS7forgets the names and numbers pushed
BATTLE_EVENT_HIT8the unit flinches and flashes
BATTLE_EVENT_DEFEAT9the unit falls; an enemy fades out
BATTLE_EVENT_DRAW_STATUS10redraws the party's status
BATTLE_EVENT_REFRESH_UNIT11the unit's status icons, colour, pose
BATTLE_EVENT_REMOVE_UNIT12an enemy leaves the battle
BATTLE_EVENT_DJINN_BONUS13later defeats give the Djinn bonus
BATTLE_EVENT_SOUND14plays a sound

Line 41

battle_motion.h

games/tbs/include/battle/battle_motion.h

battle_obj.h

games/tbs/include/battle/battle_obj.h

Declarations, without a comment: Actor_Place.

battle_party.h

games/tbs/include/battle/battle_party.h

Structures

DjinnRecoveryEntry

struct DjinnRecoveryEntry

A Djinni on standby or recovering: its element and index, its owner, and the turns until it is set again.

FieldDeclared as
elementu8 elementenum Element
indexu8 indexthe Djinni within its element, 0 to 19
unitIdu8 unitIdits owner
turnss8 turnsTurns until it is set again; -1 on standby (DJINN_RECOVERY_AFTER_BATTLE), -2 while a summon uses it.

Used by BattleCommand_BuildPlan, DjinnRecovery_CountStandby, DjinnRecovery_Tick.

Line 32

DjinnRecoveryList

struct DjinnRecoveryList

One side's Djinn recovery list: up to 64 entries and their count.

FieldDeclared as
entriesstruct DjinnRecoveryEntry entries[64]
counts32 countentries in use

Used by BattleCommand_BuildPlan, BattleParty_CountStandbyDjinn, Battle_SelectAbility, DjinnRecovery_AddStandby, DjinnRecovery_Remove, DjinnRecovery_Tick, Djinn_IsReady.

Line 44

DjinnRecoveryTable

struct DjinnRecoveryTable

One side's Djinn recovery table, as Djinn_GetRecoveryTable returns it.

FieldDeclared as
unk00u8 unk00[8]its first word is BattleSummonState's availableMask
liststruct DjinnRecoveryList list

Used by BattleCommand_BuildPlan, BattleParty_CountStandbyDjinn, Battle_SelectAbility, DjinnRecovery_AddStandby, DjinnRecovery_CountStandby, DjinnRecovery_Remove, DjinnRecovery_Tick, Djinn_IsReady.

Line 50

Enumerations

BattleUnitPresence

enum BattleUnitPresence

BattleUnit.side: which side a unit fights on, if it is in the battle.

Value=
BATTLE_UNIT_ABSENT0
BATTLE_UNIT_ENEMY1
BATTLE_UNIT_PARTY2

Line 11

BattleUnitListMark

enum BattleUnitListMark

Marks in a list of unit ids, such as BattleWork.partyUnits and enemyIds.

Value=
BATTLE_UNIT_REMOVED0xfea place whose unit has left the battle
BATTLE_UNIT_LIST_END0xffends the list

Line 18

BattleSideMask

enum BattleSideMask

Which sides a unit list takes, as BattleParty_ListLivingUnits reads it.

Value=
BATTLE_SIDE_PARTY1
BATTLE_SIDE_ENEMIES2
BATTLE_SIDE_BOTH`BATTLE_SIDE_PARTYBATTLE_SIDE_ENEMIES`

Line 24

battle_random.h

games/tbs/include/battle/battle_random.h

Globals, without a comment: gBattleRandomSeed.

battle_session.h

games/tbs/include/battle/battle_session.h

Structures

BattleObj

struct BattleObj

A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and scale, and the conditions it shows.

FieldDeclared as
objectstruct MotionObject *objectNULL once released
resourceu16 resourcethe unit's sprite
overlayu16 overlaya second sprite drawn over it, the weapon; 0 for none
animationu16 animationthe status icon's animation shown; 0 for none
effectu16 effectan effect sprite drawn with the unit
anchorXs32 anchorX16.16 fixed-point pixels
anchorZs32 anchorZ16.16 fixed-point pixels
palettes32 palettethe unit sprite's palette
scales32 scale16.16 fixed point, 0x10000 full size
activeConditionsu16 activeConditionsa bit per status with an icon (ICON_)
selectedConditionu8 selectedConditionthe status whose icon is shown
cycleTimers8 cycleTimerframes until the next status icon
animationEntrystruct SpriteEntry *animationEntrythe status icon's sprite, or NULL
effectEntrystruct SpriteEntry *effectEntrythe effect sprite, or NULL
actives16 activeSet by BattleObj_MarkForRelease: the object is released with the others by BattleMotion_DestroyAllSlotObjects.
fadings16 fadingset while a fallen enemy's picture is being removed

Used by BattleActor_DestroyTemporaryObject, BattleActor_SpawnObjectsForList, BattleActor_UpdateSpritePriorities, BattleEvent_Playback, BattleFx_InitializeRisingObject, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunProcne, BattleFx_SetApproachMotion, BattleMotion_ApplyPairMidpoint, BattleMotion_ApplyVariantMotion, BattleMotion_ApproachTarget, BattleMotion_DestroyAllSlotObjects, BattleMotion_InitializeObject, BattleMotion_InterpolatePosition, BattleMotion_ResetObjectAtScaledAnchor, BattleMotion_SetObjectPosition, BattleMotion_SetupEscapeObject, BattleObjGet, BattleObjMake, BattleObj_MarkForRelease, BattlePres_RunEntryTransition, BattlePresentation_ApplyUnitDamage, BattleStatusIcon_Cycle, BattleUnit_BuildStatusFlags, ObjMotRst, ObjectGroup_UpdateMembers, ReleaseBattleObjectRecords.

Line 16

BattleActionRecord

struct BattleActionRecord

A unit's chosen action for the turn: its command, the command's parameter, its target and range, and its priority in the turn order.

FieldDeclared as
unitIds16 unitId
slotu16 slotin a link battle, unitId as the opponent knows it
priorityu16 priorityfrom the unit's Agility; higher acts first
commands16 commandenum BattleCommand
parameters16 parameteran ability id, or CMD_ITEM's inventory index (-1 gone)
targets16 targetthe aimed unit's id
ranges16 rangethe action's range
unk0es16 unk0enot named by TBS code

Used by BattleCommand_BuildPlan, BattleEscape_PlayRun, BattlePres_BuildOpponentEntries, BattlePres_BuildUnitEntries, BattlePres_RunAction, BattlePres_RunApproachAction, BattlePres_RunItem, BattlePres_RunUnitAction, BattlePres_ShowDefendMessage, BattlePresentation_AppendLinkedActions, BattlePresentation_BuildActions, BattlePresentation_BuildSortedUnitEntries, BattlePresentation_DispatchAction, BattlePresentation_RunPairedUnitTransition, BattleQueue_SortByPriority, BattleTarget_ReplaceDefeated, Battle_CollectPartyCommands.

Line 54

BattleSpoils

struct BattleSpoils

A battle's spoils so far: coins, experience, enemies defeated and up to four items.

FieldDeclared as
coinss32 coins
experiences32 experience
defeateds32 defeatedenemies defeated
itemsu16 items[4]

Used by BattleEnemy_RecordDefeat, BattleSpoils_Clear, Battle_AwardSpoils.

Line 67

Enumerations

BattleCommand

enum BattleCommand

BattleActionRecord.command and BattlePlan's copy of it: what a unit does on its turn.

Value=
CMD_ATTACK0
CMD_PSYNERGY1
CMD_ITEM2
CMD_DEFEND3
CMD_ABILITY4an enemy's ability
CMD_DJINN5
CMD_SUMMON6
CMD_DEFEND27an enemy's Total Defense (effect 47)
CMD_NONE8nothing this turn
CMD_FLEE99

Line 39

battle_status_icon.h

games/tbs/include/battle/battle_status_icon.h

battle_summon.h

games/tbs/include/battle/battle_summon.h

Structures

BattleSpriteDefinition

struct BattleSpriteDefinition

An enemy class's battle sprite: its animation, size, attack effect, palette and defeat-sound kind.

FieldDeclared as
animationu16 animationthe class's battle sprite
spriteBit0u8 spriteBit0 : 1The byte at 2. bits: 7..5 spriteBits5 | 4..1 spriteBits1 | 0 spriteBit0 @{ 1 for a small enemy, which takes one sprite slot
spriteBits1u8 spriteBits1 : 4the attack-effect kind; 0 reads as 1
spriteBits5u8 spriteBits5 : 3the attack-hop height
layoutBit0u8 layoutBit0 : 1@} The byte at 3. bits: 7..5 layoutKind | 4..1 layoutBits1 | 0 layoutBit0 @{ read by Summon_IsEntrySecondaryFlagged only
layoutBits1u8 layoutBits1 : 4the sprite's palette
layoutKindu8 layoutKind : 3the defeat-sound kind; above 4 reads as none
unk04u8 unk04[4]@} [0] is the effect height (BattleClass_GetEffectHeight)

Used by gSummon_EntryTable.

Line 15

SummonDefinition

struct SummonDefinition

A summon: its name's message and the Djinn of each element it needs.

FieldDeclared as
nameMessageIdu16 nameMessageIdThe summon's ability id: its name is message MsgAbilityName plus it, and its low 14 bits pick the icon.
unk02u8 unk02[2]not named by TBS code
djinnRequiredu8 djinnRequired[4]standby Djinn needed, by element

Used by BattleCommand_BuildPlan, Battle_CollectPartyCommands, SummonDefinition_GetNear, SummonMenu_SelectSummon, gSummon_DefinitionTable.

Line 38

BattleSummonState

struct BattleSummonState

The party's Djinn recovery table as summons read it: the mask of summons the party can call, bit n for summon n.

FieldDeclared as
availableMasku32 availableMasknonzero offers the Summon command

Used by Battle_RunEncounter.

Line 48

Globals, without a comment: gSummon_EntryTable.

battle_system.h

games/tbs/include/battle/battle_system.h

Declarations, without a comment: BattleUnit_Recalculate.

battle_target.h

games/tbs/include/battle/battle_target.h

battle_unit.h

games/tbs/include/battle/battle_unit.h

Functions

Vitals_Clamp

static __inline__ s32 Vitals_Clamp(s32 ratio)

Clamps a gauge ratio to 0..0x4000, where 0x4000 means full.

Line 339

Structures

OwnerActionSlot

struct OwnerActionSlot

An entry in a unit's action list: the action's id (OWNER_ACTION_ID_MASK) and marks for an action its class or an equipped item gave.

FieldDeclared as
encodedActionu16 encodedActionbits: 15 from the class | 14 from an equipped item | 13..0 action id. Entries with neither mark were taught for good; 0 is empty.
unk02u16 unk02Not named by any TBS code.

Used by OwnerAction_DiffSlots.

Line 19

BattleElementStats

struct BattleElementStats

A unit's elemental power and resistance in one element.

FieldDeclared as
powers16 powerElemental power in the element.
resistances16 resistanceElemental resistance to it.

Line 27

BattleAct

struct BattleAct

An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind, element, effect, range, PP cost and power.

FieldDeclared as
targetModeu8 targetModeTARGET_MODE_NONE, _FOES, _ALLIES or _SELF
flagsu8 flagsbits: 7 usable in battle | 6 usable in the field | 5..4 clear in every row | 3..0 kind (ABILITY_KIND_MASK, enum AbilityKind).
elementu8 elementenum Element
effectu8 effectenum AbilityEffect
unk04u8 unk04[4][0] the icon the menus draw; [1] to [3] are 0 in every row.
rangeu8 rangethe aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
ppCostu8 ppCostPP the ability costs
poweru16 powerwhat the kind applies, 0 for none
type0cu8 type0cThe field Psynergy the ability works as, 1 (Move) to 16 (Avoid); 0 for none. The field effects branch on it, and the status screen counts it as usable in the field.
unk0du8 unk0d[3]0 in every row.

Used by Ability_PlayUseAnimation, BattleCommand_BuildPlan, BattleEffect_ApplyToTargets, BattleMenu_RunActionSelection, BattleQueue_SortByPriority, BattleTarget_SelectForAction, Battle_ClassifyEntryKind, Battle_CollectPartyCommands, Item_ClassifyUseMode, Menu_ResolveSelectedAction, PsynergyMenu_ClassifySelectedPsynergy, PsynergyMenu_CollectActions, PsynergyMenu_DrawActionPage, PsynergyMenu_DrawListPage, PsynergyMenu_DrawRangePage, PsynergyMenu_IsActionRestricted, PsynergyMenu_RunList, gBattleAction_DefinitionTable.

Line 151

BattleUnit

struct BattleUnit

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

FieldDeclared as
nameu8 name[0x0f]The name, one byte a character, ending in 0. An enemy's is its message name cut to 14 characters, with the suffix letter BattleUnitSet is given (a digit in Japanese); name[14] is always 0.
levelu8 level1 to 99 for a character
baseHps16 baseHpbefore equipment, Djinn and class (UnitCalc)
basePps16 basePpbefore equipment, Djinn and class (UnitCalc)
hpGauges16 hpGaugehp / maxHp in 0..0x4000; 1 while any HP remains
ppGauges16 ppGaugepp / maxPp in 0..0x4000; 1 while any PP remains
baseAttacku16 baseAttackbefore equipment, Djinn, class and stages
baseDefenseu16 baseDefensebefore equipment, Djinn, class and stages
baseAgilityu16 baseAgilitybefore equipment, Djinn, class and stages
baseLucku8 baseLuckbefore equipment, Djinn and class
baseActionCountu8 baseActionCountActions a round before equipment: the low four bits are read. An enemy's comes from its definition's turns; a level up sets a character's to 1.
baseHpRegenu8 baseHpRegenHP regained each turn before equipment; 0 for a character
basePpRegenu8 basePpRegenPP regained each turn before equipment and lighthouses
unk022u8 unk022[2]Not named by any TBS code.
baseElementstruct BattleElementStats baseElement[4]Power and resistance before equipment and stages: an enemy's from its element preset, a character's from its element levels (Unit_CalcBaseElements).
maxHps16 maxHp0 to 1999 for a character, 9999 for an enemy (UnitCalc)
maxPps16 maxPp0 to 1999 for a character, 9999 for an enemy (UnitCalc)
hps16 hpcurrent HP, 0 when downed
pps16 ppcurrent PP
atku16 atkAttack, 0 to 999 (UnitCalc)
defu16 defDefense, 0 to 999 (UnitCalc)
agiu16 agiAgility, 0 to 999: the order of the round's actions
lucku8 luck0 to 99 (UnitCalc)
actionEntryCountu8 actionEntryCountActions each round, 0 to 2: baseActionCount, one more while ready, and the equipment's extra turns (UnitCalc). Each gives the unit a place in the round's queue.
hpRegenu8 hpRegenHP regained at each turn's end (UnitCalc)
ppRegenu8 ppRegenPP regained at each turn's end, 0 to 200 (UnitCalc): 4 more once the lighthouse of the character's element is lit.
unk046u8 unk046[2]Not named by any TBS code.
elementstruct BattleElementStats element[4]Power and resistance in each element, 0 to 200, after equipment, element levels and Resistance stages (UnitCalc).
actionSlotsstruct OwnerActionSlot actionSlots[32]The action list: Psynergy taught for good, then the class's and the equipment's (Unit_RefreshPsynergy). An empty entry is 0.
inventoryu16 inventory[15]Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*). An empty entry is 0.
unk0f6u8 unk0f6[2]Not named by any TBS code.
djinnAvailableu32 djinnAvailable[4]The Djinn held, one bit per Djinni (by its index) in each element's word.
djinnActiveu32 djinnActive[4]The Djinn set, one bit per Djinni; only these add their stat bonuses.
djinnOwnedCountsu8 djinnOwnedCounts[4]the Djinn held in each element, at most 10
djinnActiveCountsu8 djinnActiveCounts[4]the Djinn set in each element; the class's element levels are read from these
rewardsu32 rewardsCopied from the enemy's definition, where it is 0 in every row. During a battle the enemy's action choice keeps its place in its action list here (BattleCommand_SelectAutomatic).
experienceu32 experiencea character's experience points
classIdu8 classIdWho the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet). The class tables are indexed by classIndex.
classIndexu8 classIndexThe character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy, and code throughout tests it to tell the two apart.
sideu8 sideBATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2). Enemies 158 to 171 are put on side 2 (BattleUnitSet).
guardLevels8 guardLevel0, GUARD_DEFEND (1, half the damage) or GUARD_TOTAL_DEFENSE (2, a tenth); set by Defend and Granite, cleared each round.
elementLevelss8 elementLevels[4]A summon's boost to each element: the Djinn of that element the summon spent, adding (n * n + n) * 5 power (UnitCalc). Cleared at the battle's start and by Break.
restraints8 restraintThe curse. bits: 3 item effect 25 (UnitCalc clears it again with bit 0) | 2 keeps bit 0 | 1 cursed item equipped | 0 bound. UnitCalc rebuilds bits 1 and 0 from the equipment. A bound unit loses one action in four, except Defend (BattleCommand_BuildPlan); any bit set shows the curse in the status screens and lets the sanctum remove it.
poisons8 poison1 poisoned, 2 deadly poison
attackTurnsu8 attackTurnsEach stat change: the turns it has left, and its stage (UnitCalc: an eighth of Attack, Defense or Agility, or 20 Resistance, a stage). Stages run -4 to 4 and last 7 turns. @{
attackStages8 attackStage
defenseTurnsu8 defenseTurns
defenseStages8 defenseStage
resistanceTurnsu8 resistanceTurns
resistanceStages8 resistanceStage
delusionu8 delusion@} Delusion to sleep: the turns each status has left, 7 when it lands; each may end sooner at the end of a turn. Sleep, confusion, charm and stun cost the unit its actions. @{
confusions8 confusion
charmu8 charm
stunu8 stun
sleepu8 sleep
psySealu8 psySeal@} bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast). Psynergy is sealed while any bit is set.
refrainu8 refrainRegenerate's turns left, 7 when cast
reflects8 reflectReflect's turns left, 7 when cast
hauntu8 hauntset while an evil spirit grips the unit
grimReaperu8 grimReaperThe Grim Reaper's countdown: 7 when cursed, down one at each turn's end; at 0 the unit falls.
equipBonusu8 equipBonus[2]The totals of equipment effects 23 (unleash chance) and 24 that UnitCalc sums; TBS never reads them back
readyu8 readyKite's extra action: 2 when cast, down one at each turn's end; while nonzero UnitCalc gives the unit one more action a round.
immobileu8 immobileset by Ground: the next action is lost
agilityTurnsu8 agilityTurnsthe Agility change's turns left, 5 when cast
agilityStages8 agilityStageThe Agility stage: -4 (Vine) to 8 (Zephyr, twice the Agility).
challenges8 challengeSet by the challenge effect: an enemy with it never chooses to flee.
unk149u8 unk149Not named by any TBS code.
enemyIdu16 enemyIdNot named by any TBS code; TLA reads it as the unit's id.

Used by BabiPalace_RestorePartyAndInventory, BattleActor_DestroyTemporaryObject, BattleActor_ResetRuntimeFields, BattleCommand_BuildPlan, BattleEffect_ApplyToTargets, BattleEnemy_AdjustLevel, BattleEnemy_CalculateCoinReward, BattleEnemy_CalculateExperienceReward, BattleEnemy_LetterFirstOfClass, BattleEnemy_RecordDefeat, BattleEnemy_ReleaseNameLetter, BattleEvent_Playback, BattleFx_RollSuccess, BattleFx_RunBeamSequence, BattleMenu_RunActionSelection, BattleMotion_ShowDowned, BattleObjMake, BattleParty_ApplyHealthDelta, BattleParty_ApplyStatusDamage, BattleParty_ListLivingUnits, BattlePres_BuildOpponentEntries, BattlePres_BuildUnitEntries, BattlePres_RunAction, BattlePres_RunAttack, BattlePres_RunEscape, BattlePres_RunItem, BattlePres_SetActorModeAndAction, BattlePres_ShowDefendMessage, BattlePresentation_ApplyUnitDamage, BattlePresentation_BuildActions, BattlePresentation_BuildSortedUnitEntries, BattlePresentation_DispatchAction, BattleTarget_IsWeakToEffect, BattleTarget_RunSelection, BattleTarget_SelectForAction, BattleUnitSet, BattleUnit_BuildStatusFlags, BattleUnit_ResetGuardLevels, BattleUnit_ResetStateByMode, BattleUnit_RollCounterEarlyEnd and 107 more.

Line 178

Enumerations

Element

enum Element

The elements, in the order of every table kept per element: a unit's element stats, the Djinn and the summons. ELEMENT_NONE marks an ability or a weapon that has no element.

Value=
ELEMENT_VENUS
ELEMENT_MERCURY
ELEMENT_MARS
ELEMENT_JUPITER
ELEMENT_NONE
NUM_ELEMENTSELEMENT_NONE

Line 35

AbilityKind

enum AbilityKind

The kinds of ability, by the low four bits of BattleAct.flags. Three kinds have no enumerator, because BattleTargetExec applies no power for them: 0 is no ability; 7 is Granite, Flash and Kite, whose effect is all they do; 9 is the field Psynergy (Move, Catch...), the field-only stat items (Apple, Power Bread...), Defend, Flee and the enemies' commands (Threaten, Ally Search...). The targeting check treats kind 9 as a summon: worth it on a living unit only when the power is nonzero.

Value=
ABILITY_KIND_HEAL_HP1Cure, Fizz, healing items
ABILITY_KIND_EFFECT2damage only if the effect lands
ABILITY_KIND_ATTACK3Attack vs Defense, plus the power
ABILITY_KIND_ATTACK_MULTIPLIED4that attack times power / 10
ABILITY_KIND_DAMAGE5HP damage from the power (Psynergy)
ABILITY_KIND_UNLEASHED_DAMAGE6an enemy's. Shown as X unleashes Y!
ABILITY_KIND_SUMMON8the summons: damage scaled by distance
ABILITY_KIND_PP_DAMAGE10Crazy Voice: the target loses PP
ABILITY_KIND_HEAL_PP11Ember, Psy Crystal, Adept Ring

Line 61

AbilityEffect

enum AbilityEffect

BattleAct.effect: what an ability does besides its damage or healing, applied by BattleTargetExec unless noted. Each is named for the abilities that have it (actions.tsv, with their English names and descriptions). Sidestep (48) and Crazy Voice (52) have effects no code here reads.

Value=
ABILITY_EFFECT_NONE0
ABILITY_EFFECT_CURE_POISON3Cure Poison, Antidote
ABILITY_EFFECT_RESTORE4Restore, Elixir
ABILITY_EFFECT_REVIVE5Revive, Water of Life: full HP
ABILITY_EFFECT_ATTACK_UP_26Impact: two stages
ABILITY_EFFECT_ATTACK_UP7High Impact: one stage
ABILITY_EFFECT_ATTACK_DOWN_28Dull
ABILITY_EFFECT_ATTACK_DOWN9Blunt
ABILITY_EFFECT_DEFENSE_UP_210Guard
ABILITY_EFFECT_DEFENSE_UP11Protect
ABILITY_EFFECT_DEFENSE_DOWN_212Impair
ABILITY_EFFECT_DEFENSE_DOWN13Debilitate
ABILITY_EFFECT_RESISTANCE_UP_214Ward
ABILITY_EFFECT_RESISTANCE_UP15Resist
ABILITY_EFFECT_RESISTANCE_DOWN_216Weaken
ABILITY_EFFECT_RESISTANCE_DOWN17Enfeeble
ABILITY_EFFECT_POISON18Taint
ABILITY_EFFECT_DEADLY_POISON19Poison
ABILITY_EFFECT_DELUSION20Delude
ABILITY_EFFECT_CONFUSION21Confuse
ABILITY_EFFECT_CHARM22Charm
ABILITY_EFFECT_STUN23Paralyze
ABILITY_EFFECT_SLEEP24Sleep
ABILITY_EFFECT_SEAL25Bind: Psynergy sealed
ABILITY_EFFECT_HAUNT26Haunt
ABILITY_EFFECT_INSTANT_DEATH27Condemn
ABILITY_EFFECT_CURSE28Curse: the Grim Reaper's countdown
ABILITY_EFFECT_REGENERATE29Regenerate
ABILITY_EFFECT_REFLECT30Reflect
ABILITY_EFFECT_DRAIN_HP31Drain
ABILITY_EFFECT_DRAIN_PP32Psy Drain
ABILITY_EFFECT_BREAK33Break: raised stats undone
ABILITY_EFFECT_LEAVE_ONE_HP34Severe Blow, Thrash
ABILITY_EFFECT_HALVE_DEFENSE35Torch
ABILITY_EFFECT_CRITICAL_1_IN_6436A 1 in 64 to 1 in 4 chance of an ability's critical hit, rolled by BattleCommand_BuildPlan.
ABILITY_EFFECT_CRITICAL_1_IN_3237
ABILITY_EFFECT_CRITICAL_1_IN_1638
ABILITY_EFFECT_CRITICAL_1_IN_839
ABILITY_EFFECT_CRITICAL_1_IN_440
ABILITY_EFFECT_DOUBLE_BLOW_1_IN_841A chance of a double or triple blow, rolled by BattleCommand_BuildPlan.
ABILITY_EFFECT_DOUBLE_BLOW_1_IN_442Double Fang, Twin Beaks
ABILITY_EFFECT_TRIPLE_BLOW_1_IN_843
ABILITY_EFFECT_TRIPLE_BLOW_1_IN_444Swift Strike
ABILITY_EFFECT_THREATEN45Contain, Threaten, Tremble
ABILITY_EFFECT_DEFEND46Defend, Granite
ABILITY_EFFECT_TOTAL_DEFENSE47Total Defense, Flash
ABILITY_EFFECT_FLEE49Flee
ABILITY_EFFECT_CALL_ALLY50Ally Search, Speed Surge
ABILITY_EFFECT_CALL_HELP51Search for Help
ABILITY_EFFECT_GROUND53Ground: the target's turn lost
ABILITY_EFFECT_CHALLENGE54no ability has it
ABILITY_EFFECT_SELF_DESTRUCT55Dynamite, Mortal Blow
ABILITY_EFFECT_REVIVE_HALF56Quartz
ABILITY_EFFECT_REVIVE_8057Dew: 80% of max HP
ABILITY_EFFECT_AGILITY_DOWN58Vine
ABILITY_EFFECT_AGILITY_UP59Zephyr
ABILITY_EFFECT_DRAIN_HALF_HP60Sap
ABILITY_EFFECT_HEAL_HP_6061Fizz: 60% of max HP
ABILITY_EFFECT_HEAL_HP_3062Spritz: 30%
ABILITY_EFFECT_HEAL_PP_763Ember: 7% of max PP
ABILITY_EFFECT_CURE_ALL64Tonic
ABILITY_EFFECT_DOUBLE_BLOW_6065Gust, Rapid Smash: 153 in 256
ABILITY_EFFECT_ACT_TWICE66Kite
ABILITY_EFFECT_SEAL_2_TURNS67Luff
ABILITY_EFFECT_TRIPLE_BLOW_6068Sonic Smash
ABILITY_EFFECT_PSY_LEECH69Psy Leech

Line 77

BattleActionUse

enum BattleActionUse

BattleAct.flags: where an ability can be used.

Value=
ACTION_USABLE_IN_FIELD0x40can be used outside battle
ACTION_USABLE_IN_BATTLE0x80can be used in battle; else greyed there

Line 171

Macros

ABILITY_RANGE_ALL

#define ABILITY_RANGE_ALL 255

BattleAct.range of an ability that reaches every unit on the side, each as if aimed at.

Used by BattleMenu_RunActionSelection, BattleTarget_RunSelection.

Line 46

ABILITY_KIND_MASK

#define ABILITY_KIND_MASK 15

The low four bits of BattleAct.flags: how BattleTargetExec applies the ability's power. Kinds 0, 7 and 9 apply none: 0 is no ability, 7 is Granite, Flash and Kite, 9 the field Psynergy, Defend, Flee and enemies' commands.

Used by BattleCommand_BuildPlan, BattleTarget_SelectForAction, Battle_ClassifyEntryKind.

Line 52

Also, macros without a comment: Unit_UpdateGauges.

effect_slot.h

games/tbs/include/battle/effect_slot.h

Structures

EffectSlot

struct EffectSlot

A particle a Psynergy effect moves and draws: its sprite, its position and target, its speed, scale and heading, and its per-frame callback.

FieldDeclared as
objectvoid *objectthe slot's sprite, released with the slot
xs32 x16.16 fixed-point pixels
zs32 z16.16 fixed-point pixels
targetXs32 targetX16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
targetZs32 targetZ16.16 fixed-point pixels; EFFECT_NO_TARGET at rest
originXs32 originX16.16 fixed-point pixels; where the slot started
originZs32 originZ16.16 fixed-point pixels; where the slot started
speeds32 speed16.16 fixed-point pixels per frame
maxSpeeds32 maxSpeed16.16 fixed-point pixels per frame
accelerations32 acceleration16.16 fixed-point pixels per frame, each frame
scaleXs32 scaleX16.16 fixed point, 0x10000 full size
scaleYs32 scaleY16.16 fixed point, 0x10000 full size
headingu16 heading1/65536 turns
maxTurnSteps16 maxTurnStep1/65536 turns a frame
callbackEffectCallback callbackrun each frame once callbackDelay is 0
ageu16 ageframes
callbackDelays16 callbackDelayframes
orbitRadiuss16 orbitRadiuspixels
orbitAngles16 orbitAngle1/32 turns
states8 statethe callback's own step; 0 when it is given
stopAtTargets8 stopAtTargetnonzero: lands on the target within 8 pixels
limitTurnSteps8 limitTurnStepClamp steering to maxTurnStep; zero faces the target directly.
updateMotions8 updateMotionnonzero: EffectSlot_UpdateMotion moves it each frame
renders8 rendernonzero: drawn each frame
actives8 activenonzero while the slot is in use
randomValueu8 randomValuerandom when filled; not read by name in TBS
flagsu8 flagsbits: 2 z also lifts the sprite (set when the slot is filled)

Used by AltmillerCave_ReleaseWallBurst, AltmillerCave_UpdateWallFragment, BattleEffect_CleanupSceneObjects, BattleEffect_RunFallbackObjectTransition, BattleEffect_UpdatePhasedRadialParticle, BattleFx_ClearActiveSlotsAndScheduleUpdates, BattleFx_ClearOwnedSlot, BattleFx_DrawScaledObject, BattleFx_RunAngledApproachPhases, BattleFx_RunMercuryDjinnCapture, BattleFx_RunVenusDjinnCapture, BattleFx_UpdateOrbitAndReturn, BattleFx_UpdateRadialBurst, BattleFx_UpdateRadialCamera, BattleFx_UpdateRadialLaunch, BattleFx_UpdateRadialMotion, BattleFx_UpdateRadialSpread, BattleFx_UpdateRandomTargetParticle, Djinn_RunJupiterJoinEffect, Djinn_RunMarsJoinEffect, EffectSlot_HasPendingTarget, EffectSlot_Initialize, EffectSlot_SetCallback, EffectSlot_SetObjectMode, EffectSlot_SetPosition, EffectSlot_Update, EffectSlot_UpdateMotion, FieldFx_RunForce, FieldFx_RunRetreat, FieldFx_UpdateSceneSlots, Shop_ResetEffects, Shop_RunPartyMemberIconBurst.

Line 18

Types, without a comment: EffectCallback.

Macros, without a comment: EFFECT_NO_TARGET.

fx_scene.h

games/tbs/include/battle/fx_scene.h

Functions, without a comment: BattleFx_Interpolate.

Structures

ArcEffectObject

struct ArcEffectObject

A field object as Avoid's caster: its facing, its animation records and the phase and frame count of its per-frame callback.

FieldDeclared as
unk00u8 unk00[6]not named through this view
angleu16 angle1/65536 turns
unk08u8 unk08[0x48]not named through this view
recordsstruct AnimationObject *recordsthe caster's sprite
unk54u8 unk54[0x10]not named through this view
phases16 phase1 spins the caster 0xc00 a frame
steps16 stepframes since the arcs started
linkedObjectstruct FieldActor *linkedObject
callbackvoid (*callback)(union FieldObject *object)run each frame

Used by BattleFx_UpdatePairedArcSpawner, FieldFx_BlinkAvoidCaster, FieldFx_RunAvoid.

Line 17

BattleFxScene

struct BattleFxScene

The work of a Psynergy effect scene: its caster and target, where it takes place, the map state it restores and its 24 effect slots.

FieldDeclared as
angles32 angle1/65536 turns
xs32 x16.16 fixed-point pixels
ys32 y16.16 fixed-point pixels
zs32 z16.16 fixed-point pixels
mainObjectvoid *mainObjectthe caster's object
childvoid *childthe target's object, or NULL
firstObjectIds16 firstObjectIdthe caster's object id
secondObjectIds16 secondObjectIdthe target's object id, -1 for none
actionu16 actionthe ability id
fieldKinds16 fieldKindthe ability's field kind (FIELD_KIND_)
enableds8 enabledSet at the start: Force then aims in front of the caster; cleared once the target has been dispatched.
modeu8 modewhere the effect runs; MODE_WORLD_MAP on the world map
visibles8 visibleset at the start: the caster flashes with a sound
actives8 activeset at the start: the ability's name is announced
finishCallbackvoid (*finishCallback)(void)run, when set, as Ply's effect ends
unk28u8 unk28[0x0c]not named by TBS code
childOptions8 childOptionSet by some scenes before an effect; Carry, Frost, Force and Reveal treat the target differently with it.
childModes8 childModeset by some scenes: Frost and Force leave the target be
unk36u8 unk36[2]not named by TBS code
savedCallbackvoid (*savedCallback)(union FieldObject *object)The target's update hook and script, saved at the start and restored when Move or Carry lets it go. @{
savedScriptconst s32 *savedScript
unk40u8 unk40[4]@} not named by TBS code
savedPaletteu8 savedPalettethe target's first sprite's param, saved likewise
litu8 litset in two Mercury Lighthouse maps; not read by name
tileSlotu16 tileSlotresource entry holding the spark tiles
unk48u16 unk48not named by TBS code
freeBlocksu16 freeBlocks512 less the free resource blocks at the start
savedShakeXs32 savedShakeXThe map's shake and its decay, restored when the effect ends. @{
savedShakeYs32 savedShakeY
savedShakeDecays32 savedShakeDecay
slotsstruct EffectSlot slots[24]@}
unk718u8 unk718[2]not named by TBS code
arcTileSlots16 arcTileSlotresource entry of Avoid's and Retreat's arcs
messageModes8 messageModethe announcement's box mode: 1, a scene adds 8
unk71du8 unk71d[3]not named by TBS code

Used by AltmillerCave_BeginRetreat, AltmillerCave_CheckFrostTargetCollision, AltmillerCave_EndReveal, AltmillerCave_FreezePuddle, AltmillerCave_ReleaseWallBurst, BabiLighthouse_EnableChildOption, BattleEffect_CleanupSceneObjects, BattleEffect_RunFallbackObjectTransition, BattleEffect_SpawnBurstParticleField, BattleFx_ClearActiveSlotsAndScheduleUpdates, BattleFx_ClearChildValueOnMismatch, BattleFx_DispatchRequestKind, BattleFx_InitializeSlots, BattleFx_LoadActionEffectResources, BattleFx_MarkChildAndRunFallbackTransition, BattleFx_Run, BattleFx_RunMercuryDjinnCapture, BattleFx_RunSparkEmitter, BattleFx_RunVenusDjinnCapture, BattleFx_SetupObjectPair, BattleFx_SpawnDescendingArcParticles, BattleFx_SpawnFallingParticles, BattleFx_SpawnScaledArcObjects, BattleFx_SteerLiftedTarget, BattleFx_SteerPushedTarget, BattleFx_UpdateRadialBurst, BattleFx_UpdateRadialCamera, BattleFx_UpdateRadialLaunch, BattleFx_UpdateShrinkingOrbitObject, DebugMenu_EnableEffectChildMode, Djinn_RunJupiterJoinEffect, Djinn_RunMarsJoinEffect, EffectRuntime_StopCurrentObject, EventObject_Initialize, Event_DouseCastAtStorm, Event_PrepareForce, Event_StartDousingTravelMarker, FieldEvent_RunTypeHandler, FieldFx_RunAvoid, FieldFx_RunCatch and 21 more.

Line 31

motobj.h

games/tbs/include/battle/motobj.h

Structures

MotionObject

struct MotionObject

An effect object that moves and draws one sprite: its position, scale, velocity and target, and its per-frame update. It is one of the object slots Object_CreateFar hands out, the same object FieldActor and ScriptMotionObject describe; the notes name their fields at the same offsets.

FieldDeclared as
unk00u8 unk00[0x06]ScriptMotionObject's script and scriptCursor
angleu16 angle1/65536 turns
xs32 x16.16 fixed-point pixels
ys32 y16.16 fixed-point pixels
zs32 z16.16 fixed-point pixels
unk14u8 unk14[0x04]FieldActor's terrainHeight, the ground's y
scaleXs32 scaleX16.16 fixed point, 0x10000 full size
scaleYs32 scaleY16.16 fixed point, 0x10000 full size
heightu16 heighthalf the sprite's box height; FieldActor's radius
unk22u8 unk22[0x02]FieldActor's terrainId and priorityFlags
velocityXs32 velocityX16.16 fixed-point pixels per frame
velocityYs32 velocityY16.16 fixed-point pixels per frame
velocityZs32 velocityZ16.16 fixed-point pixels per frame
speedLimits32 speedLimit16.16 fixed-point pixels per frame
accelerations32 accelerationHorizontal speed gained each frame towards the target, or lost braking without one, in 16.16 fixed-point pixels per frame.
targetXs32 targetX16.16 fixed-point pixels; 0x80000000 for no target
targetYs32 targetY16.16 fixed-point pixels
targetZs32 targetZ16.16 fixed-point pixels
verticalMotionPhases32 verticalMotionPhaseWith motionFlags bit 1, the 16.16 share of velocityY kept on a bounce; with bit 2, the float's phase, stepped each frame (ScriptMotionObject's vertical).
verticalMotionStrengths32 verticalMotionStrengthGravity: taken from velocityY each frame above the ground with motionFlags bit 1, in 16.16 fixed-point pixels per frame; with bit 2, it also scales the float.
unk4cu8 unk4c[0x04]FieldActor's riseBaseY
recordsvoid *recordsone sprite, or a table of up to four (recordStorageKind)
recordStorageKindu8 recordStorageKindbits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE
motionFlagsu8 motionFlagsbits: 4 no terrain slowdown | 3 bigger float | 2 floats | 1 falls | 0 follows terrain
unk56u8 unk56[0x02]ScriptMotionObject's arrivalAxis and unk57
snapToTargetu8 snapToTargetnonzero: lands exactly on the target, else brakes in
unk59u8 unk59FieldActor's collisionFlags; battle units set 3
autoFaceMotionu8 autoFaceMotionbit 0 turns the object to face where it moves
unk5bu8 unk5b[0x11]FieldActor's paused, timer, linkedObject and the bytes between; not named by TBS code through this view.
updatevoid (*update)(union FieldObject *object)run first each frame

Used by Animation_ApplyChildPalette, BattleActor_SpawnObjectsForList, BattleActor_UpdateSpritePriorities, BattleEffect_RunFallbackObjectTransition, BattleFx_AdvanceSpinAngle, BattleFx_FindMatchingEvent, BattleFx_FinishSceneAndReleaseHeapBlock, BattleFx_InitializeRisingObject, BattleFx_RunAngledApproachPhases, BattleFx_RunAnnihilation, BattleFx_RunAstralBlast, BattleFx_RunBeamSequence, BattleFx_RunBind, BattleFx_RunBreak, BattleFx_RunBurstScene, BattleFx_RunCastingImpact, BattleFx_RunCondemn, BattleFx_RunCybele, BattleFx_RunDeathPlunge, BattleFx_RunDjinnBeams, BattleFx_RunDjinnHeal, BattleFx_RunDjinniEntrance, BattleFx_RunDrain, BattleFx_RunFire, BattleFx_RunFroth, BattleFx_RunGatheringLights, BattleFx_RunGround, BattleFx_RunHaunt, BattleFx_RunHealingMotes, BattleFx_RunHelmSplitter, BattleFx_RunLobbedShells, BattleFx_RunMoteFountain, BattleFx_RunNereid, BattleFx_RunOrbitingSkulls, BattleFx_RunOrbitingSpirals, BattleFx_RunParticleStreams, BattleFx_RunPlanetDiver, BattleFx_RunProcne, BattleFx_RunProjectileVolley, BattleFx_RunQuake and 60 more.

Line 20

SpriteEntry

struct SpriteEntry

A sprite of an animation record, as battle objects set its palette and drawing priority.

FieldDeclared as
unk00u8 unk00[5]
paletteu8 palette
priorityu8 priority

Used by BattleActor_SpawnObjectsForList, BattleActor_UpdateSpritePriorities, BattleStatusIcon_Cycle.

Line 68

object_effect_scripts.h

games/tbs/include/battle/object_effect_scripts.h

Macros, without a comment: GUARD_OBJECT_EFFECT_SCRIPTS_H.

Globals, without a comment: gBattleFx_CommonParticleScript, gBattleFx_FragmentScript.

On this page