src/battle/battle_ability.c
Applying an ability to each of its targets: damage, healing, statuses, stat changes, Djinn and special effects. More…
Included by battle.c.
Macros
| Name | Description | |
|---|---|---|
#define | AGILITY_STAGE_DOUBLED 8 | Zephyr's Agility stage, beyond the usual highest: twice the Agility. |
#define | STAT_CHANGE_TURNS 7 | The turns a stat change or a status lasts; a status or a lowered stat may end sooner. |
#define | AGILITY_CHANGE_TURNS 5 | |
#define | STATUS_TURNS 7 | |
#define | REGENERATE_TURNS 5 | |
#define | CURSE_TURNS 7 | The Grim Reaper's countdown. |
#define | FULL_RATE 256 | The rate gmBattleCalculatePsynergyPowerStub and gmBattleCalculateRecoveryStub scale by: 256 is 1. |
#define | MESSAGE_NONE -1 | A message operand that shows nothing: the event only waits for the player. |
#define | SUMMON_BONUS_HP_MAX 10000 | A summon's bonus damage counts the target's max HP up to this much. |
#define | IS_PARTY_UNIT (unitId) ((unitId) >= 0 && (unitId) <= ALLY_MAX) | Party unit ids run to ALLY_MAX; enemy units start at FIRST_ENEMY_UNIT. |
#define | ARE_OPPONENTS (unitId, otherId) | Whether two units are on opposite sides: party unit ids are below FIRST_ENEMY_UNIT, enemy ids from it. |
#define | CLAMP_STAT_STAGE (stage) | Holds a stat stage within STAT_STAGE_MIN to STAT_STAGE_MAX. |
#define | PUSH_SIDE_MESSAGE (unitId, partyMessage, enemyMessage) | Pushes one message for a unit of the party and another for an enemy. |
#define | REDUCE_BY_GUARD (damage, unit) | A guarding unit takes half the damage, two fifths behind Shade, or a tenth behind Total Defense. |
#define | DEFENSE_HALVED 1 | defenseCut: how much of the target's Defense an attack counts. |
#define | DEFENSE_IGNORED 2 | Raiden's Wrath and Trident: none |
#define | ITEM_ELEMENT_POWER 100 | The element power an item, or an ability with no element, acts with. |
#define | DJINN_BONUS_CHANCE 30 | An unleashed Djinni gives the Djinn bonus (more coins and experience, and a likelier item, from the enemies that fall) against a target weakest to its element, with a chance in percent of the user's power less the target's resistance, plus this many. |
Functions
| Name | Description | |
|---|---|---|
Bool | btAbilityEffectAppliesToDowned (Sint32 effect) | Returns 1 for an effect that still applies when the ability's damage has just knocked its target out: the drains, which give the damage they dealt back to the user. |
Bool | btUnitKeepsOneHp (Sint32 unitId) | Returns 1 for a unit no blow may fell, which is left 1 HP: Agatio and Karst in their first battle. |
void | btPartyInsertUnitCentered (Uint16 *list, Sint32 unit) | Puts unit into a unit list at the removed place nearest the list's divider, or appends it: where a Star Magician's ball takes its place. |
Sint32 | btAbilityApplyToTarget (BATTLE_PLAN *plan, Sint32 slot) | Applies the action's ability to one of its targets, slot, in the seven steps of README.md's "How an ability resolves", queueing what playback will show. |
Uint32 | btAbilityIsPsynergy (Sint32 abilityId) | Returns 1 for abilities that cost PP, and for Psy Drain whatever its cost. |
Description
Applying an ability to each of its targets: damage, healing, statuses, stat
changes, Djinn and special effects. Part of battle.c.
Macros in detail
AGILITY_STAGE_DOUBLED
#define AGILITY_STAGE_DOUBLED 8
Zephyr's Agility stage, beyond the usual highest: twice the Agility.
Referenced by btAbilityApplyToTarget().
Definition at line 5 of file battle_ability.c.
STAT_CHANGE_TURNS
#define STAT_CHANGE_TURNS 7
The turns a stat change or a status lasts; a status or a lowered stat may end sooner.
Referenced by btAbilityApplyToTarget().
Definition at line 9 of file battle_ability.c.
AGILITY_CHANGE_TURNS
#define AGILITY_CHANGE_TURNS 5
Referenced by btAbilityApplyToTarget().
Definition at line 10 of file battle_ability.c.
STATUS_TURNS
#define STATUS_TURNS 7
Referenced by btAbilityApplyToTarget().
Definition at line 11 of file battle_ability.c.
REGENERATE_TURNS
#define REGENERATE_TURNS 5
Referenced by btAbilityApplyToTarget().
Definition at line 12 of file battle_ability.c.
CURSE_TURNS
#define CURSE_TURNS 7
The Grim Reaper's countdown.
Referenced by btAbilityApplyToTarget().
Definition at line 14 of file battle_ability.c.
FULL_RATE
#define FULL_RATE 256
The rate gmBattleCalculatePsynergyPowerStub and gmBattleCalculateRecoveryStub
scale by: 256 is 1.
Referenced by btAbilityApplyToTarget().
Definition at line 18 of file battle_ability.c.
MESSAGE_NONE
#define MESSAGE_NONE -1
A message operand that shows nothing: the event only waits for the player.
Referenced by btAbilityApplyToTarget().
Definition at line 21 of file battle_ability.c.
SUMMON_BONUS_HP_MAX
#define SUMMON_BONUS_HP_MAX 10000
A summon's bonus damage counts the target's max HP up to this much.
Referenced by btAbilityApplyToTarget().
Definition at line 24 of file battle_ability.c.
IS_PARTY_UNIT
#define IS_PARTY_UNIT(unitId) ((unitId) >= 0 && (unitId) <= ALLY_MAX)
Party unit ids run to ALLY_MAX; enemy units start at FIRST_ENEMY_UNIT.
Referenced by btAbilityApplyToTarget().
Definition at line 109 of file battle_ability.c.
ARE_OPPONENTS
#define ARE_OPPONENTS(unitId, otherId)
Whether two units are on opposite sides: party unit ids are below
FIRST_ENEMY_UNIT, enemy ids from it.
Referenced by btAbilityApplyToTarget().
Definition at line 113 of file battle_ability.c.
CLAMP_STAT_STAGE
#define CLAMP_STAT_STAGE(stage)
Holds a stat stage within STAT_STAGE_MIN to STAT_STAGE_MAX.
Referenced by btAbilityApplyToTarget().
Definition at line 117 of file battle_ability.c.
PUSH_SIDE_MESSAGE
#define PUSH_SIDE_MESSAGE(unitId, partyMessage, enemyMessage)
Pushes one message for a unit of the party and another for an enemy.
Referenced by btAbilityApplyToTarget().
Definition at line 126 of file battle_ability.c.
REDUCE_BY_GUARD
#define REDUCE_BY_GUARD(damage, unit)
A guarding unit takes half the damage, two fifths behind Shade, or a tenth behind Total Defense.
Referenced by btAbilityApplyToTarget().
Definition at line 136 of file battle_ability.c.
DEFENSE_HALVED
#define DEFENSE_HALVED 1
defenseCut: how much of the target's Defense an attack counts.
Torch: half
Referenced by btAbilityApplyToTarget().
Definition at line 151 of file battle_ability.c.
DEFENSE_IGNORED
#define DEFENSE_IGNORED 2
Raiden's Wrath and Trident: none
Referenced by btAbilityApplyToTarget().
Definition at line 152 of file battle_ability.c.
ITEM_ELEMENT_POWER
#define ITEM_ELEMENT_POWER 100
The element power an item, or an ability with no element, acts with.
Referenced by btAbilityApplyToTarget().
Definition at line 155 of file battle_ability.c.
DJINN_BONUS_CHANCE
#define DJINN_BONUS_CHANCE 30
An unleashed Djinni gives the Djinn bonus (more coins and experience, and a likelier item, from the enemies that fall) against a target weakest to its element, with a chance in percent of the user's power less the target's resistance, plus this many.
Referenced by btAbilityApplyToTarget().
Definition at line 161 of file battle_ability.c.
Functions in detail
btAbilityEffectAppliesToDowned
Bool btAbilityEffectAppliesToDowned(Sint32 effect)
Returns 1 for an effect that still applies when the ability's damage has just knocked its target out: the drains, which give the damage they dealt back to the user.
References Sint32.
Referenced by btAbilityApplyToTarget().
Definition at line 29 of file battle_ability.c.
btUnitKeepsOneHp
Bool btUnitKeepsOneHp(Sint32 unitId)
Returns 1 for a unit no blow may fell, which is left 1 HP: Agatio and Karst in their first battle.
References gmUnitGet() and Sint32.
Referenced by btAbilityApplyToTarget() and btUnitProcessActionEnd().
Definition at line 43 of file battle_ability.c.
btPartyInsertUnitCentered
void btPartyInsertUnitCentered(Uint16 *list, Sint32 unit)
Puts unit into a unit list at the removed place nearest the list's divider, or appends it: where a Star Magician's ball takes its place.
References Sint32.
Referenced by btAbilityApplyToTarget().
Definition at line 54 of file battle_ability.c.
btAbilityApplyToTarget
Sint32 btAbilityApplyToTarget(BATTLE_PLAN *plan, Sint32 slot)
Applies the action's ability to one of its targets, slot, in the seven steps of README.md's "How an ability resolves", queueing what playback will show. The Lost Age adds the shields that turn an ability away, the abilities that call reinforcements, and the Djinn and summon effects of its own.
References btAbilityEffectAppliesToDowned(), btEnemyClaimNameLetter(), btEnemyGetFreeUnitId(), btEnemyHasSpriteRoom(), btEnemyLetterFirstOfKind(), btEnemyList(), btFormationGetRandomMember(), btMotionReturnToSpot(), btObjectGet(), btObjectMake(), btObjectPut(), btPartyInsertUnitCentered(), btPlacementRelayoutEnemies(), btPlaybackPush(), btUnitDrainDjinn(), btUnitKeepsOneHp(), gmAbilityGetDefinitionStub(), gmBattleCalculateAttackDamageStub(), gmBattleCalculatePsynergyPowerStub(), gmBattleCalculateRecoveryStub(), gmBattleIsReviveEffectStub(), gmBattleRandomStub(), gmBattleRollEffectSuccessStub(), gmBattleUnitSetStub(), gmUnitAddPpStub(), gmUnitCalculateStub(), gmUnitGet(), gmUnitRecalculateGaugesStub(), MainRoutineStateWork, mnPartyStatusDrawStub(), RangeFalloffEffectChance, RangeFalloffEffectDamage, RangeFalloffEnemyDamage, RangeFalloffHealHp, RangeFalloffHealPp, RangeFalloffPpDamage, RangeFalloffPpLoss, RangeFalloffPsynergyDamage, RangeFalloffSummonDamage, Sint32, syGameFlagGet(), syHeapAllocate() and syHeapRelease().
Referenced by btPlaybackRun() and btStagingRunMessages().
Definition at line 167 of file battle_ability.c.
btAbilityIsPsynergy
Uint32 btAbilityIsPsynergy(Sint32 abilityId)
Returns 1 for abilities that cost PP, and for Psy Drain whatever its cost.
References gmAbilityGetDefinitionStub() and Sint32.
Referenced by btActionRunBuild() and btAIChooseAction().
Definition at line 1850 of file battle_ability.c.