22 for (unitIndex = 0; unitIndex < unitCount; unitIndex++) {
23 if (list[unitIndex] == unitId)
27 return unitIndex != unitCount;
43 s32 unitOrElementIndex;
59 for (unitOrElementIndex = 3; unitOrElementIndex >= 0; unitOrElementIndex--)
60 counts[unitOrElementIndex] = 0;
62 if (recoveryList->
count != 0) {
66 for (unitOrElementIndex = 0; unitOrElementIndex < unitCount;
68 if (unitIds[unitOrElementIndex] ==
71 if (unitOrElementIndex != unitCount) {
78 }
while (recoveryIndex != recoveryList->
count);
85#define DJINN_ELEMENT(v) (((v) >> 8) & 15)
86#define DJINN_INDEX(v) ((v) & 255)
90#define DJINN_FIRST_ABILITY 300
92#define ABILITY_ANNIHILATION 178
112 s32 selectedTargetId;
120 s32 BattlePlan_SetTargets(
s32 abilityId) {
123 s32 includeDowned = 0;
132 switch (ability->
effect) {
165 aimedPlace = request->
target & 15;
171 for (place = first; place <= last; place++) {
175 if (request->
target & 128) {
176 if (place >= enemyCount)
181 if (!includeDowned &&
UnitGetFar(targetId)->hp == 0)
188 if (place >= partyCount)
193 if (!includeDowned &&
UnitGetFar(targetId)->hp == 0)
203 if (targetCount <= 0) {
241 for (index = 0;; index++) {
320 if (BattlePlan_SetTargets(abilityId) == -1)
339 if (BattlePlan_SetTargets(abilityId) == -1)
376 if (abilityId == 0 ||
384 if (BattlePlan_SetTargets(abilityId) == -1)
392 switch (item->
type) {
422 if (BattlePlan_SetTargets(abilityId) == -1)
428 message = MsgActorUnleashesAbility;
430 message = MsgActorUsesAbility;
436 message = MsgEmitsUltrasonicWaves;
439 message = MsgActorCasts;
442 message = MsgGlowersFerociously;
445 message = MsgIsIntimidated;
448 message = MsgBalefulGaze;
451 message = MsgEatsWorms;
458 message = MsgLetsOutAbility;
463 message = MsgActorUsesAbility;
466 message = MsgEnemyUnleashesAbility;
469 message = MsgGlowersMiserably;
472 message = MsgSmellOfDecay;
475 message = MsgFuriousRage;
478 message = MsgAttemptsToDivide;
481 message = MsgLooksForAllies;
484 message = MsgLooksForHelp;
540 if (BattlePlan_SetTargets(abilityId) == -1)
573 for (index = 0; index < 4 && counts[index] >= summon->
djinnRequired[index];
577 if (BattlePlan_SetTargets(abilityId) == -1)
590 for (index = 0; index !=
list->
count; index++) {
646 if (target->
hp == 0 || target->
sleep != 0 || target->
stun != 0 ||
658 if (target->
hp != 0) {
704 for (index = 0; index < plan->
targetCount; index++)
712 switch (ability->
effect) {
733 for (index = 0; index < plan->
targetCount; index++)
741 for (index = 0; index < plan->
targetCount; index++)
750 if (abilityId >= 0 && abilityId <= 518) {
758 if ((abilityId >= 0 && abilityId <= 517) &&
783#undef DJINN_FIRST_ABILITY
784#undef ABILITY_ANNIHILATION
@ ABILITY_SPEED_SURGE
An enemy that splits itself in two. Its message: "attempts to divide".
void BattlePres_SetActorModes(u16 *selectedUnits, s32 mode)
Highlights the units in selectedUnits, a list ended by BATTLE_UNIT_LIST_END, or with mode 0 stops the...
u32 BattleClass_GetAttackEffect(u32 index)
Returns the effect a class's plain attack shows, 1 for none or out of range.
s32 BattleParty_ListActorIds(s32 sideMask, u16 *unitIds)
Lists the units in the battle's unit lists on the sides in sideMask, party first, skipping those remo...
void BattleEv_MarkDisplay(void)
Sets gBattleDisplayWork->marked, which the next message reads, as BATTLE_EVENT_MARK does.
u32 BattleEvPush(u32 opcode, u32 operand)
Queues one battle event (enum BattleEventOpcode) with its operand, and returns the opcode.
u32 BattleEv_DispatchQueued(void)
Plays the queued battle events at once, in order (BattleEvent_Playback plays them over frames instead...
s32 BattlePresentation_WaitForAdvance(void)
Shows the bobbing arrow at the message window and waits for the player to go on (B,...
struct BattleObj * BattleObjGet(s32 unitId)
Returns unitId's battle object, through its place, or null for a unit with no place.
const u8 gBattle_ActionStatus[]
const u32 gBattle_ActionFlags[]
@ BATTLE_EVENT_DEFEAT
the unit falls; an enemy fades out
@ BATTLE_EVENT_UNIT_NAME
a unit's name for the next message
@ BATTLE_EVENT_DRAW_STATUS
redraws the party's status
@ BATTLE_EVENT_HIT
the unit flinches and flashes
@ BATTLE_EVENT_ABILITY_NAME
an ability's name for the next message
@ BATTLE_EVENT_REFRESH_UNIT
the unit's status icons, colour, pose
@ BATTLE_EVENT_MESSAGE
a message, waiting for the player
@ BATTLE_EVENT_SOUND
plays a sound
What every part of the battle object shares: its includes, in their original order,...
#define STAGING_ON_DOWNED
shown on downed targets too (revivals)
#define VALUE_ABILITY_NAME
#define STAGING_VARIANT_SHIFT
#define ALLY_MAX
the last party member's unit id
#define ABILITY_ATTACK
the ability "Attack"
#define STAGING_BY_ID_RANGE
BattleFx_DispatchByIdRangeFar.
#define DJINN_RECOVERY_AFTER_BATTLE
DjinnRecoveryEntry.turns of a Djinni waiting for the battle to end.
@ PLAN_SHOW_ATTACK
the actor runs up and strikes
@ PLAN_SHOW_CAST
Psynergy, and Venus, Mercury, Mars, Jupiter.
@ PLAN_SHOW_ENEMY_CAST
an enemy's Psynergy
@ PLAN_SHOW_FLEE
a unit runs
@ PLAN_SHOW_FULL_SCREEN
Gaia, Rockfall, Procne and their kin.
@ PLAN_SHOW_MESSAGES
no animation: each target's events only
@ PLAN_SHOW_SUMMON
the larger summons, the actor hidden
#define ITEM_USE_MAY_BREAK
breaks one time in eight
#define EQUIP_WEAPON
The inventory's weapon slot, for Inventory_FindEquippedFar.
#define GUARD_DEFEND
BattleUnit.guardLevel: Defend and Granite halve the damage, Total Defense and Flash cut it to a tenth...
#define DJINN_PER_ELEMENT
@ BATTLE_UNIT_LIST_END
ends the list
@ BATTLE_UNIT_REMOVED
a place whose unit has left the battle
@ CMD_ABILITY
an enemy's ability
@ CMD_NONE
nothing this turn
@ CMD_DEFEND2
an enemy's Total Defense (effect 47)
#define HIT_NOT_ROLLED
BattlePlan.targetHit while the hit is still to be rolled, as the ability lands; BattleCommand_BuildPl...
@ CRITICAL_STRONG
an ability's (effects 36 to 40): half as much again
@ CRITICAL_HIT
an attack's: a quarter more damage
@ ABILITY_KIND_UNLEASHED_DAMAGE
an enemy's. Shown as X unleashes Y!
@ ABILITY_EFFECT_TRIPLE_BLOW_60
Sonic Smash.
@ ABILITY_EFFECT_DOUBLE_BLOW_1_IN_4
Double Fang, Twin Beaks.
@ ABILITY_EFFECT_CRITICAL_1_IN_16
@ ABILITY_EFFECT_CRITICAL_1_IN_64
A 1 in 64 to 1 in 4 chance of an ability's critical hit, rolled by BattleCommand_BuildPlan.
@ ABILITY_EFFECT_TRIPLE_BLOW_1_IN_4
Swift Strike.
@ ABILITY_EFFECT_CRITICAL_1_IN_8
@ ABILITY_EFFECT_REVIVE_HALF
Quartz.
@ ABILITY_EFFECT_REVIVE_80
Dew: 80% of max HP.
@ ABILITY_EFFECT_CRITICAL_1_IN_32
@ ABILITY_EFFECT_DOUBLE_BLOW_1_IN_8
A chance of a double or triple blow, rolled by BattleCommand_BuildPlan.
@ ABILITY_EFFECT_CRITICAL_1_IN_4
@ ABILITY_EFFECT_REVIVE
Revive, Water of Life: full HP.
@ ABILITY_EFFECT_DOUBLE_BLOW_60
Gust, Rapid Smash: 153 in 256.
@ ABILITY_EFFECT_TRIPLE_BLOW_1_IN_8
#define ABILITY_KIND_MASK
The low four bits of BattleAct.flags: how BattleTargetExec applies the ability's power.
struct BattleWork * gBattleWork
void ObjectDispatch_SelectAnimationFar(void *raw, s32 no)
void ObjectDispatch_SetAnimationSpeedFar(struct DispatchObject *obj, s32 val)
struct BattleUnit * UnitGetFar(u32 owner)
struct ItemDefinition * Item_GetDirectFar(s32 item)
s32 BattleHitCheck(s32 caster, s32 target, s32 resistance_category, s32 effect_id, s32 success_scale)
Far call to BattleFx_RollSuccess.
s32 GameFlag_TestFar(s32 flag)
u32 * DjinnRecovery_AddStandbyFar(u32 kind, u32 first, u32 second)
s32 Equipment_GetUnleashRateBonusFar(struct BattleUnit *owner)
void UnitRatioFar(s32 owner_id)
void * Djinn_GetRecoveryTableFar(s32 arg0)
struct BattleAct * BattleActGet(s32 actionId)
Far call to BattleAction_GetDirect.
s32 Inventory_GetEquippedItemFar(struct BattleUnit *inv, s32 type)
u32 Djinn_IsActiveFar(s32 owner, s32 index, s32 bit)
s32 RollWeaponUnleashFar(struct BattleUnit *owner)
s32 DjinnRecovery_RemoveFar(s32 owner, s32 index, s32 bit)
s32 Unit_AddHpFar(s32 owner, s32 delta)
s32 Item_GetEquippedElementFar(s32 id)
const struct SummonDefinition * SummonDefinition_Get(u32 summon_id)
Far call to SummonDefinition_GetNear.
s32 Djinn_GetAbilityIdFar(u32 group, u32 index)
s32 Battle_IsReviveEffectFar(s32 effect_id)
s32 Djinn_IsReadyFar(s32 owner, s32 index, s32 bit)
s32 BattleRandomFar(void)
s32 Djinn_ActivateFar(s32 owner, s32 index, s32 bit)
void UnitCalcFar(s32 owner)
void AudioCommand_PlayFar(s32 id)
void UiWork_PushValueSlotFar(u32 value, u32 kind)
void UiText_ShowMessageAndWaitCoreFar(s32 argument)
void UiWork_ClearValueNameTablesFar(void)
#define FLAG_DJINN_TUTORIAL
void WaitFrames(s32 frames)
The game's frame loop: runs frames frames and returns.
@ ITEM_TYPE_PSYNERGY
The items that teach Psynergy while held: Orb of Force to Catch Beads.
@ ITEM_TYPE_WEAPON
swords, axes, maces, rods and staffs
#define CLAMP(v, low, high)
Keeps v within low to high, the low bound tested first.
#define DJINN_FIRST_ABILITY
The first Djinni's ability id: each element's 20 follow, Venus first.
s32 BattleCommand_BuildPlan(struct BattleActionRecord *request, struct BattlePlan *plan)
Announces the action and plans its targets and effects.
s32 BattleParty_CountStandbyDjinn(u32 unitId, u8 *counts)
Counts the standby Djinn whose owners fight on unitId's side, from that side's Djinn recovery list.
#define TARGET_MAX
The most targets a plan holds (BATTLE_TARGET_CAPACITY).
u32 BattleParty_IsUnitListed(u32 unitId)
Returns one when the unit is in its side's formation.
#define ABILITY_ANNIHILATION
The ability Annihilation, which rolls its hit as it is planned.
s32 BattleEventRuntime_SchedulePhase(s32 frames)
Empties the event queue and schedules playback of the events queued next, with no targets to resolve.
s32 BattleEventRuntime_WaitForReady(void)
Waits, a frame at a time, until BattleEvent_Playback has played every target, then removes the callba...
void BattleEventRuntime_Reset(void)
Stops playback and empties the event queue.
s32 Battle_GetTaggedSlotValue(s32 taggedPlace)
Returns the unit id at a list place.
void BattleFx_PlayUnitElementEffect(s32 unitId, s32 element, s32 mode, s32 variant)
Plays a glow of the element about a unit, and returns when it is over.
An ability's definition, a row of gBattleAction_DefinitionTable: its targeting, kind,...
u8 ppCost
PP the ability costs.
u8 effect
enum AbilityEffect
u8 range
the aimed unit and range - 1 either side, or ABILITY_RANGE_ALL
u8 targetMode
TARGET_MODE_NONE, _FOES, _ALLIES or _SELF.
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
struct MotionObject * object
NULL once released.
One action, as BattleCommand_BuildPlan lays it out for BattleTargetExec to apply target by target.
s32 outcome
enum BattlePlanStaging: how the action is shown
u32 presentationFlags
How the effect is staged (STAGING_ in battle_internal.h).
u32 hauntDamage
The damage the evil spirit deals a haunted actor at the end of its turn.
s8 targetCount
targets in targetIds
u8 actorId
the acting unit
u8 targetIds[BATTLE_TARGET_CAPACITY]
in battlefield order
s8 targetHit[BATTLE_TARGET_CAPACITY]
1, 0 or HIT_NOT_ROLLED
s8 targetOffset[BATTLE_TARGET_CAPACITY]
Each target's place relative to the aimed one: negative to one side.
s8 targetCritical[BATTLE_TARGET_CAPACITY]
enum BattleCritical
s16 command
enum BattleCommand
s32 failure
0 cast; 1 the Psynergy is sealed, 2 too little PP
s8 targetMultiplier[BATTLE_TARGET_CAPACITY]
The damage multiplier: 0 a miss, 1 a blow, 2 or 3 a double or triple.
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 immobile
set by Ground: the next action is lost
u8 psySeal
bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast).
s16 maxPp
0 to 1999 for a character, 9999 for an enemy (UnitCalc)
s16 hp
current HP, 0 when downed
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,...
s8 guardLevel
0, GUARD_DEFEND (1, half the damage) or GUARD_TOTAL_DEFENSE (2, a tenth); set by Defend and Granite,...
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
u8 delusion
Delusion to sleep: the turns each status has left, 7 when it lands; each may end sooner at the end of...
The battle's own work: its enemies, units and their objects, the turn's actions, the spoils,...
s16 partyUnits[7]
ends with BATTLE_UNIT_LIST_END
s16 enemyIds[BATTLE_ENEMY_CAPACITY+1]
ends with BATTLE_UNIT_LIST_END
A field object as the object dispatcher's far calls take it.
A Djinni on standby or recovering: its element and index, its owner, and the turns until it is set ag...
s8 turns
Turns until it is set again; -1 on standby (DJINN_RECOVERY_AFTER_BATTLE), -2 while a summon uses it.
u8 index
the Djinni within its element, 0 to 19
One side's Djinn recovery list: up to 64 entries and their count.
struct DjinnRecoveryEntry entries[64]
One side's Djinn recovery table, as Djinn_GetRecoveryTable returns it.
struct DjinnRecoveryList list
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
u8 useType
what using it costs (ITEM_USE_), or 0 for nothing
u8 type
enum ItemType; 0 for an item that is not equipment
u16 actionId
the ability used, or taught as Psynergy
A summon: its name's message and the Djinn of each element it needs.
u16 nameMessageId
The summon's ability id: its name is message MsgAbilityName plus it, and its low 14 bits pick the ico...
u8 djinnRequired[4]
standby Djinn needed, by element
u32 Ability_IsPsynergy(s32 abilityId)
Returns 1 for an ability that costs PP, and for Psy Drain, which costs none.