Alchemy
Loading...
Searching...
No Matches

auto_battle.c File Reference

Auto battle: the actions it builds and plays, without the command menu. More...

Go to the source code of this file.

Macros

#define TARGET_SIDE_DEFEATED   0x100
 BattleTarget_ReplaceDefeated's result when the target's side is all down.

Functions

s32 BattlePresentation_BuildSortedUnitEntries (struct BattleActionRecord *entries)
 Auto battle: gives every living unit a plain attack and sorts them into turn order.
void BattlePres_AdjustCameraByShoulderKeys (void)
 Turns the camera while L or R is held. Nothing in the source calls it.
s32 BattlePres_RunAction (struct BattleActionRecord *action)
 Auto battle: plays one action.
s32 BattleObject_IsValidId (u32 unitId)
 Returns 0 for a party member's or an enemy's unit id, -1 for any other.
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 turn.
s32 BattlePres_ShowDefendMessage (const struct BattleActionRecord *action)
 Auto battle: shows that a standing unit is defending.
s32 BattlePresentation_RunPairedUnitTransition (struct BattleActionRecord *action)
 Auto battle: casts Psynergy.
s32 BattlePres_RunApproachAction (struct BattleActionRecord *input)
 Auto battle: an attack.
s32 BattlePres_RunUnitAction (struct BattleActionRecord *action)
 Auto battle: an attack or an item.
void BattlePresentation_ApplyUnitDamage (u32 unitId, s32 damage, s32 showMessage, u8 *context)
 Auto battle: deals damage HP to unit unitId and shows it.
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 for release (BattleObj_MarkForRelease).
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_DEFEATED when none is left.

Detailed Description

Auto battle: the actions it builds and plays, without the command menu.

Part of battle.c, the battle object, compiled only through it.

Definition in file auto_battle.c.

Macro Definition Documentation

◆ TARGET_SIDE_DEFEATED

#define TARGET_SIDE_DEFEATED   0x100

BattleTarget_ReplaceDefeated's result when the target's side is all down.

Definition at line 543 of file auto_battle.c.

Referenced by BattleTarget_ReplaceDefeated().

Function Documentation

◆ BattlePresentation_BuildSortedUnitEntries()

s32 BattlePresentation_BuildSortedUnitEntries ( struct BattleActionRecord * entries)

Auto battle: gives every living unit a plain attack and sorts them into turn order.

The party act at their Agility and target the first enemy; enemies act at half their Agility plus a random part of it and target a random party member. Returns how many actions there are. Called by Battle_RunEncounter each round under FLAG_AUTO_BATTLE; fills entries.

Definition at line 12 of file auto_battle.c.

Referenced by Battle_RunEncounter(), and BattlePresentation_BuildSortedUnitEntries().

◆ BattlePres_AdjustCameraByShoulderKeys()

void BattlePres_AdjustCameraByShoulderKeys ( void )

Turns the camera while L or R is held. Nothing in the source calls it.

Definition at line 83 of file auto_battle.c.

Referenced by BattlePres_AdjustCameraByShoulderKeys().

◆ BattlePres_RunAction()

s32 BattlePres_RunAction ( struct BattleActionRecord * action)

Auto battle: plays one action.

A unit already down does nothing (-1); a defeated target is replaced by a living unit of its side first. Returns 1 when the party got away, 0 otherwise. Called by Battle_RunEncounter for each action under FLAG_AUTO_BATTLE. Turns the camera to the actor's side (gTransitionWork) and rewrites action->target.

Definition at line 90 of file auto_battle.c.

Referenced by Battle_RunEncounter(), and BattlePres_RunAction().

◆ BattleObject_IsValidId()

s32 BattleObject_IsValidId ( u32 unitId)

Returns 0 for a party member's or an enemy's unit id, -1 for any other.

Called by the auto battle's action players.

Definition at line 145 of file auto_battle.c.

