Skip to Content
The Alchemy Project

src/battle/battle_auto_battle.c

Auto battle, the battle test menu's mode (FLAG_AUTO_BATTLE, set by btDebugBattleRunMenu): no command menu opens, every unit attacks in action order, and each action is played by the simpler routines here instead of battle_staging.c's. More…

Included by battle.c.

Macros

NameDescription
#defineTARGET_SIDE_DEFEATED 256btAbilityReplaceDefeated's result when the target's side is all down, which the battle's end comes before.

Functions

NameDescription
Sint32btAutoBattleBuildActions (BATTLE_ACTION *entries)Gives every living unit a plain attack and sorts them into action order.
DEFINE_ADJUST_CAMERA(btCameraAdjustByShoulderKeys) // Plays one action, a defeated target replaced by a living unit of its side. // Returns 1 when the party got away, -1 when the unit is down. Sint32btAutoBattleRunAction (BATTLE_ACTION *action)Unused: turns the camera while L or R is held.
DEFINE_ADJUST_CAMERA(btCameraAdjustByShoulderKeys ) // Plays one action, a defeated target replaced by a living unit of its side. // Returns 1 when the party got away, -1 when the unit is down. Sint32 btAutoBattleRunAction(BATTLE_ACTION *action)Unused: turns the camera while L or R is held.
Sint32btObjectIsValidId (Uint32 unitId)Returns 0 for a party member's or an enemy's unit id, -1 for any other.
BoolbtFleePlayRun (BATTLE_ACTION *action)The party tries to run, and gets away 15 times in 16.
Sint32btAutoBattleShowDefend (const BATTLE_ACTION *action)Shows "<unit> is defending!" for a standing unit.
Sint32btAutoBattleRunPsynergy (BATTLE_ACTION *action)Casts Psynergy: the caster's side fades out while the effect, run as a summon is (btEffectRunSummon), plays over the target's side.
Sint32btAutoBattleRunApproachAttack (BATTLE_ACTION *input)Unused auto battle attack: "<unit> attacks!", the attacker runs up to its target, the blow, and both return.
Sint32btAutoBattleRunAttackOrItem (BATTLE_ACTION *action)An attack or an item, played on the first living unit of the target's side.
voidbtAutoBattleApplyDamage (Uint32 unitId, Sint32 damage, Sint32 showMsg, Uint8 *context)Unused auto battle damage: takes damage HP from a unit and shows it, with "A bitter blow!" or "A critical hit!" first when showMsg is set.
voidbtMotionPlayFall (Sint32 unitId)For a unit whose HP has run out: plays its falling effect to the last tick and marks its battle object for release (btObjectMarkForRelease).
Sint32btAbilityReplaceDefeated (const BATTLE_ACTION *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.

Description

Auto battle, the battle test menu's mode (FLAG_AUTO_BATTLE, set by btDebugBattleRunMenu): no command menu opens, every unit attacks in action order, and each action is played by the simpler routines here instead of battle_staging.c's. Part of battle.c.

Macros in detail

TARGET_SIDE_DEFEATED

#define TARGET_SIDE_DEFEATED 256

btAbilityReplaceDefeated's result when the target's side is all down, which the battle's end comes before.

Referenced by btAbilityReplaceDefeated().

Definition at line 588 of file battle_auto_battle.c.

Functions in detail

btAutoBattleBuildActions

Sint32 btAutoBattleBuildActions(BATTLE_ACTION *entries)

Gives every living unit a plain attack and sorts them into action order. Returns how many actions there are.

References btUnitListLiving(), gmUnitGetStub(), Sint32 and syDMAXCopy().

Referenced by btRun().

Definition at line 10 of file battle_auto_battle.c.

btAutoBattleRunAction

DEFINE_ADJUST_CAMERA(btCameraAdjustByShoulderKeys) // Plays one action, a defeated target replaced by a living unit of its side. // Returns 1 when the party got away, -1 when the unit is down. Sint32 btAutoBattleRunAction(BATTLE_ACTION *action)

Unused: turns the camera while L or R is held.

References btAbilityReplaceDefeated(), btAutoBattleRunAttackOrItem(), btAutoBattleRunPsynergy(), btAutoBattleShowDefend(), btCameraAdjustByShoulderKeys(), btFleePlayRun(), gmUnitGetStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentClearAllStub(), mnMessageResetIdleStub(), Sint32 and sySynch().

Referenced by btRun().

Definition at line 88 of file battle_auto_battle.c.

btCameraAdjustByShoulderKeys

DEFINE_ADJUST_CAMERA(btCameraAdjustByShoulderKeys) // Plays one action, a defeated target replaced by a living unit of its side. // Returns 1 when the party got away, -1 when the unit is down. Sint32 btAutoBattleRunAction(BATTLE_ACTION *action)

Unused: turns the camera while L or R is held.

Referenced by btAutoBattleRunAction().

Definition at line 88 of file battle_auto_battle.c.

btObjectIsValidId

Sint32 btObjectIsValidId(Uint32 unitId)

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

References Sint32.

Referenced by btAutoBattleRunApproachAttack(), btAutoBattleRunAttackOrItem(), btAutoBattleRunPsynergy() and btAutoBattleShowDefend().

Definition at line 149 of file battle_auto_battle.c.

btFleePlayRun

Bool btFleePlayRun(BATTLE_ACTION *action)

The party tries to run, and gets away 15 times in 16. Returns TRUE when it got away.

References btMotionSetupEscapeObject(), btUnitListLiving(), mnBattleMessageShowAndWaitStub(), Sint32 and sySynch().

Referenced by btAutoBattleRunAction().

Definition at line 164 of file battle_auto_battle.c.

btAutoBattleShowDefend

Sint32 btAutoBattleShowDefend(const BATTLE_ACTION *action)

Shows "<unit> is defending!" for a standing unit. Returns -1 for an invalid unit id, 0 otherwise.

References btObjectIsValidId(), gmUnitGetStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentClearAllStub(), mnMessageArgumentPushStub() and Sint32.

Referenced by btAutoBattleRunAction().

Definition at line 188 of file battle_auto_battle.c.

btAutoBattleRunPsynergy

Sint32 btAutoBattleRunPsynergy(BATTLE_ACTION *action)

Casts Psynergy: the caster's side fades out while the effect, run as a summon is (btEffectRunSummon), plays over the target's side.

References btCameraSetView(), btEffectRunSummonStub(), btHighlightSetSpriteMode(), btObjectGet(), btObjectIsValidId(), btObjectPut(), btObjectSpawnObjectsForList(), btUnitListLiving(), fdActorSelectAnimationStub(), gmUnitGetStub(), mnPartyStatusDrawStub(), Sint32, state, syRandom() and sySynch().

Referenced by btAutoBattleRunAction().

Definition at line 212 of file battle_auto_battle.c.

btAutoBattleRunApproachAttack

Sint32 btAutoBattleRunApproachAttack(BATTLE_ACTION *input)

Unused auto battle attack: "<unit> attacks!", the attacker runs up to its target, the blow, and both return.

References btEffectRunByIdRangeStub(), btMotionApproachTarget(), btMotionReturnToSpot(), btObjectGet(), btObjectIsValidId(), fdActorSetAnimationSpeedStub(), gmUnitGetStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentPushStub(), Sint32, state, syRandom() and sySynch().

Definition at line 353 of file battle_auto_battle.c.

btAutoBattleRunAttackOrItem

Sint32 btAutoBattleRunAttackOrItem(BATTLE_ACTION *action)

An attack or an item, played on the first living unit of the target's side.

References btEffectRunElementPillarStub(), btMotionReturnToSpot(), btObjectGet(), btObjectIsValidId(), btUnitListLiving(), fdActorSelectAnimationStub(), fdActorSetAnimationSpeedStub(), mnPartyStatusDrawStub(), Sint32, state and sySynch().

Referenced by btAutoBattleRunAction().

Definition at line 404 of file battle_auto_battle.c.

btAutoBattleApplyDamage

void btAutoBattleApplyDamage(Uint32 unitId, Sint32 damage, Sint32 showMsg, Uint8 *context)

Unused auto battle damage: takes damage HP from a unit and shows it, with "A bitter blow!" or "A critical hit!" first when showMsg is set. Nothing reads context; a null one is pointed at four zeroed bytes of the routine's own.

References btMotionPlayFall(), btObjectGet(), fdActorSelectAnimationStub(), gmUnitGetStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentClearAllStub(), mnMessageArgumentPushStub(), mnPartyStatusDrawStub() and Sint32.

Definition at line 500 of file battle_auto_battle.c.

btMotionPlayFall

void btMotionPlayFall(Sint32 unitId)

For a unit whose HP has run out: plays its falling effect to the last tick and marks its battle object for release (btObjectMarkForRelease).

References btObjectGet(), btObjectMarkForRelease(), fdSpriteDissolveRunStub(), fdSpriteStartAnimationStub(), gmUnitGetStub(), Sint32 and sySynch().

Referenced by btAutoBattleApplyDamage().

Definition at line 568 of file battle_auto_battle.c.

btAbilityReplaceDefeated

Sint32 btAbilityReplaceDefeated(const BATTLE_ACTION *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.

References btUnitListLiving(), gmUnitGetStub() and Sint32.

Referenced by btAutoBattleRunAction().

Definition at line 592 of file battle_auto_battle.c.