Skip to Content
The Alchemy Project

src/battle/battle_targeting.c

The targets an enemy's or a confused unit's ability picks. More…

Included by battle.c.

Structures

NameDescription
structBATTLE_STATE_UNIT_LIST_VIEWBATTLE_STATE's unit lists, read as one array of halfwords.

Macros

NameDescription
#defineCOUNT_STUN_SLOT (unit, count)
#defineCOUNT_PARTIAL_CURES (unit, count)Counts the statuses of unit that Restore's count takes: delusion, COUNT_STUN_SLOT's (confusion and charm where Restore cures stun, the BUG above), sleep, the Psynergy seal and the Grim Reaper.
#defineCOUNT_ALL_CURES (unit, count)Counts the statuses Tonic cures: those, the evil spirit and poison.
#defineCOUNT_POSITIVE_MODIFIERS (unit, count)Counts what Break would undo on unit; a raised Agility is not counted.
#defineCHECK_EFFECT_TARGET (unit, action, applies, kindIndex)How worthwhile an enemy's ability is against unit, 0 for pointless: a stat change that can still move, a cure or heal it needs, a status it lacks, a downed unit to revive.

Functions

NameDescription
Sint32btAIChooseRandomTarget (Sint32 requireLivingUnit)Picks a random place: a party member still standing with requireLivingUnit, otherwise any enemy place in use.
Sint32btAIChooseTarget (Sint32 userId, ABILITY_DEFINITION *action)Picks the target of an enemy's ability, or a confused unit's, at random among those it would affect; a single-target attack by an enemy with a strategy favours the strongest.

Description

The targets an enemy's or a confused unit's ability picks. Part of battle.c.

Macros in detail

COUNT_STUN_SLOT

#define COUNT_STUN_SLOT(unit, count)

Definition at lines 115 and 119 of file battle_targeting.c.

COUNT_PARTIAL_CURES

#define COUNT_PARTIAL_CURES(unit, count)

Counts the statuses of unit that Restore's count takes: delusion, COUNT_STUN_SLOT's (confusion and charm where Restore cures stun, the BUG above), sleep, the Psynergy seal and the Grim Reaper.

Definition at line 129 of file battle_targeting.c.

COUNT_ALL_CURES

#define COUNT_ALL_CURES(unit, count)

Counts the statuses Tonic cures: those, the evil spirit and poison. No enemy has Tonic.

Definition at line 142 of file battle_targeting.c.

COUNT_POSITIVE_MODIFIERS

#define COUNT_POSITIVE_MODIFIERS(unit, count)

Counts what Break would undo on unit; a raised Agility is not counted.

Definition at line 152 of file battle_targeting.c.

CHECK_EFFECT_TARGET

#define CHECK_EFFECT_TARGET(unit, action, applies, kindIndex)

How worthwhile an enemy's ability is against unit, 0 for pointless: a stat change that can still move, a cure or heal it needs, a status it lacks, a downed unit to revive.

Referenced by btAIChooseTarget().

Definition at line 173 of file battle_targeting.c.

Functions in detail

btAIChooseRandomTarget

Sint32 btAIChooseRandomTarget(Sint32 requireLivingUnit)

Picks a random place: a party member still standing with requireLivingUnit, otherwise any enemy place in use. Returns 0 when there is none.

References gmUnitGetStub() and Sint32.

Referenced by btAIChooseAction().

Definition at line 16 of file battle_targeting.c.

btAIChooseTarget

Sint32 btAIChooseTarget(Sint32 userId, ABILITY_DEFINITION *action)

Picks the target of an enemy's ability, or a confused unit's, at random among those it would affect; a single-target attack by an enemy with a strategy favours the strongest.

References gmEnemyGetDefinitionStub(), gmUnitGetStub() and Sint32.

Referenced by btAIChooseAction().

Definition at line 312 of file battle_targeting.c.