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.
| Field | Declared as | |
|---|---|---|
object | void *object | |
padding04 | u8 padding04[8] | |
word0c | s32 word0c | |
word10 | s32 word10 | |
padding14 | u8 padding14[0x0c] | |
excluded20 | void *excluded20 | |
excluded24 | void *excluded24 | |
padding28 | u8 padding28[2] | |
suppressUpdates | s16 suppressUpdates |
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.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[0x36] | BattleCamera's eye to pitch; not named in this view |
scroll | u16 scroll | the camera's yaw, in 1/65536 turns |
Used by BattleFx_RunPlasma, BattleFx_RunSparkGroups.
EffectVector
struct EffectVector
A world position, as Camera_WorldToScreen converts it to the screen.
| Field | Declared as | |
|---|---|---|
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.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.
Ring
struct Ring
One of the star field's three rings, moving outward on the effect canvas.
| Field | Declared as | |
|---|---|---|
x | s32 x | 1/1024 canvas pixels |
y | s32 y | 1/1024 canvas pixels |
velX | s32 velX | 1/1024 canvas pixels per frame |
velY | s32 velY | 1/1024 canvas pixels per frame |
age | s32 age | frames |
ScatterPosition
struct ScatterPosition
The position an item-break effect spawns its objects and shards from.
| Field | Declared as | |
|---|---|---|
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
Enumerations
BattlePose
enum BattlePose
The battle sprites' animations (AnimationObjects_SelectAnimation numbers) that the battle code picks by name.
| Value | = | |
|---|---|---|
POSE_ENEMY_HELD | 0 | an enemy asleep, stunned or held |
POSE_STANDING | 1 | |
POSE_PARTY_HELD | 4 | asleep, stunned or held; also a downed member |
POSE_DAMAGE | 5 | taking damage |
POSE_ENEMY_DOWN | 5 | a downed enemy stays in its damage pose |
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.
| Field | Declared as | |
|---|---|---|
eye | s32 eye[3] | The eye, 16.16 fixed-point pixels: written each frame distance behind the focus along the turned view. |
pos | s32 pos[3] | the focus, 16.16 fixed-point pixels |
unk18 | s32 unk18 | cleared beside followPos; not read by name in TBS |
followPos | s32 *followPos | when set, the focus followed instead of pos |
distance | s32 distance | eye to focus, 16.16 fixed-point pixels |
unk24 | u8 unk24[16] | not named by TBS code |
pitch | u16 pitch | 1/65536 turns |
yaw | u16 yaw | 1/65536 turns |
unk38 | u8 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.
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.
| Field | Declared as | |
|---|---|---|
targetYaw | s32 targetYaw | 1/65536 turns |
frames | s32 frames | frames left to ease the yaw, a sixteenth a frame |
unk08 | u8 unk08[8] | BattleBackgroundView's mode and secondMode |
active | s32 active | BattleBackgroundView's busy, at the same offset |
flag | s32 flag | 0 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. |
unk18 | s32 unk18 | cleared when the battle starts; not read by name in TBS |
unk1c | s32 unk1c | cleared 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.
BattlePresentationWork
struct BattlePresentationWork
The effect updates its command while the presentation keeps animation state.
| Field | Declared as | |
|---|---|---|
effect | struct BattleEffectArgument effect | |
savedAnimationParameters | u8 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.
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).
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[8] | BattlePresentationTransition's targetYaw and frames |
mode | s32 mode | 2 draws the affine plane; 1 sets BG1's scroll too |
secondMode | s32 secondMode | 1 also sets BG1's scroll; one effect sets it |
busy | s32 busy | while 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.
BattleAffine
struct BattleAffine
The battle background's affine parameters and reference point, copied whole to the BG2PA registers.
| Field | Declared as | |
|---|---|---|
pa, pb, pc, pd | u16 pa, pb, pc, pd | |
x, y | s32 x, y |
Used by BattleCamera_SetRange.
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.
| Field | Declared as | |
|---|---|---|
page | u32 page | the page of lines shown; the other one is built |
unk04 | u8 unk04[12] | not named by TBS code |
affine | struct BattleAffine affine | |
lines | u16 lines[2][160] |
Used by BattleCamera_SetRange, BattlePres_UpdateHBlankScroll, BattlePresentation_InitializeWorkAndResetState.
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.
| Field | Declared as | |
|---|---|---|
kind | s32 kind | handler table index; 200 more for a critical hit |
side | s32 side | 1 when the targets are the party, 0 for enemies |
actor | s32 actor | the user's unit id |
firstTarget | s32 firstTarget | the action's first target, standing or not |
range | s32 range | forwarded action range, otherwise initialized to 1 |
count | s32 count | targets in actors, at least 1 |
variant | s32 variant | the ability's size, from 0 (Quake, then Earthquake) |
prelude | s32 prelude | 1 plays a prelude: in some effects a Djinni appears |
unk0020 | s32 unk0020 | not named by TBS code |
actors | s16 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.
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.
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.
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.
| Field | Declared as | |
|---|---|---|
x | s32 x | BG2X, 8 fractional bits |
y | s32 y | BG2Y, 8 fractional bits |
unk_08 | s32 unk_08 | Written after staging the coordinates; no reader has been identified. |
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.
| Field | Declared as | |
|---|---|---|
sheet, bg2xLines, unk_6c00, imageStorage, image, origin, trackedCanvas | union { 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. |
particles | struct EffectStep particles[64] | free while variant is -1 |
transferMode | s32 transferMode | How the canvas transfer callbacks treat the canvas after each copy (enum CanvasTransferMode in effect_internal.h). |
transferValue | s32 transferValue | The transfer mode's argument: the fill value, the share kept (50 or 75 percent) or the darken or brighten amount. |
unk_7788 | s32 unk_7788 | not named by TBS code |
frame | s32 frame | frame counter some effects keep, from 0 |
scrollTimer | s32 scrollTimer | frames since the last interval scroll step |
scrollInterval | s32 scrollInterval | frames between interval scroll steps |
scrollStepX | s32 scrollStepX | added to BG1 or BG2 x at each step |
scrollStepY | s32 scrollStepY | added to BG1 or BG2 y at each step |
savedBg1X | s32 savedBg1X | BG1 scroll restored when a shake ends |
savedBg1Y | s32 savedBg1Y | BG1 scroll restored when a shake ends |
shakeFrames | s32 shakeFrames | shake frames left; Camera_ApplyShake counts down |
cameraDelta | s32 cameraDelta | camera yaw turned per effect frame |
cameraPhase | s32 cameraPhase | The effect sets 1 after a frame; Camera_ApplyPhasedDelta then turns the whole cameraDelta and sets 0, else turns half and toggles 0 and 2. |
fadeFrames | s32 fadeFrames | backdrop fade frames left (Palette_StepFadeTransfer) |
fadeStep | s32 fadeStep | CANVAS_FADE_STEPs the backdrop has darkened so far |
win0h | u16 win0h | Window, display and blend registers, which Graphics_ApplyWindowBlendRegisters writes all at once. @{ |
win0v | u16 win0v | |
win1h | u16 win1h | |
win1v | u16 win1v | |
winin | u16 winin | |
winout | u16 winout | |
dispcnt | u16 dispcnt | |
bldcnt | u16 bldcnt | |
bldalpha | u16 bldalpha | |
unk_77ce | u16 unk_77ce | @} not named by TBS code |
bg2x | s32 bg2x | BG2's reference point, written to BG2X and BG2Y by Display_ApplyBg2Reference and BattleFx_AdvanceBg2OnInterval. @{ |
bg2y | s32 bg2y | |
objects | struct AnimationObject *objects[16] | @} the effect's animation objects |
actorTimers | u8 actorTimers[8] | Each target's flash timer in frames, for effect->actors[n]: set by ObjectGroup_UpdateMembers, counted down by ObjectGroup_TickMemberTimers. |
framesSinceTransfer | s32 framesSinceTransfer | 1 on a canvas copy's frame, then counts up |
transferPending | s32 transferPending | 1 once the effect has drawn a frame (EFFECT_PRESENT_FRAME); the canvas transfer callback copies the canvas and clears it. |
effect | struct BattleEffectArgument *effect | the 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.
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.
| Field | Declared as | |
|---|---|---|
opcodes | u8 opcodes[BATTLE_EVENT_CAPACITY] | |
operands | u32 operands[BATTLE_EVENT_CAPACITY] | |
targetIndex | s32 targetIndex | the plan's next target to resolve |
count | s32 count | events queued |
Used by BattleEvPush, BattleEv_DispatchQueued.
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_IDLE | 0 | paused until the effect resumes it |
BATTLE_PLAYBACK_RESOLVE_TARGET | 1 | resolves the next target's events |
BATTLE_PLAYBACK_DISPATCH | 2 | plays the queued events in order |
BATTLE_PLAYBACK_READY | 4 | every target has been played |
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_NAME | 0 | a unit's name for the next message |
BATTLE_EVENT_NUMBER | 1 | a number for the next message |
BATTLE_EVENT_ITEM_NAME | 2 | an item's name for the next message |
BATTLE_EVENT_ABILITY_NAME | 3 | an ability's name for the next message |
BATTLE_EVENT_MESSAGE | 4 | a message, waiting for the player |
BATTLE_EVENT_MESSAGE_NO_WAIT | 5 | a message, going straight on |
BATTLE_EVENT_MARK | 6 | sets gBattleDisplayWork->marked |
BATTLE_EVENT_CLEAR_ARGUMENTS | 7 | forgets the names and numbers pushed |
BATTLE_EVENT_HIT | 8 | the unit flinches and flashes |
BATTLE_EVENT_DEFEAT | 9 | the unit falls; an enemy fades out |
BATTLE_EVENT_DRAW_STATUS | 10 | redraws the party's status |
BATTLE_EVENT_REFRESH_UNIT | 11 | the unit's status icons, colour, pose |
BATTLE_EVENT_REMOVE_UNIT | 12 | an enemy leaves the battle |
BATTLE_EVENT_DJINN_BONUS | 13 | later defeats give the Djinn bonus |
BATTLE_EVENT_SOUND | 14 | plays a sound |
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.
| Field | Declared as | |
|---|---|---|
element | u8 element | enum Element |
index | u8 index | the Djinni within its element, 0 to 19 |
unitId | u8 unitId | its owner |
turns | s8 turns | Turns 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.
DjinnRecoveryList
struct DjinnRecoveryList
One side's Djinn recovery list: up to 64 entries and their count.
| Field | Declared as | |
|---|---|---|
entries | struct DjinnRecoveryEntry entries[64] | |
count | s32 count | entries in use |
Used by BattleCommand_BuildPlan, BattleParty_CountStandbyDjinn, Battle_SelectAbility, DjinnRecovery_AddStandby, DjinnRecovery_Remove, DjinnRecovery_Tick, Djinn_IsReady.
DjinnRecoveryTable
struct DjinnRecoveryTable
One side's Djinn recovery table, as Djinn_GetRecoveryTable returns it.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[8] | its first word is BattleSummonState's availableMask |
list | struct DjinnRecoveryList list |
Used by BattleCommand_BuildPlan, BattleParty_CountStandbyDjinn, Battle_SelectAbility, DjinnRecovery_AddStandby, DjinnRecovery_CountStandby, DjinnRecovery_Remove, DjinnRecovery_Tick, Djinn_IsReady.
Enumerations
BattleUnitPresence
enum BattleUnitPresence
BattleUnit.side: which side a unit fights on, if it is in the battle.
| Value | = | |
|---|---|---|
BATTLE_UNIT_ABSENT | 0 | |
BATTLE_UNIT_ENEMY | 1 | |
BATTLE_UNIT_PARTY | 2 |
BattleUnitListMark
enum BattleUnitListMark
Marks in a list of unit ids, such as BattleWork.partyUnits and enemyIds.
| Value | = | |
|---|---|---|
BATTLE_UNIT_REMOVED | 0xfe | a place whose unit has left the battle |
BATTLE_UNIT_LIST_END | 0xff | ends the list |
BattleSideMask
enum BattleSideMask
Which sides a unit list takes, as BattleParty_ListLivingUnits reads it.
| Value | = | |
|---|---|---|
BATTLE_SIDE_PARTY | 1 | |
BATTLE_SIDE_ENEMIES | 2 | |
BATTLE_SIDE_BOTH | `BATTLE_SIDE_PARTY | BATTLE_SIDE_ENEMIES` |
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.
| Field | Declared as | |
|---|---|---|
object | struct MotionObject *object | NULL once released |
resource | u16 resource | the unit's sprite |
overlay | u16 overlay | a second sprite drawn over it, the weapon; 0 for none |
animation | u16 animation | the status icon's animation shown; 0 for none |
effect | u16 effect | an effect sprite drawn with the unit |
anchorX | s32 anchorX | 16.16 fixed-point pixels |
anchorZ | s32 anchorZ | 16.16 fixed-point pixels |
palette | s32 palette | the unit sprite's palette |
scale | s32 scale | 16.16 fixed point, 0x10000 full size |
activeConditions | u16 activeConditions | a bit per status with an icon (ICON_) |
selectedCondition | u8 selectedCondition | the status whose icon is shown |
cycleTimer | s8 cycleTimer | frames until the next status icon |
animationEntry | struct SpriteEntry *animationEntry | the status icon's sprite, or NULL |
effectEntry | struct SpriteEntry *effectEntry | the effect sprite, or NULL |
active | s16 active | Set by BattleObj_MarkForRelease: the object is released with the others by BattleMotion_DestroyAllSlotObjects. |
fading | s16 fading | set 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.
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.
| Field | Declared as | |
|---|---|---|
unitId | s16 unitId | |
slot | u16 slot | in a link battle, unitId as the opponent knows it |
priority | u16 priority | from the unit's Agility; higher acts first |
command | s16 command | enum BattleCommand |
parameter | s16 parameter | an ability id, or CMD_ITEM's inventory index (-1 gone) |
target | s16 target | the aimed unit's id |
range | s16 range | the action's range |
unk0e | s16 unk0e | not 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.
BattleSpoils
struct BattleSpoils
A battle's spoils so far: coins, experience, enemies defeated and up to four items.
| Field | Declared as | |
|---|---|---|
coins | s32 coins | |
experience | s32 experience | |
defeated | s32 defeated | enemies defeated |
items | u16 items[4] |
Used by BattleEnemy_RecordDefeat, BattleSpoils_Clear, Battle_AwardSpoils.
Enumerations
BattleCommand
enum BattleCommand
BattleActionRecord.command and BattlePlan's copy of it: what a unit does on its turn.
| Value | = | |
|---|---|---|
CMD_ATTACK | 0 | |
CMD_PSYNERGY | 1 | |
CMD_ITEM | 2 | |
CMD_DEFEND | 3 | |
CMD_ABILITY | 4 | an enemy's ability |
CMD_DJINN | 5 | |
CMD_SUMMON | 6 | |
CMD_DEFEND2 | 7 | an enemy's Total Defense (effect 47) |
CMD_NONE | 8 | nothing this turn |
CMD_FLEE | 99 |
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.
| Field | Declared as | |
|---|---|---|
animation | u16 animation | the class's battle sprite |
spriteBit0 | u8 spriteBit0 : 1 | The byte at 2. bits: 7..5 spriteBits5 | 4..1 spriteBits1 | 0 spriteBit0 @{ 1 for a small enemy, which takes one sprite slot |
spriteBits1 | u8 spriteBits1 : 4 | the attack-effect kind; 0 reads as 1 |
spriteBits5 | u8 spriteBits5 : 3 | the attack-hop height |
layoutBit0 | u8 layoutBit0 : 1 | @} The byte at 3. bits: 7..5 layoutKind | 4..1 layoutBits1 | 0 layoutBit0 @{ read by Summon_IsEntrySecondaryFlagged only |
layoutBits1 | u8 layoutBits1 : 4 | the sprite's palette |
layoutKind | u8 layoutKind : 3 | the defeat-sound kind; above 4 reads as none |
unk04 | u8 unk04[4] | @} [0] is the effect height (BattleClass_GetEffectHeight) |
Used by gSummon_EntryTable.
SummonDefinition
struct SummonDefinition
A summon: its name's message and the Djinn of each element it needs.
| Field | Declared as | |
|---|---|---|
nameMessageId | u16 nameMessageId | The summon's ability id: its name is message MsgAbilityName plus it, and its low 14 bits pick the icon. |
unk02 | u8 unk02[2] | not named by TBS code |
djinnRequired | u8 djinnRequired[4] | standby Djinn needed, by element |
Used by BattleCommand_BuildPlan, Battle_CollectPartyCommands, SummonDefinition_GetNear, SummonMenu_SelectSummon, gSummon_DefinitionTable.
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.
| Field | Declared as | |
|---|---|---|
availableMask | u32 availableMask | nonzero offers the Summon command |
Used by Battle_RunEncounter.
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.
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.
| Field | Declared as | |
|---|---|---|
encodedAction | u16 encodedAction | bits: 15 from the class | 14 from an equipped item | 13..0 action id. Entries with neither mark were taught for good; 0 is empty. |
unk02 | u16 unk02 | Not named by any TBS code. |
Used by OwnerAction_DiffSlots.
BattleElementStats
struct BattleElementStats
A unit's elemental power and resistance in one element.
| Field | Declared as | |
|---|---|---|
power | s16 power | Elemental power in the element. |
resistance | s16 resistance | Elemental resistance to it. |
BattleAct
struct BattleAct
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind, element, effect, range, PP cost and power.
| Field | Declared as | |
|---|---|---|
targetMode | u8 targetMode | TARGET_MODE_NONE, _FOES, _ALLIES or _SELF |
flags | u8 flags | bits: 7 usable in battle | 6 usable in the field | 5..4 clear in every row | 3..0 kind (ABILITY_KIND_MASK, enum AbilityKind). |
element | u8 element | enum Element |
effect | u8 effect | enum AbilityEffect |
unk04 | u8 unk04[4] | [0] the icon the menus draw; [1] to [3] are 0 in every row. |
range | u8 range | the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL |
ppCost | u8 ppCost | PP the ability costs |
power | u16 power | what the kind applies, 0 for none |
type0c | u8 type0c | The 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. |
unk0d | u8 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.
BattleUnit
struct BattleUnit
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
| Field | Declared as | |
|---|---|---|
name | u8 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. |
level | u8 level | 1 to 99 for a character |
baseHp | s16 baseHp | before equipment, Djinn and class (UnitCalc) |
basePp | s16 basePp | before equipment, Djinn and class (UnitCalc) |
hpGauge | s16 hpGauge | hp / maxHp in 0..0x4000; 1 while any HP remains |
ppGauge | s16 ppGauge | pp / maxPp in 0..0x4000; 1 while any PP remains |
baseAttack | u16 baseAttack | before equipment, Djinn, class and stages |
baseDefense | u16 baseDefense | before equipment, Djinn, class and stages |
baseAgility | u16 baseAgility | before equipment, Djinn, class and stages |
baseLuck | u8 baseLuck | before equipment, Djinn and class |
baseActionCount | u8 baseActionCount | Actions 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. |
baseHpRegen | u8 baseHpRegen | HP regained each turn before equipment; 0 for a character |
basePpRegen | u8 basePpRegen | PP regained each turn before equipment and lighthouses |
unk022 | u8 unk022[2] | Not named by any TBS code. |
baseElement | struct 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). |
maxHp | s16 maxHp | 0 to 1999 for a character, 9999 for an enemy (UnitCalc) |
maxPp | s16 maxPp | 0 to 1999 for a character, 9999 for an enemy (UnitCalc) |
hp | s16 hp | current HP, 0 when downed |
pp | s16 pp | current PP |
atk | u16 atk | Attack, 0 to 999 (UnitCalc) |
def | u16 def | Defense, 0 to 999 (UnitCalc) |
agi | u16 agi | Agility, 0 to 999: the order of the round's actions |
luck | u8 luck | 0 to 99 (UnitCalc) |
actionEntryCount | u8 actionEntryCount | Actions 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. |
hpRegen | u8 hpRegen | HP regained at each turn's end (UnitCalc) |
ppRegen | u8 ppRegen | PP regained at each turn's end, 0 to 200 (UnitCalc): 4 more once the lighthouse of the character's element is lit. |
unk046 | u8 unk046[2] | Not named by any TBS code. |
element | struct BattleElementStats element[4] | Power and resistance in each element, 0 to 200, after equipment, element levels and Resistance stages (UnitCalc). |
actionSlots | struct 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. |
inventory | u16 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. |
unk0f6 | u8 unk0f6[2] | Not named by any TBS code. |
djinnAvailable | u32 djinnAvailable[4] | The Djinn held, one bit per Djinni (by its index) in each element's word. |
djinnActive | u32 djinnActive[4] | The Djinn set, one bit per Djinni; only these add their stat bonuses. |
djinnOwnedCounts | u8 djinnOwnedCounts[4] | the Djinn held in each element, at most 10 |
djinnActiveCounts | u8 djinnActiveCounts[4] | the Djinn set in each element; the class's element levels are read from these |
rewards | u32 rewards | Copied 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). |
experience | u32 experience | a character's experience points |
classId | u8 classId | Who 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. |
classIndex | u8 classIndex | The character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy, and code throughout tests it to tell the two apart. |
side | u8 side | BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2). Enemies 158 to 171 are put on side 2 (BattleUnitSet). |
guardLevel | s8 guardLevel | 0, GUARD_DEFEND (1, half the damage) or GUARD_TOTAL_DEFENSE (2, a tenth); set by Defend and Granite, cleared each round. |
elementLevels | s8 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. |
restraint | s8 restraint | The 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. |
poison | s8 poison | 1 poisoned, 2 deadly poison |
attackTurns | u8 attackTurns | Each 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. @{ |
attackStage | s8 attackStage | |
defenseTurns | u8 defenseTurns | |
defenseStage | s8 defenseStage | |
resistanceTurns | u8 resistanceTurns | |
resistanceStage | s8 resistanceStage | |
delusion | u8 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. @{ |
confusion | s8 confusion | |
charm | u8 charm | |
stun | u8 stun | |
sleep | u8 sleep | |
psySeal | u8 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. |
refrain | u8 refrain | Regenerate's turns left, 7 when cast |
reflect | s8 reflect | Reflect's turns left, 7 when cast |
haunt | u8 haunt | set while an evil spirit grips the unit |
grimReaper | u8 grimReaper | The Grim Reaper's countdown: 7 when cursed, down one at each turn's end; at 0 the unit falls. |
equipBonus | u8 equipBonus[2] | The totals of equipment effects 23 (unleash chance) and 24 that UnitCalc sums; TBS never reads them back |
ready | u8 ready | Kite's extra action: 2 when cast, down one at each turn's end; while nonzero UnitCalc gives the unit one more action a round. |
immobile | u8 immobile | set by Ground: the next action is lost |
agilityTurns | u8 agilityTurns | the Agility change's turns left, 5 when cast |
agilityStage | s8 agilityStage | The Agility stage: -4 (Vine) to 8 (Zephyr, twice the Agility). |
challenge | s8 challenge | Set by the challenge effect: an enemy with it never chooses to flee. |
unk149 | u8 unk149 | Not named by any TBS code. |
enemyId | u16 enemyId | Not 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.
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_ELEMENTS | ELEMENT_NONE |
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_HP | 1 | Cure, Fizz, healing items |
ABILITY_KIND_EFFECT | 2 | damage only if the effect lands |
ABILITY_KIND_ATTACK | 3 | Attack vs Defense, plus the power |
ABILITY_KIND_ATTACK_MULTIPLIED | 4 | that attack times power / 10 |
ABILITY_KIND_DAMAGE | 5 | HP damage from the power (Psynergy) |
ABILITY_KIND_UNLEASHED_DAMAGE | 6 | an enemy's. Shown as X unleashes Y! |
ABILITY_KIND_SUMMON | 8 | the summons: damage scaled by distance |
ABILITY_KIND_PP_DAMAGE | 10 | Crazy Voice: the target loses PP |
ABILITY_KIND_HEAL_PP | 11 | Ember, Psy Crystal, Adept Ring |
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_NONE | 0 | |
ABILITY_EFFECT_CURE_POISON | 3 | Cure Poison, Antidote |
ABILITY_EFFECT_RESTORE | 4 | Restore, Elixir |
ABILITY_EFFECT_REVIVE | 5 | Revive, Water of Life: full HP |
ABILITY_EFFECT_ATTACK_UP_2 | 6 | Impact: two stages |
ABILITY_EFFECT_ATTACK_UP | 7 | High Impact: one stage |
ABILITY_EFFECT_ATTACK_DOWN_2 | 8 | Dull |
ABILITY_EFFECT_ATTACK_DOWN | 9 | Blunt |
ABILITY_EFFECT_DEFENSE_UP_2 | 10 | Guard |
ABILITY_EFFECT_DEFENSE_UP | 11 | Protect |
ABILITY_EFFECT_DEFENSE_DOWN_2 | 12 | Impair |
ABILITY_EFFECT_DEFENSE_DOWN | 13 | Debilitate |
ABILITY_EFFECT_RESISTANCE_UP_2 | 14 | Ward |
ABILITY_EFFECT_RESISTANCE_UP | 15 | Resist |
ABILITY_EFFECT_RESISTANCE_DOWN_2 | 16 | Weaken |
ABILITY_EFFECT_RESISTANCE_DOWN | 17 | Enfeeble |
ABILITY_EFFECT_POISON | 18 | Taint |
ABILITY_EFFECT_DEADLY_POISON | 19 | Poison |
ABILITY_EFFECT_DELUSION | 20 | Delude |
ABILITY_EFFECT_CONFUSION | 21 | Confuse |
ABILITY_EFFECT_CHARM | 22 | Charm |
ABILITY_EFFECT_STUN | 23 | Paralyze |
ABILITY_EFFECT_SLEEP | 24 | Sleep |
ABILITY_EFFECT_SEAL | 25 | Bind: Psynergy sealed |
ABILITY_EFFECT_HAUNT | 26 | Haunt |
ABILITY_EFFECT_INSTANT_DEATH | 27 | Condemn |
ABILITY_EFFECT_CURSE | 28 | Curse: the Grim Reaper's countdown |
ABILITY_EFFECT_REGENERATE | 29 | Regenerate |
ABILITY_EFFECT_REFLECT | 30 | Reflect |
ABILITY_EFFECT_DRAIN_HP | 31 | Drain |
ABILITY_EFFECT_DRAIN_PP | 32 | Psy Drain |
ABILITY_EFFECT_BREAK | 33 | Break: raised stats undone |
ABILITY_EFFECT_LEAVE_ONE_HP | 34 | Severe Blow, Thrash |
ABILITY_EFFECT_HALVE_DEFENSE | 35 | Torch |
ABILITY_EFFECT_CRITICAL_1_IN_64 | 36 | A 1 in 64 to 1 in 4 chance of an ability's critical hit, rolled by BattleCommand_BuildPlan. |
ABILITY_EFFECT_CRITICAL_1_IN_32 | 37 | |
ABILITY_EFFECT_CRITICAL_1_IN_16 | 38 | |
ABILITY_EFFECT_CRITICAL_1_IN_8 | 39 | |
ABILITY_EFFECT_CRITICAL_1_IN_4 | 40 | |
ABILITY_EFFECT_DOUBLE_BLOW_1_IN_8 | 41 | A chance of a double or triple blow, rolled by BattleCommand_BuildPlan. |
ABILITY_EFFECT_DOUBLE_BLOW_1_IN_4 | 42 | Double Fang, Twin Beaks |
ABILITY_EFFECT_TRIPLE_BLOW_1_IN_8 | 43 | |
ABILITY_EFFECT_TRIPLE_BLOW_1_IN_4 | 44 | Swift Strike |
ABILITY_EFFECT_THREATEN | 45 | Contain, Threaten, Tremble |
ABILITY_EFFECT_DEFEND | 46 | Defend, Granite |
ABILITY_EFFECT_TOTAL_DEFENSE | 47 | Total Defense, Flash |
ABILITY_EFFECT_FLEE | 49 | Flee |
ABILITY_EFFECT_CALL_ALLY | 50 | Ally Search, Speed Surge |
ABILITY_EFFECT_CALL_HELP | 51 | Search for Help |
ABILITY_EFFECT_GROUND | 53 | Ground: the target's turn lost |
ABILITY_EFFECT_CHALLENGE | 54 | no ability has it |
ABILITY_EFFECT_SELF_DESTRUCT | 55 | Dynamite, Mortal Blow |
ABILITY_EFFECT_REVIVE_HALF | 56 | Quartz |
ABILITY_EFFECT_REVIVE_80 | 57 | Dew: 80% of max HP |
ABILITY_EFFECT_AGILITY_DOWN | 58 | Vine |
ABILITY_EFFECT_AGILITY_UP | 59 | Zephyr |
ABILITY_EFFECT_DRAIN_HALF_HP | 60 | Sap |
ABILITY_EFFECT_HEAL_HP_60 | 61 | Fizz: 60% of max HP |
ABILITY_EFFECT_HEAL_HP_30 | 62 | Spritz: 30% |
ABILITY_EFFECT_HEAL_PP_7 | 63 | Ember: 7% of max PP |
ABILITY_EFFECT_CURE_ALL | 64 | Tonic |
ABILITY_EFFECT_DOUBLE_BLOW_60 | 65 | Gust, Rapid Smash: 153 in 256 |
ABILITY_EFFECT_ACT_TWICE | 66 | Kite |
ABILITY_EFFECT_SEAL_2_TURNS | 67 | Luff |
ABILITY_EFFECT_TRIPLE_BLOW_60 | 68 | Sonic Smash |
ABILITY_EFFECT_PSY_LEECH | 69 | Psy Leech |
BattleActionUse
enum BattleActionUse
BattleAct.flags: where an ability can be used.
| Value | = | |
|---|---|---|
ACTION_USABLE_IN_FIELD | 0x40 | can be used outside battle |
ACTION_USABLE_IN_BATTLE | 0x80 | can be used in battle; else greyed there |
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.
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.
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.
| Field | Declared as | |
|---|---|---|
object | void *object | the slot's sprite, released with the slot |
x | s32 x | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
targetX | s32 targetX | 16.16 fixed-point pixels; EFFECT_NO_TARGET at rest |
targetZ | s32 targetZ | 16.16 fixed-point pixels; EFFECT_NO_TARGET at rest |
originX | s32 originX | 16.16 fixed-point pixels; where the slot started |
originZ | s32 originZ | 16.16 fixed-point pixels; where the slot started |
speed | s32 speed | 16.16 fixed-point pixels per frame |
maxSpeed | s32 maxSpeed | 16.16 fixed-point pixels per frame |
acceleration | s32 acceleration | 16.16 fixed-point pixels per frame, each frame |
scaleX | s32 scaleX | 16.16 fixed point, 0x10000 full size |
scaleY | s32 scaleY | 16.16 fixed point, 0x10000 full size |
heading | u16 heading | 1/65536 turns |
maxTurnStep | s16 maxTurnStep | 1/65536 turns a frame |
callback | EffectCallback callback | run each frame once callbackDelay is 0 |
age | u16 age | frames |
callbackDelay | s16 callbackDelay | frames |
orbitRadius | s16 orbitRadius | pixels |
orbitAngle | s16 orbitAngle | 1/32 turns |
state | s8 state | the callback's own step; 0 when it is given |
stopAtTarget | s8 stopAtTarget | nonzero: lands on the target within 8 pixels |
limitTurnStep | s8 limitTurnStep | Clamp steering to maxTurnStep; zero faces the target directly. |
updateMotion | s8 updateMotion | nonzero: EffectSlot_UpdateMotion moves it each frame |
render | s8 render | nonzero: drawn each frame |
active | s8 active | nonzero while the slot is in use |
randomValue | u8 randomValue | random when filled; not read by name in TBS |
flags | u8 flags | bits: 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.
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.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[6] | not named through this view |
angle | u16 angle | 1/65536 turns |
unk08 | u8 unk08[0x48] | not named through this view |
records | struct AnimationObject *records | the caster's sprite |
unk54 | u8 unk54[0x10] | not named through this view |
phase | s16 phase | 1 spins the caster 0xc00 a frame |
step | s16 step | frames since the arcs started |
linkedObject | struct FieldActor *linkedObject | |
callback | void (*callback)(union FieldObject *object) | run each frame |
Used by BattleFx_UpdatePairedArcSpawner, FieldFx_BlinkAvoidCaster, FieldFx_RunAvoid.
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.
| Field | Declared as | |
|---|---|---|
angle | s32 angle | 1/65536 turns |
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
mainObject | void *mainObject | the caster's object |
child | void *child | the target's object, or NULL |
firstObjectId | s16 firstObjectId | the caster's object id |
secondObjectId | s16 secondObjectId | the target's object id, -1 for none |
action | u16 action | the ability id |
fieldKind | s16 fieldKind | the ability's field kind (FIELD_KIND_) |
enabled | s8 enabled | Set at the start: Force then aims in front of the caster; cleared once the target has been dispatched. |
mode | u8 mode | where the effect runs; MODE_WORLD_MAP on the world map |
visible | s8 visible | set at the start: the caster flashes with a sound |
active | s8 active | set at the start: the ability's name is announced |
finishCallback | void (*finishCallback)(void) | run, when set, as Ply's effect ends |
unk28 | u8 unk28[0x0c] | not named by TBS code |
childOption | s8 childOption | Set by some scenes before an effect; Carry, Frost, Force and Reveal treat the target differently with it. |
childMode | s8 childMode | set by some scenes: Frost and Force leave the target be |
unk36 | u8 unk36[2] | not named by TBS code |
savedCallback | void (*savedCallback)(union FieldObject *object) | The target's update hook and script, saved at the start and restored when Move or Carry lets it go. @{ |
savedScript | const s32 *savedScript | |
unk40 | u8 unk40[4] | @} not named by TBS code |
savedPalette | u8 savedPalette | the target's first sprite's param, saved likewise |
lit | u8 lit | set in two Mercury Lighthouse maps; not read by name |
tileSlot | u16 tileSlot | resource entry holding the spark tiles |
unk48 | u16 unk48 | not named by TBS code |
freeBlocks | u16 freeBlocks | 512 less the free resource blocks at the start |
savedShakeX | s32 savedShakeX | The map's shake and its decay, restored when the effect ends. @{ |
savedShakeY | s32 savedShakeY | |
savedShakeDecay | s32 savedShakeDecay | |
slots | struct EffectSlot slots[24] | @} |
unk718 | u8 unk718[2] | not named by TBS code |
arcTileSlot | s16 arcTileSlot | resource entry of Avoid's and Retreat's arcs |
messageMode | s8 messageMode | the announcement's box mode: 1, a scene adds 8 |
unk71d | u8 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.
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.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[0x06] | ScriptMotionObject's script and scriptCursor |
angle | u16 angle | 1/65536 turns |
x | s32 x | 16.16 fixed-point pixels |
y | s32 y | 16.16 fixed-point pixels |
z | s32 z | 16.16 fixed-point pixels |
unk14 | u8 unk14[0x04] | FieldActor's terrainHeight, the ground's y |
scaleX | s32 scaleX | 16.16 fixed point, 0x10000 full size |
scaleY | s32 scaleY | 16.16 fixed point, 0x10000 full size |
height | u16 height | half the sprite's box height; FieldActor's radius |
unk22 | u8 unk22[0x02] | FieldActor's terrainId and priorityFlags |
velocityX | s32 velocityX | 16.16 fixed-point pixels per frame |
velocityY | s32 velocityY | 16.16 fixed-point pixels per frame |
velocityZ | s32 velocityZ | 16.16 fixed-point pixels per frame |
speedLimit | s32 speedLimit | 16.16 fixed-point pixels per frame |
acceleration | s32 acceleration | Horizontal speed gained each frame towards the target, or lost braking without one, in 16.16 fixed-point pixels per frame. |
targetX | s32 targetX | 16.16 fixed-point pixels; 0x80000000 for no target |
targetY | s32 targetY | 16.16 fixed-point pixels |
targetZ | s32 targetZ | 16.16 fixed-point pixels |
verticalMotionPhase | s32 verticalMotionPhase | With 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). |
verticalMotionStrength | s32 verticalMotionStrength | Gravity: 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. |
unk4c | u8 unk4c[0x04] | FieldActor's riseBaseY |
records | void *records | one sprite, or a table of up to four (recordStorageKind) |
recordStorageKind | u8 recordStorageKind | bits: 3..0 RECORDS_NONE, RECORDS_SINGLE or RECORDS_TABLE |
motionFlags | u8 motionFlags | bits: 4 no terrain slowdown | 3 bigger float | 2 floats | 1 falls | 0 follows terrain |
unk56 | u8 unk56[0x02] | ScriptMotionObject's arrivalAxis and unk57 |
snapToTarget | u8 snapToTarget | nonzero: lands exactly on the target, else brakes in |
unk59 | u8 unk59 | FieldActor's collisionFlags; battle units set 3 |
autoFaceMotion | u8 autoFaceMotion | bit 0 turns the object to face where it moves |
unk5b | u8 unk5b[0x11] | FieldActor's paused, timer, linkedObject and the bytes between; not named by TBS code through this view. |
update | void (*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.
SpriteEntry
struct SpriteEntry
A sprite of an animation record, as battle objects set its palette and drawing priority.
| Field | Declared as | |
|---|---|---|
unk00 | u8 unk00[5] | |
palette | u8 palette | |
priority | u8 priority |
Used by BattleActor_SpawnObjectsForList, BattleActor_UpdateSpritePriorities, BattleStatusIcon_Cycle.
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.