Skip to Content
The Alchemy Project

src/battle/battle_turn_end.c

The end of an action and of a turn: counters, Djinn recovery, poison and the Grim Reaper. More…

Included by battle.c.

Macros

NameDescription
#defineDEFINE_COUNT_DOWN_MODIFIER (name, counter, level, bias)Defines a stat change's turn-end countdown, as btUnitCountDownAttackStage is, a lowered stat ending early at bias.
#defineDEFINE_COUNT_DOWN_STATUS (name, counter, bias)Defines a status's turn-end countdown: returns 1 when counter runs out, or clears it and returns 1 when the status ends early at bias.

Enumerations

NameDescription
enumEARLY_END_BIAS { EARLY_END_ATTACK_DOWN, EARLY_END_DEFENSE_DOWN, EARLY_END_RES … }How much likelier, in percent, each lowered stat and status is to end early (btUnitRollCounterEarlyEnd's bias).

Functions

NameDescription
BoolbtUnitRollCounterEarlyEnd (Sint32 unitId, Sint32 turns, Sint32 bias)Rolls whether a stat change or status with five turns or fewer left ends early, at luck * 3 - turns * 5 + bias percent, and returns 1 when it does.
BoolbtUnitCountDownAttackStage (Sint32 unitId)Counts down an Attack change and returns 1 when it ends; a lowered Attack may recover early.
DEFINE_COUNT_DOWN_MODIFIER(btUnitCountDownDefenseStage , defenseTurns, defenseStage, EARLY_END_DEFENSE_DOWN)Counts down a Defense change; btProcessTurnEnd shows MsgDefNormal when it returns 1.
DEFINE_COUNT_DOWN_MODIFIER(btUnitCountDownResistanceStage , resistanceTurns, resistanceStage, EARLY_END_RESISTANCE_DOWN)Counts down a Resistance change; btProcessTurnEnd shows MsgResNormal when it returns 1.
DEFINE_COUNT_DOWN_STATUS(btUnitCountDownDelusion , delusion, EARLY_END_DELUSION)Counts down delusion, which may end early; btProcessTurnEnd shows MsgCureDelusion when it returns 1.
DEFINE_COUNT_DOWN_STATUS(btUnitCountDownConfusion , confusion, EARLY_END_CONFUSION)Counts down confusion, which may end early; btProcessTurnEnd shows MsgConfusionConscious when it returns 1.
DEFINE_COUNT_DOWN_STATUS(btUnitCountDownCharm , charm, EARLY_END_CHARM)Counts down charm, which may end early; btProcessTurnEnd shows MsgCharmConscious when it returns 1.
DEFINE_COUNT_DOWN_STATUS(btUnitCountDownStun , stun, EARLY_END_STUN)Counts down stun, which may end early; btProcessTurnEnd shows MsgCureStun when it returns 1.
DEFINE_COUNT_DOWN_STATUS(btUnitCountDownSleep , sleep, EARLY_END_SLEEP)Counts down sleep, which may end early; btProcessTurnEnd shows MsgWakes when it returns 1.
BoolbtUnitCountDownPsynergySeal (Sint32 unitId)Counts down both seals in UNIT.psySeal and returns 1 when the last ends; only Bind's, once Luff's is gone, may end early.
BoolbtUnitCountDownRegenerate (Sint32 unitId)Counts down UNIT.regenerate and returns 1 when it runs out; it never ends early.
BoolbtUnitCountDownReflect (Sint32 unitId)Counts down Reflect and returns 1 when it runs out; it never ends early.
BoolbtUnitCountDownAgilityStage (Sint32 unitId)Counts down an Agility change and returns 1 when it runs out; it never ends early.
Sint32btDjinnRecoveryCountDown (void)Brings the party's recovering Djinn one turn nearer, setting each that is ready, and returns 1 when any was set.
Sint32btDjinnRecoverAll (void)Runs btDjinnRecoveryCountDown twenty times, which sets every recovering Djinni of a party member with HP; those on standby stay so.
voidbtTurnEndNoOperation (void)Does nothing; btRun calls it at the end of each turn and of the battle.
UNREAD_RESULTbtProcessTurnEnd (void)Ends a turn: sets recovered Djinn, then gives each unit its regeneration and counts down its stat changes and statuses, showing each that ends.
UNREAD_RESULTbtUnitProcessActionEnd (BATTLE_ACTION_RUN *plan)Ends one unit's action: its Djinn on standby are taken off its set, the Djinn a summon used begin to recover, and the unit takes its summon's power boost, the haunt's damage, poison and the Grim Reaper.

Description

The end of an action and of a turn: counters, Djinn recovery, poison and the Grim Reaper. Part of battle.c.

Macros in detail

DEFINE_COUNT_DOWN_MODIFIER

#define DEFINE_COUNT_DOWN_MODIFIER(name, counter, level, bias)

Defines a stat change's turn-end countdown, as btUnitCountDownAttackStage is, a lowered stat ending early at bias.

Definition at line 70 of file battle_turn_end.c.

DEFINE_COUNT_DOWN_STATUS

#define DEFINE_COUNT_DOWN_STATUS(name, counter, bias)

Defines a status's turn-end countdown: returns 1 when counter runs out, or clears it and returns 1 when the status ends early at bias.

Definition at line 109 of file battle_turn_end.c.

Enumerations in detail

EARLY_END_BIAS

enum EARLY_END_BIAS

How much likelier, in percent, each lowered stat and status is to end early (btUnitRollCounterEarlyEnd's bias).

EnumeratorValueDescription
EARLY_END_ATTACK_DOWN30
EARLY_END_DEFENSE_DOWN20
EARLY_END_RESISTANCE_DOWN20
EARLY_END_DELUSION30
EARLY_END_CONFUSION60
EARLY_END_CHARM70
EARLY_END_STUN40
EARLY_END_SLEEP50
EARLY_END_BIND30Bind's seal, once Luff's is gone

Definition at line 8 of file battle_turn_end.c.

Functions in detail

btUnitRollCounterEarlyEnd

Bool btUnitRollCounterEarlyEnd(Sint32 unitId, Sint32 turns, Sint32 bias)

Rolls whether a stat change or status with five turns or fewer left ends early, at luck * 3 - turns * 5 + bias percent, and returns 1 when it does.

References gmBattleRandomStub(), gmUnitGetStub() and Sint32.

Referenced by btUnitCountDownAttackStage() and btUnitCountDownPsynergySeal().

Definition at line 23 of file battle_turn_end.c.

btUnitCountDownAttackStage

Bool btUnitCountDownAttackStage(Sint32 unitId)

Counts down an Attack change and returns 1 when it ends; a lowered Attack may recover early.

References btUnitRollCounterEarlyEnd(), gmUnitGetStub() and Sint32.

Referenced by btProcessTurnEnd().

Definition at line 41 of file battle_turn_end.c.

btUnitCountDownDefenseStage

DEFINE_COUNT_DOWN_MODIFIER(btUnitCountDownDefenseStage, defenseTurns, defenseStage, EARLY_END_DEFENSE_DOWN)

Counts down a Defense change; btProcessTurnEnd shows MsgDefNormal when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 96 of file battle_turn_end.c.

btUnitCountDownResistanceStage

DEFINE_COUNT_DOWN_MODIFIER(btUnitCountDownResistanceStage, resistanceTurns, resistanceStage, EARLY_END_RESISTANCE_DOWN)

Counts down a Resistance change; btProcessTurnEnd shows MsgResNormal when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 102 of file battle_turn_end.c.

btUnitCountDownDelusion

DEFINE_COUNT_DOWN_STATUS(btUnitCountDownDelusion, delusion, EARLY_END_DELUSION)

Counts down delusion, which may end early; btProcessTurnEnd shows MsgCureDelusion when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 129 of file battle_turn_end.c.

btUnitCountDownConfusion

DEFINE_COUNT_DOWN_STATUS(btUnitCountDownConfusion, confusion, EARLY_END_CONFUSION)

Counts down confusion, which may end early; btProcessTurnEnd shows MsgConfusionConscious when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 133 of file battle_turn_end.c.

btUnitCountDownCharm

DEFINE_COUNT_DOWN_STATUS(btUnitCountDownCharm, charm, EARLY_END_CHARM)

Counts down charm, which may end early; btProcessTurnEnd shows MsgCharmConscious when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 139 of file battle_turn_end.c.

btUnitCountDownStun

DEFINE_COUNT_DOWN_STATUS(btUnitCountDownStun, stun, EARLY_END_STUN)

Counts down stun, which may end early; btProcessTurnEnd shows MsgCureStun when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 142 of file battle_turn_end.c.

btUnitCountDownSleep

DEFINE_COUNT_DOWN_STATUS(btUnitCountDownSleep, sleep, EARLY_END_SLEEP)

Counts down sleep, which may end early; btProcessTurnEnd shows MsgWakes when it returns 1.

Referenced by btProcessTurnEnd().

Definition at line 145 of file battle_turn_end.c.

btUnitCountDownPsynergySeal

Bool btUnitCountDownPsynergySeal(Sint32 unitId)

Counts down both seals in UNIT.psySeal and returns 1 when the last ends; only Bind's, once Luff's is gone, may end early.

References btUnitRollCounterEarlyEnd(), gmUnitGetStub() and Sint32.

Referenced by btProcessTurnEnd().

Definition at line 149 of file battle_turn_end.c.

btUnitCountDownRegenerate

Bool btUnitCountDownRegenerate(Sint32 unitId)

Counts down UNIT.regenerate and returns 1 when it runs out; it never ends early. btProcessTurnEnd then shows MsgRefrainEnd.

References gmUnitGetStub() and Sint32.

Referenced by btProcessTurnEnd().

Definition at line 174 of file battle_turn_end.c.

btUnitCountDownReflect

Bool btUnitCountDownReflect(Sint32 unitId)

Counts down Reflect and returns 1 when it runs out; it never ends early. btProcessTurnEnd then shows MsgReflectEnd.

References gmUnitGetStub() and Sint32.

Referenced by btProcessTurnEnd().

Definition at line 190 of file battle_turn_end.c.

btUnitCountDownAgilityStage

Bool btUnitCountDownAgilityStage(Sint32 unitId)

Counts down an Agility change and returns 1 when it runs out; it never ends early.

References gmUnitGetStub() and Sint32.

Referenced by btProcessTurnEnd().

Definition at line 206 of file battle_turn_end.c.

btDjinnRecoveryCountDown

Sint32 btDjinnRecoveryCountDown(void)

Brings the party's recovering Djinn one turn nearer, setting each that is ready, and returns 1 when any was set.

References gmDjinnGetRecoveryTableStub(), gmDjinnRecoveryRemoveStub(), gmDjinnSetStub(), gmUnitCalculateStub(), gmUnitGetStub() and Sint32.

Referenced by btDjinnRecoverAll() and btRun().

Definition at line 224 of file battle_turn_end.c.

btDjinnRecoverAll

Sint32 btDjinnRecoverAll(void)

Runs btDjinnRecoveryCountDown twenty times, which sets every recovering Djinni of a party member with HP; those on standby stay so. Returns 0.

References btDjinnRecoveryCountDown() and Sint32.

Referenced by scInit() and scVaultReturnIsaacsDjinni().

Definition at line 263 of file battle_turn_end.c.

btTurnEndNoOperation

void btTurnEndNoOperation(void)

Does nothing; btRun calls it at the end of each turn and of the battle.

Referenced by btRun().

Definition at line 273 of file battle_turn_end.c.

btProcessTurnEnd

UNREAD_RESULT btProcessTurnEnd(void)

Ends a turn: sets recovered Djinn, then gives each unit its regeneration and counts down its stat changes and statuses, showing each that ends.

References BattleTurnEndSideOrder, btBackgroundSetMode(), btElementGlowPlay(), btMessageWaitForAdvance(), btObjectGet(), btObjectUpdatePose(), btPlaybackPush(), btPlaybackReset(), btPlaybackSchedulePhase(), btPlaybackWaitForReady(), btUnitBuildStatusFlags(), btUnitCountDownAgilityStage(), btUnitCountDownAttackStage(), btUnitCountDownCharm(), btUnitCountDownConfusion(), btUnitCountDownDefenseStage(), btUnitCountDownDelusion(), btUnitCountDownPsynergySeal(), btUnitCountDownReflect(), btUnitCountDownRegenerate(), btUnitCountDownResistanceStage(), btUnitCountDownSleep(), btUnitCountDownStun(), btUnitListIds(), fdActorSelectAnimationStub(), fdActorSetAnimationSpeedStub(), gmDjinnGetRecoveryTableStub(), gmDjinnRecoveryRemoveStub(), gmDjinnSetStub(), gmUnitAddHpStub(), gmUnitAddPpStub(), gmUnitCalculateStub(), gmUnitGetStub(), mnBattleMessageShowAndWaitStub(), mnMessageArgumentPushStub(), Sint32 and sySoundPlayStub().

Referenced by btRun().

Definition at line 279 of file battle_turn_end.c.

btUnitProcessActionEnd

UNREAD_RESULT btUnitProcessActionEnd(BATTLE_ACTION_RUN *plan)

Ends one unit's action: its Djinn on standby are taken off its set, the Djinn a summon used begin to recover, and the unit takes its summon's power boost, the haunt's damage, poison and the Grim Reaper.

References btElementGlowPlay(), btObjectGet(), btPlaybackPush(), btPlaybackReset(), btPlaybackRunAll(), btPlaybackSchedulePhase(), btPlaybackWaitForReady(), btUnitListLiving(), fdActorSelectAnimationStub(), fdActorSetAnimationSpeedStub(), gmDjinnGetRecoveryTableStub(), gmDjinnPutOnStandbyStub(), gmUnitAddHpStub(), gmUnitCalculateStub(), gmUnitGetStub(), Sint32, syHeapAllocateEWRAM(), syHeapRelease(), sySoundPlayStub() and syWordsCopy().

Referenced by btStagingDispatchAction().

Definition at line 525 of file battle_turn_end.c.