Alchemy
Loading...
Searching...
No Matches

auto_battle.c

Go to the documentation of this file.
1/// @file
2/// Auto battle: the actions it builds and plays, without the command menu.
3/// Part of battle.c, the battle object, compiled only through it.
4
6
7/// Auto battle: gives every living unit a plain attack and sorts them into
8/// turn order. The party act at their Agility and target the first enemy;
9/// enemies act at half their Agility plus a random part of it and target a
10/// random party member. Returns how many actions there are. Called by
11/// Battle_RunEncounter each round under FLAG_AUTO_BATTLE; fills entries.
13 struct BattleActionRecord *entries) {
14 struct BattleActionRecord swap;
15 u16 unitIds[14];
16 s32 partyCount;
17 s32 count = 0;
18 s32 enemyCount;
19 s32 targetRange;
20 s32 index;
21 struct BattleActionRecord *entry;
22 struct BattleUnit *unit;
23
24 // The party's actions. The four lookups' results are never used.
26 for (index = 0; index != 4; index++)
27 UnitGetFar(index);
28 for (index = 0; index < partyCount; index++) {
29 s32 unitId = unitIds[index];
30
31 unit = UnitGetFar(unitId);
32 entry = &entries[index];
33 entry->unitId = unitId;
34 entry->priority = unit->agi;
35 entry->command = CMD_ATTACK;
36 entry->parameter = 0;
37 entry->target = FIRST_ENEMY_UNIT;
38 count++;
39 }
40 // The enemies' actions. Random16() * n >> 16 is a roll from 0 to n - 1;
41 // the target is that number taken as a unit id, which BattlePres_RunAction
42 // replaces if the unit is down.
44 entry = &entries[partyCount];
46 for (index = 0; index < enemyCount; index++) {
47 s32 unitId = unitIds[index];
48
49 unit = UnitGetFar(unitId);
50 entry->unitId = unitId;
51 entry->priority = unit->agi >> 1;
52 if (entry->priority != 0)
53 entry->priority += (Random16() * unit->agi) >> 16;
54 entry->command = CMD_ATTACK;
55 entry->parameter = 0;
56 entry->target = (Random16() * targetRange) >> 16;
57 count++;
58 entry++;
59 }
60
61 // Bubble the faster units forward until a pass swaps nothing.
62 // BUG: count - 2 passes at most, one short of a full sort; with two
63 // actions nothing is sorted.
64 for (index = count - 2; index > 0; index--) {
65 s32 swaps = 0;
66 s32 pos;
67
68 for (pos = count - 1; pos > 0; pos--) {
69 if ((s16)entries[pos].priority > (s16)entries[pos - 1].priority) {
70 Dma_Set(&entries[pos], &swap, DMA_COPY_WORDS(4), REG_DMA3);
71 Dma_Set(&entries[pos - 1], &entries[pos], DMA_COPY_WORDS(4), REG_DMA3);
72 Dma_Set(&swap, &entries[pos - 1], DMA_COPY_WORDS(4), REG_DMA3);
73 swaps++;
74 }
75 }
76 if (swaps == 0)
77 break;
78 }
79 return count;
80}
81
82/// Turns the camera while L or R is held. Nothing in the source calls it.
84
85/// Auto battle: plays one action. A unit already down does nothing (-1);
86/// a defeated target is replaced by a living unit of its side first.
87/// Returns 1 when the party got away, 0 otherwise. Called by
88/// Battle_RunEncounter for each action under FLAG_AUTO_BATTLE. Turns the
89/// camera to the actor's side (gTransitionWork) and rewrites action->target.
91 struct BattlePresentationTransition *transition;
92 s32 actorId;
93 s32 yaw;
94 struct BattleUnit *actor;
95
96 actorId = action->unitId;
97 actor = UnitGetFar(actorId);
98 if (actor->hp == 0)
99 return -1;
100
101 action->target = BattleTarget_ReplaceDefeated(action);
102 transition = gTransitionWork;
103 // Here any unit id above 4 counts as an enemy.
104 if (action->unitId > 4)
105 yaw = YAW_ENEMY_TURN;
106 else
107 yaw = YAW_PARTY_TURN;
108 transition->targetYaw = yaw;
109 transition->frames = 60;
111
112 switch (action->command) {
113 case CMD_FLEE:
115 if (BattleEscape_PlayRun(action) != 0)
116 return 1;
117 break;
118 case CMD_DEFEND:
119 WaitFrames(45);
121 break;
122 case CMD_ITEM:
123 WaitFrames(45);
125 break;
126 case CMD_ATTACK:
127 default: {
129 transition->flag = 0;
131 transition->flag = 0;
132 break;
133 }
134 case CMD_PSYNERGY:
136 break;
137 }
138
140 return 0;
141}
142
143/// Returns 0 for a party member's or an enemy's unit id, -1 for any other.
144/// Called by the auto battle's action players.
146 if (unitId <= 7) {
147 return 0;
148 }
149 if (unitId - FIRST_ENEMY_UNIT < ENEMY_BATTLE_SIZE) {
150 return 0;
151 }
152 return -1;
153}
154
155/// Auto battle: the party tries to run, and gets away 15 times in 16, each
156/// living member running off in turn. Returns 1 when they got away; else
157/// shows MsgCannotEscape and returns 0. Called by BattlePres_RunAction.
159 s16 partyMembers[14];
160 s32 partySize;
161 s32 animated;
162 s32 memberSlot;
163
164 (void)action;
165 // The roll's top four bits: escape unless all are clear, 15 in 16.
166 if (((Random16() << 4) >> 16) != 0) {
167 partySize = BattleParty_ListLivingUnits(BATTLE_SIDE_PARTY, partyMembers);
168 animated = 0;
169 if (partySize != 0) {
170 memberSlot = 0;
171 do {
172 BattleMotion_SetupEscapeObject(partyMembers[memberSlot]);
173 animated++;
174 WaitFrames(8);
175 memberSlot++;
176 } while (animated != partySize);
177 }
178 WaitFrames(22);
179 return 1;
180 }
181 UiText_ShowMessageAndWaitCoreFar(MsgCannotEscape);
182 return 0;
183}
184
185/// Auto battle: shows that a standing unit is defending. The message is
186/// `<unit> is defending`. Returns -1 for an invalid unit id, 0 otherwise.
187/// Called by BattlePres_RunAction.
189 s32 unitId;
190 s32 result;
191 struct BattleUnit *unit;
192
193 unitId = action->unitId;
194 unit = UnitGetFar(unitId);
195 if (BattleObject_IsValidId(unitId) < 0) {
196 return -1;
197 }
198 result = 0;
199 if (unit->hp <= 0) {
200 return result;
201 }
204 UiText_ShowMessageAndWaitCoreFar(MsgActorDefends);
205 return 0;
206}
207
208/// Auto battle: casts Psynergy. The camera turns to the caster's side and
209/// the caster raises its hand; the target side fades out, its living units
210/// are readied alone, the Psynergy's effect (kind action->parameter) plays
211/// on them, and everyone fades back in. Returns -1 for an invalid actor or
212/// target. Called by BattlePres_RunAction for CMD_PSYNERGY. Writes
213/// REG_BLDCNT and REG_BLDALPHA and the actors' record modes, and leaves the
214/// battle objects readied again.
216 struct BattleActionRecord *action) {
217 u16 visibleUnits[14];
218 struct BattlePresentationWork context;
219 s32 actorId;
220 s32 targetId;
221 u32 sideStart;
222 u32 sideCount;
223 u32 livingCount;
224 struct MotionObject *actorRecord;
225 u32 index;
226
227 livingCount = 0;
228 actorId = action->unitId;
229 if (BattleObject_IsValidId(actorId) < 0) {
230 return -1;
231 }
232 targetId = action->target;
233 if (BattleObject_IsValidId(targetId) < 0) {
234 return -1;
235 }
236
237 {
239 // An enemy caster turns the camera to 0x5000, not YAW_ENEMY_TURN.
240 transition->targetYaw = action->unitId > 4 ? 0x5000 : YAW_PARTY_TURN;
241 transition->frames = 60;
242 }
243 WaitFrames(10);
244 // A roll nothing uses, which still advances the random sequence.
245 Random16();
246 actorRecord = BattleObjGet(actorId)->object;
247
248 // The caster's side: its pose when the caster is among them.
249 if (targetId >= 0 && targetId <= 7) {
250 sideCount = BattleParty_ListLivingUnits(BATTLE_SIDE_ENEMIES, visibleUnits);
251 sideStart = FIRST_ENEMY_UNIT;
252 } else {
253 sideCount = BattleParty_ListLivingUnits(BATTLE_SIDE_PARTY, visibleUnits);
254 sideStart = 0;
255 }
256
257 for (index = 0; index != sideCount; index++) {
258 if (index + sideStart == actorId) {
259 ObjectDispatch_SelectAnimationFar(actorRecord, 3);
260 }
261 }
262
263 // Fade the caster's side out.
264 WaitFrames(30);
266 for (index = 0; index != sideCount; index++) {
267 BattlePres_SetActorRecordMode(index + sideStart, 1);
268 }
269 for (index = 0; index != 16; index++) {
270 REG_BLDALPHA = BLEND_ALPHA(16 - index, 16);
271 WaitFrames(1);
272 }
274
275 // Ready only the target side's living units, and play the effect. The
276 // walk counts unit ids up from the side's first until it has found as
277 // many living units as the side has.
278 if (targetId > FIRST_ENEMY_UNIT - 1) {
280 for (index = 0; livingCount != count; index++) {
281 u32 unit = index + FIRST_ENEMY_UNIT;
282 if (UnitGetFar(unit)->hp > 0) {
283 visibleUnits[livingCount++] = unit;
284 }
285 }
286 } else {
288 for (index = 0; livingCount != count; index++) {
289 if (UnitGetFar(index)->hp > 0) {
290 visibleUnits[livingCount++] = index;
291 }
292 }
293 }
294 visibleUnits[livingCount] = BATTLE_UNIT_LIST_END;
295 BattleActor_SpawnObjectsForList(visibleUnits, 0);
296
297 context.effect.kind = action->parameter;
298 context.effect.actor = actorId;
299 for (index = 0; index != livingCount; index++) {
300 context.effect.actors[index] = visibleUnits[index];
301 }
302 context.effect.count = livingCount;
303 if (targetId >= 0 && targetId <= 7) {
304 context.effect.side = 1;
305 } else {
306 context.effect.side = 0;
307 }
309
310 // Bring every unit back and fade the caster's side in.
311 WaitFrames(10);
312 BattleObjPut();
314 for (index = 0; index != sideCount; index++) {
315 BattlePres_SetActorRecordMode(index + sideStart, 1);
316 }
317 for (index = 0; index != 16; index++) {
318 REG_BLDALPHA = BLEND_ALPHA(index, 16);
319 WaitFrames(1);
320 }
321 for (index = 0; index != sideCount; index++) {
322 BattlePres_SetActorRecordMode(index + sideStart, 0);
323 }
324 BattlePres_SetupTransitionScene(0, 0, 0, 0x64);
325 WaitFrames(3);
326 return 0;
327}
328
329/// Auto battle: an attack. Shows `<unit> attacks!`, sends the attacker up
330/// to its target, plays the blow and sends both back. Returns -1 for an
331/// invalid attacker or target. Nothing in the source calls it.
333 struct BattlePresentationWork work;
334
335 // A short wait when the camera already faces the party's turn.
338 WaitFrames(10);
339 } else {
341 WaitFrames(30);
342 }
343
344 work.effect.actor = input->unitId;
345 if (BattleObject_IsValidId(work.effect.actor) < 0)
346 return -1;
347
348 work.effect.actors[0] = input->target;
349 if (BattleObject_IsValidId(work.effect.actors[0]) < 0)
350 return -1;
351
352 // Lookups whose results are unused, and a roll that only advances the
353 // random sequence.
354 UnitGetFar(work.effect.actor);
355 UnitGetFar(work.effect.actors[0]);
356 Random16();
358 UiText_ShowMessageAndWaitCoreFar(MsgActorAttacks);
361 (struct DispatchObject *)BattleObjGet(work.effect.actor)->object, 16);
362 BattleObjGet(work.effect.actors[0]);
363
364 work.effect.count = 1;
365 if ((u16)work.effect.actors[0] <= 7)
366 work.effect.side = 1;
367 else
368 work.effect.side = 0;
369 work.effect.prelude = 0;
370
371 WaitFrames(4);
373 ObjMotRst(work.effect.actors[0]);
374 ObjMotRst(work.effect.actor);
375 return 0;
376}
377
378/// Auto battle: an attack or an item. Turns the camera to the actor's side,
379/// poses the actor and plays the effect (kind action->parameter) on the
380/// first living unit of the target's side, then sends both back. Returns -1
381/// for an invalid actor. Called by BattlePres_RunAction for CMD_ATTACK,
382/// CMD_ITEM and any other command but fleeing, defending and Psynergy.
384 struct BattlePresentationWork work;
386 struct MotionObject *object;
387 s32 targetYaw;
388 s32 targetIndex;
389
390 if (action->unitId > 4)
391 targetYaw = YAW_ENEMY_TURN;
392 else
393 targetYaw = YAW_PARTY_TURN;
394 if (transition->targetYaw == targetYaw) {
395 transition->frames = 40;
396 WaitFrames(40);
397 } else {
398 transition->targetYaw = targetYaw;
399 transition->frames = 40;
400 WaitFrames(40);
401 }
402 work.effect.kind = action->parameter;
403 work.effect.range = action->range;
404 work.effect.actor = action->unitId;
405 work.effect.firstTarget = action->target;
406 if (BattleObject_IsValidId(work.effect.actor) < 0)
407 return -1;
408 if (work.effect.firstTarget > FIRST_ENEMY_UNIT - 1)
409 work.effect.count =
411 else
412 work.effect.count =
415 // The actor raises its hand (pose 3); then only the first living unit of
416 // the target's side takes the effect.
417 object = BattleObjGet(work.effect.actor)->object;
420 if ((u16)action->target <= 7) {
421 work.effect.side = 1;
423 work.effect.count = 1;
424 } else {
425 work.effect.side = 0;
427 work.effect.count = 1;
428 }
429
430 // Keep each target's sprite entries' parameters for the effect.
431 for (targetIndex = 0; targetIndex != work.effect.count; targetIndex++) {
432 struct AnimationObject *animation =
433 BattleObjGet(work.effect.actors[targetIndex])->object->records;
434 s32 entryIndex;
435
436 for (entryIndex = 0; entryIndex != animation->count - 1; entryIndex++)
437 work.savedAnimationParameters[targetIndex][entryIndex] =
438 animation->entries[entryIndex]->param;
439 }
440 /* FAKEMATCH(one-pass): the five effects in a one-pass block, which places
441 * each call's argument before its kind's store; as plain statements, 43 of
442 * 180 instructions differ in tbs-en. */
443 do {
444 work.effect.kind = 0;
445 work.effect.variant = 0;
447 work.effect.kind = 1;
449 work.effect.kind = 2;
451 work.effect.kind = 3;
453 work.effect.kind = 0;
456 } while (0);
457 for (targetIndex = 0; targetIndex != work.effect.count; targetIndex++)
458 ObjMotRst(work.effect.actors[targetIndex]);
459 ObjMotRst(work.effect.actor);
460 return 0;
461}
462
463/// Auto battle: deals damage HP to unit unitId and shows it. When showMessage
464/// is set, "A bitter blow!" (to the party) or "A critical hit!" (to an enemy)
465/// comes first; then `<unit> takes <damage> damage!`, and `<unit> goes down...`
466/// or `<unit> has been downed!` when the HP runs out.
467/// context, if null, is replaced by four cleared bytes nothing reads.
468/// Nothing in the source calls it. Lowers unit->hp, no lower than 0.
469void BattlePresentation_ApplyUnitDamage(u32 unitId, s32 damage, s32 showMessage,
470 u8 *context) {
471 u8 localContext[4];
472 struct BattleUnit *unit;
473 struct BattleObj *battleObject;
474
475 if (context == 0) {
476 context = localContext;
477 context[0] = 0;
478 context[1] = 0;
479 context[2] = 0;
480 context[3] = 0;
481 }
482
483 unit = UnitGetFar(unitId);
484 unit->hp -= damage;
485 if (unit->hp < 0)
486 unit->hp = 0;
487
488 battleObject = BattleObjGet(unitId);
492
493 if (unitId <= 7) {
494 if (showMessage != 0)
499 } else {
500 if (showMessage != 0)
506 }
507
509 if (unitId <= 7) {
510 if (unit->hp <= 0) {
513 }
514 } else if (unit->hp <= 0) {
517 }
518
519 battleObject = BattleObjGet(unitId);
521}
522
523/// For a unit whose HP has run out: plays its falling animation to the last
524/// frame and marks its object for release (BattleObj_MarkForRelease).
525/// Called by BattlePresentation_ApplyUnitDamage.
527 struct AnimationEntry *actorData;
528 struct AnimationObject *object;
529 if (UnitGetFar(unitId)->hp <= 0) {
530 // Animation 5, its first entry set to frame 0xff, past its last.
531 object = BattleObjGet(unitId)->object->records;
533 actorData = object->entries[0];
534 actorData->param = 6;
535 actorData->frame = 0xFF;
536 WaitFrames(4);
539 }
540}
541
542/// BattleTarget_ReplaceDefeated's result when the target's side is all down.
543#define TARGET_SIDE_DEFEATED 0x100
544
545/// Returns the action's target, or a random living unit of its side when
546/// the target is down; TARGET_SIDE_DEFEATED when none is left. Called by
547/// BattlePres_RunAction.
549 u16 livingUnits[14];
550 s32 targetId;
551 s32 livingCount;
552
553 targetId = action->target;
554 if (UnitGetFar(targetId)->hp != 0) {
555 return targetId;
556 }
557
558 if (targetId > FIRST_ENEMY_UNIT - 1) {
559 livingCount = BattleParty_ListLivingUnits(BATTLE_SIDE_ENEMIES, livingUnits);
560 } else {
561 livingCount = BattleParty_ListLivingUnits(BATTLE_SIDE_PARTY, livingUnits);
562 }
563
564 if (livingCount == 0) {
566 }
567
568 return (s16)livingUnits[(Random16() * livingCount) >> 0x10];
569}
s32 BattlePres_RunUnitAction(struct BattleActionRecord *action)
Auto battle: an attack or an item.
void BattlePres_AdjustCameraByShoulderKeys(void)
Turns the camera while L or R is held. Nothing in the source calls it.
Definition auto_battle.c:83
void BattleMotion_SetMode5AndActivateSlot(s32 unitId)
For a unit whose HP has run out: plays its falling animation to the last frame and marks its object f...
s32 BattleObject_IsValidId(u32 unitId)
Returns 0 for a party member's or an enemy's unit id, -1 for any other.
s32 BattlePres_RunApproachAction(struct BattleActionRecord *input)
Auto battle: an attack.
s32 BattleTarget_ReplaceDefeated(const struct BattleActionRecord *action)
Returns the action's target, or a random living unit of its side when the target is down; TARGET_SIDE...
#define TARGET_SIDE_DEFEATED
BattleTarget_ReplaceDefeated's result when the target's side is all down.
s32 BattleEscape_PlayRun(struct BattleActionRecord *action)
Auto battle: the party tries to run, and gets away 15 times in 16, each living member running off in ...
void BattlePresentation_ApplyUnitDamage(u32 unitId, s32 damage, s32 showMessage, u8 *context)
Auto battle: deals damage HP to unit unitId and shows it.
s32 BattlePres_ShowDefendMessage(const struct BattleActionRecord *action)
Auto battle: shows that a standing unit is defending.
s32 BattlePresentation_BuildSortedUnitEntries(struct BattleActionRecord *entries)
Auto battle: gives every living unit a plain attack and sorts them into turn order.
Definition auto_battle.c:12
s32 BattlePres_RunAction(struct BattleActionRecord *action)
Auto battle: plays one action.
Definition auto_battle.c:90
s32 BattlePresentation_RunPairedUnitTransition(struct BattleActionRecord *action)
Auto battle: casts Psynergy.
void BattlePres_SetActorRecordMode(s32 actorId, s32 mode)
Sets the OBJ mode (1 semi-transparent, 0 normal) of every sprite of a unit's battle object,...
Definition background.c:515
void BattlePres_SetupTransitionScene(s32 x, s32 depth, s32 y, s32 zoom)
Points the battle camera at (x, depth, y) with a zoom in percent, and lines the perspective plane up ...
Definition background.c:359
s32 BattleParty_ListLivingUnits(s32 sideMask, u16 *unitIds)
Lists the units still standing (HP above 0) on the sides in sideMask (BATTLE_SIDE_PARTY,...
Definition encounter.c:437
void BattleActor_SpawnObjectsForList(s16 *unitIds, s32 refreshPoses)
Readies the sprites of the units in list: releases those of every place list lacks,...
Definition objects.c:356
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
Definition objects.c:480
s32 BattleObj_MarkForRelease(s32 unitId)
Frees the enemy sprite slots unitId holds and marks its object for release at the end of the round (B...
Definition objects.c:543
void BattleObjPut(void)
Readies the sprite of every unit in the battle (releasing those of units that left) and sets each one...
Definition sprites.c:13
struct BattlePresentationTransition * gTransitionWork
What every part of the battle object shares: its includes, in their original order,...
#define VALUE_UNIT_NAME
#define VALUE_NUMBER
#define BLEND_SPRITES_OVER_ALL
REG_BLDCNT: blend the semi-transparent sprites (OBJ mode 1) over every layer, to fade them.
#define FIRST_ENEMY_UNIT
Unit ids from 128 are the enemies'; in a link battle the opponent's party takes the first three.
#define YAW_PARTY_TURN
The camera's yaw while a party member acts, and while an enemy does.
#define YAW_ENEMY_TURN
#define ENEMY_BATTLE_SIZE
@ BATTLE_UNIT_LIST_END
ends the list
@ BATTLE_SIDE_PARTY
@ BATTLE_SIDE_ENEMIES
@ CMD_DEFEND
@ CMD_ITEM
@ CMD_PSYNERGY
@ CMD_ATTACK
@ CMD_FLEE
struct BattleWork * gBattleWork
static __inline__ void Dma_Set(const volatile void *source, volatile void *destination, u32 control, volatile u32 *channel)
Starts a DMA transfer: stores the source, destination and control words into channel's registers with...
Definition dma.h:62
void BattleFx_RunTableEffectFar(struct BattleEffectArgument *effect)
void BattleFx_RunSceneEffectFar(struct BattleEffectArgument *effect)
void BattleFx_RunElementPillarFar(struct BattleEffectArgument *effect)
void BattleFx_DispatchByIdRangeFar(struct BattleEffectArgument *effect)
s32 AnimationObjects_SelectAnimationFar(struct AnimationObject *state, s32 flags)
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
void Map_RenderAnimatedTileFramesForObjectFar(u8 *obj)
struct BattleUnit * UnitGetFar(u32 owner)
void PartyStatusDrawFar(s32 flags)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiText_ShowMessageAndWaitCoreFar(s32 argument)
void UiWork_ResetFreeChannelFar(void)
void UiWork_ClearValueNameTablesFar(void)
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
Definition frame.c:97
#define REG_DMA3
Definition io_reg.h:153
#define BLEND_ALPHA(top, bottom)
A REG_BLDALPHA value: top and bottom are the two targets' weights, out of 16.
Definition io_reg.h:145
#define DMA_COPY_WORDS(n)
Definition io_reg.h:226
#define REG_BLDALPHA
Definition io_reg.h:142
#define REG_BLDCNT
Definition io_reg.h:119
u32 Random16(void)
Advances the game's random number generator (the C library's classic linear congruential one),...
Definition math.c:10
void BattleMotion_ApproachTarget(s32 actorId, s32 targetId, s32 travelDivisor, s32 initialVelocityY)
Sends unit actorId three quarters of the way to unit targetId, arriving in travelDivisor steps,...
Definition motion.c:191
void ObjMotRst(s32 unitId)
Sends unitId back to its spot, landing there, and turns it to face the centre.
Definition motion.c:17
void BattleMotion_SetupEscapeObject(s32 unitId)
Sends unitId running off its side of the battlefield, three times as far out as its spot,...
Definition motion.c:46
#define NULL
Definition bilibin.h:6
One animation layer of a sprite: its animation id, frames, running script and timer.
Definition animspr.h:37
u8 param
SpriteColorMode its pixels are drawn with; 0 when taken.
Definition animspr.h:45
u8 frame
frame shown, frameBase plus the facing offset; 255 none
Definition animspr.h:53
An animated sprite: its image and shadow, scale, rotation, size and up to four animation layers.
Definition animspr.h:108
struct AnimationEntry * entries[4]
its layers; empty ones null
Definition animspr.h:130
u8 count
layers in use, up to the last one present
Definition animspr.h:129
A unit's chosen action for the turn: its command, the command's parameter, its target and range,...
s16 target
the aimed unit's id
s16 parameter
an ability id, or CMD_ITEM's inventory index (-1 gone)
s16 command
enum BattleCommand
s16 range
the action's range
u16 priority
from the unit's Agility; higher acts first
s32 range
forwarded action range, otherwise initialized to 1
s32 actor
the user's unit id
s32 side
1 when the targets are the party, 0 for enemies
s32 kind
handler table index; 200 more for a critical hit
s16 actors[8]
the targets' unit ids, count of them
s32 variant
the ability's size, from 0 (Quake, then Earthquake)
s32 count
targets in actors, at least 1
s32 prelude
1 plays a prelude: in some effects a Djinni appears
s32 firstTarget
the action's first target, standing or not
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct MotionObject * object
NULL once released.
The battle background's work slot as the camera reads it: the yaw the camera eases toward and the fra...
s32 frames
frames left to ease the yaw, a sixteenth a frame
s32 flag
0 lets the camera update set the background's range each frame; 1 for a critical hit's zoom and once ...
The effect updates its command while the presentation keeps animation state.
struct BattleEffectArgument effect
u8 savedAnimationParameters[8][4]
Each target's animation entries' param, saved before the effect.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
s16 hp
current HP, 0 when downed
u16 agi
Agility, 0 to 999: the order of the round's actions.
u8 partyStatus
PARTY_STATUS_SUMMONS or PARTY_STATUS_NO_SUMMONS.
Definition battle_work.h:86
A field object as the object dispatcher's far calls take it.
An effect object that moves and draws one sprite: its position, scale, velocity and target,...
Definition motobj.h:20
void * records
one sprite, or a table of up to four (recordStorageKind)
Definition motobj.h:50
signed int s32
Definition types.h:14
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11
#define DEFINE_ADJUST_CAMERA(name)
Moves camera yaw by 512 while L/R is held; two identical functions exist.
Definition battle.h:67