8#define SPRITE_ISAAC_MACHETE 480
9#define SPRITE_GARET_MACHETE 482
12#define SCALE_ONE 0x10000
15#define BATTLE_OBJ_NO_EFFECT 0x1fe
53 if (registeredSprite == 0)
56 sprite = registeredSprite;
76 if (unitId < 0 || unitId > 7)
87 actor->
scale = 0x19999;
90 actor->
scale = 0x18ccc;
93 actor->
scale = 0x13333;
96 actor->
scale = 0x19999;
99 actor->
scale = 0x18000;
102 actor->
scale = 0x1cccc;
105 actor->
scale = 0x1cccc;
108 actor->
scale = 0x10000;
111 actor->
scale = 0x1b333;
114 actor->
scale = 0x18000;
117 actor->
scale = 0x18000;
120 actor->
scale = 0x18000;
123 actor->
scale = 0x18000;
126 actor->
scale = 0x18000;
129 actor->
scale = 0x18000;
132 actor->
scale = 0x18000;
135 actor->
scale = 0x18000;
138 actor->
scale = 0x18000;
141 actor->
scale = 0x13333;
144 actor->
scale = 0x13333;
147 actor->
scale = 0x16666;
150 actor->
scale = 0x10000;
153 actor->
scale = 0x14000;
156 actor->
scale = 0x16666;
159 actor->
scale = 0x16666;
162 actor->
scale = 0x18000;
165 actor->
scale = 0x14ccc;
168 actor->
scale = 0x13333;
171 actor->
scale = 0x10ccc;
174 actor->
scale = 0x10ccc;
177 actor->
scale = 0x11999;
180 actor->
scale = 0x11999;
183 actor->
scale = 0x13333;
186 actor->
scale = 0x13333;
189 actor->
scale = 0x18000;
192 actor->
scale = 0x13333;
195 actor->
scale = 0x18000;
198 actor->
scale = 0x18ccc;
201 actor->
scale = 0x14000;
204 actor->
scale = 0x14000;
220 actor->
scale = 0xe666;
241 if (classId <=
GARET &&
256 facingAngle =
ArcTan2(
y / 8,
x) + 0x8000;
257 object->angle = facingAngle;
259 object->motionFlags = 2;
261 object->scaleX = 0x14ccc;
262 object->scaleY = 0x14ccc;
282#define IS_PLACEHOLDER_ID(id) ((u16)((id) - BATTLE_UNIT_REMOVED) <= 1)
292 s32 totalSpacing = count <= 4 ? 30 : 27;
293 s32 z = ((count - 1) * totalSpacing) / 2;
298 for (index = 0; index != count; index++) {
301 xPositions[index] = -80;
310 xPositions[index] = -50;
315 zPositions[index] = z;
360 unitIds[enemyIndex] = battle->
enemyIds[enemyIndex];
361 enemyCount = enemyIndex;
363 for (enemyIndex = 0; enemyIndex < enemyCount; enemyIndex++) {
369 object->anchorX = xPositions[enemyIndex] * 65536;
370 object->anchorZ = zPositions[enemyIndex] * 65536;
398 placementValue = 0xff;
399 for (unitIndex = 13; unitIndex >= 0; unitIndex--)
400 battle->
placement[unitIndex] = placementValue;
401 placementCursor = &battle->
placement[13];
402 for (remainingPlaces = 5, placementValue = 13; remainingPlaces >= 0;
403 remainingPlaces--, placementValue--)
404 *placementCursor-- = placementValue;
407 for (unitIndex = 0; unitIndex < count; partyPlace++, unitIndex++) {
408 s32 unitId = unitIds[unitIndex];
420 unitIds[unitIndex] = battle->
enemyIds[unitIndex];
423 for (unitIndex = 0; unitIndex < count; unitIndex++, enemyPlace++) {
428 zPositions[enemyPlace]);
444 u16 unitId = *list++;
450 }
while (++listIndex < 14);
s32 BattleClass_GetPalette(s32 index)
Returns the class's sprite palette.
s32 BattleClass_IsSmall(s32 index)
Returns 1 for a small class, which takes one enemy sprite slot instead of two and stands closer to it...
s32 BattleClass_GetSprite(s32 index)
Returns the class's battle sprite, row 0's for a class out of range.
s32 BattleParty_PrepareActiveOwners(u16 *owners)
Lists the party members who fight (the first four of the party, three in a link battle) and marks eac...
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
s32 SummonSlot_RegisterActorSprites(s32 unitId)
Loads an enemy unit's battle sprite into the first free enemy sprite slots (one for a small enemy,...
s32 BattleUnit_LookupWeaponValueByClass(s32 unitId)
Returns the weapon sprite a party member's attack shows for the kind of weapon they have equipped (gB...
const s32 gBattlePres_ActorObjectScript[]
const s8 gBattlePlacement_StepPairs[]
What every part of the battle object shares: its includes, in their original order,...
#define FIRST_ENEMY_UNIT
Unit ids from 128 are the enemies'; in a link battle the opponent's party takes the first three.
#define EQUIP_WEAPON
The inventory's weapon slot, for Inventory_FindEquippedFar.
#define ENEMY_BATTLE_SIZE
@ BATTLE_UNIT_LIST_END
ends the list
@ BATTLE_UNIT_REMOVED
a place whose unit has left the battle
struct BattleWork * gBattleWork
#define BATTLE_CHARACTER(no)
the character's battle sprite
struct ObjectRuntime * Object_CreateFar(s32 id, s32 x, s32 y, s32 z)
Far call to FieldObject_Create.
void ObjectDispatch_InitializeFar(struct DispatchObject *obj, const s32 *script)
struct BattleUnit * UnitGetFar(u32 owner)
s32 Inventory_GetEquippedItemFar(struct BattleUnit *inv, s32 type)
s32 ArcTan2(s32 x, s32 y)
Returns the angle of the vector (x, y), in 1/65536 turns, measured from the y axis: 0 along +y,...
void BattleUnit_RefreshPlacement(void)
Places every unit at the start of a battle: numbers the places (party members 0 up in their order,...
s32 BattlePlacement_ContainsId(s16 *list, s32 place)
Returns 1 if the unit at place is in list.
s32 EnemySlotGet(void)
Returns the id of the first free enemy unit, or -1 when all six are taken.
#define BATTLE_OBJ_NO_EFFECT
BattleObj.effect while no effect is attached.
void BattleObjMake(struct BattleObj *actor, s32 unitId, s32 x, s32 y)
Creates the battle object of unit at (x, y) on the battlefield, in pixels: its sprite (an enemy's fro...
#define SCALE_ONE
BattleObj.scale and MotionObject scales are 16.16 fixed point.
s32 EnemyUpdate(void)
Lays the enemies out again and moves each one's object anchor to its new place.
void Summon_LayoutPositions(u16 *actorIds, s32 count, s32 *xPositions, s32 *zPositions)
Lays out count enemies in a column 80 pixels left of the centre, spaced by their size (38 pixels arou...
void BattlePlacement_GetStepPair(s32 partyPlace, s32 *x, s32 *y)
Reads the battlefield position of party place index from gBattlePlacement_StepPairs,...
#define SPRITE_GARET_MACHETE
#define IS_PLACEHOLDER_ID(id)
BattleWork.enemyIds of an enemy that left the battle, and of a place held for one: unit ids 254 and 2...
#define SPRITE_ISAAC_MACHETE
Isaac and Garet hold a Machete with sprites of their own.
A unit's place on the battlefield: its sprite object, resources and animations, its anchor spot and s...
struct SpriteEntry * effectEntry
the effect sprite, or NULL
struct MotionObject * object
NULL once released.
u16 animation
the status icon's animation shown; 0 for none
u16 resource
the unit's sprite
s32 palette
the unit sprite's palette
s16 fading
set while a fallen enemy's picture is being removed
s32 scale
16.16 fixed point, 0x10000 full size
u16 effect
an effect sprite drawn with the unit
s16 active
Set by BattleObj_MarkForRelease: the object is released with the others by BattleMotion_DestroyAllSlo...
struct SpriteEntry * animationEntry
the status icon's sprite, or NULL
s32 anchorZ
16.16 fixed-point pixels
u16 overlay
a second sprite drawn over it, the weapon; 0 for none
s32 anchorX
16.16 fixed-point pixels
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 side
BATTLE_UNIT_ABSENT (0), BATTLE_UNIT_ENEMY (1) or BATTLE_UNIT_PARTY (2).
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u8 classIndex
The character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy,...
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
u8 placement[14]
Each unit's index in slots, enemies from 8; 0xff for none.
s16 enemyIds[BATTLE_ENEMY_CAPACITY+1]
ends with BATTLE_UNIT_LIST_END
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,...
s32 z
16.16 fixed-point pixels
s32 y
16.16 fixed-point pixels
s32 x
16.16 fixed-point pixels