Referenced by BattleObject_IsValidId(), BattlePres_RunApproachAction(), BattlePres_RunUnitAction(), BattlePres_ShowDefendMessage(), and BattlePresentation_RunPairedUnitTransition().

◆ BattleEscape_PlayRun()

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 turn.

Returns 1 when they got away; else shows MsgCannotEscape and returns 0. Called by BattlePres_RunAction.

Definition at line 158 of file auto_battle.c.

Referenced by BattleEscape_PlayRun(), and BattlePres_RunAction().

◆ BattlePres_ShowDefendMessage()

s32 BattlePres_ShowDefendMessage ( const struct BattleActionRecord * action)

Auto battle: shows that a standing unit is defending.

The message is <unit> is defending. Returns -1 for an invalid unit id, 0 otherwise. Called by BattlePres_RunAction.

Definition at line 188 of file auto_battle.c.

Referenced by BattlePres_RunAction(), and BattlePres_ShowDefendMessage().

◆ BattlePresentation_RunPairedUnitTransition()

s32 BattlePresentation_RunPairedUnitTransition ( struct BattleActionRecord * action)

Auto battle: casts Psynergy.

The camera turns to the caster's side and the caster raises its hand; the target side fades out, its living units are readied alone, the Psynergy's effect (kind action->parameter) plays on them, and everyone fades back in. Returns -1 for an invalid actor or target. Called by BattlePres_RunAction for CMD_PSYNERGY. Writes REG_BLDCNT and REG_BLDALPHA and the actors' record modes, and leaves the battle objects readied again.

Definition at line 215 of file auto_battle.c.

Referenced by BattlePres_RunAction(), and BattlePresentation_RunPairedUnitTransition().

◆ BattlePres_RunApproachAction()

s32 BattlePres_RunApproachAction ( struct BattleActionRecord * input)

Auto battle: an attack.

Shows <unit> attacks!, sends the attacker up to its target, plays the blow and sends both back. Returns -1 for an invalid attacker or target. Nothing in the source calls it.

Definition at line 332 of file auto_battle.c.

Referenced by BattlePres_RunApproachAction().

◆ BattlePres_RunUnitAction()

s32 BattlePres_RunUnitAction ( struct BattleActionRecord * action)

Auto battle: an attack or an item.

Turns the camera to the actor's side, poses the actor and plays the effect (kind action->parameter) on the first living unit of the target's side, then sends both back. Returns -1 for an invalid actor. Called by BattlePres_RunAction for CMD_ATTACK, CMD_ITEM and any other command but fleeing, defending and Psynergy.

Definition at line 383 of file auto_battle.c.

Referenced by BattlePres_RunAction(), and BattlePres_RunUnitAction().

◆ BattlePresentation_ApplyUnitDamage()

void BattlePresentation_ApplyUnitDamage ( u32 unitId,
s32 damage,
s32 showMessage,
u8 * context )

Auto battle: deals damage HP to unit unitId and shows it.

When showMessage is set, "A bitter blow!" (to the party) or "A critical hit!" (to an enemy) comes first; then <unit> takes <damage> damage!, and <unit> goes down... or <unit> has been downed! when the HP runs out. context, if null, is replaced by four cleared bytes nothing reads. Nothing in the source calls it. Lowers unit->hp, no lower than 0.

Definition at line 469 of file auto_battle.c.

Referenced by BattlePresentation_ApplyUnitDamage().

◆ BattleMotion_SetMode5AndActivateSlot()

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 for release (BattleObj_MarkForRelease).

Called by BattlePresentation_ApplyUnitDamage.

Definition at line 526 of file auto_battle.c.

Referenced by BattleMotion_SetMode5AndActivateSlot(), and BattlePresentation_ApplyUnitDamage().

◆ BattleTarget_ReplaceDefeated()

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_DEFEATED when none is left.

Called by BattlePres_RunAction.

Definition at line 548 of file auto_battle.c.

Referenced by BattlePres_RunAction(), and BattleTarget_ReplaceDefeated().