12 s32 minimumDifference;
13 s32 maximumDifference;
23 if (input > maximumDifference)
24 input = maximumDifference;
25 else if (input < minimumDifference)
26 input = minimumDifference;
27 for (pointIndex = 0; pointIndex < pointCount; pointIndex++) {
31 if (pointIndex == pointCount) {
39 multiplierSpan / differenceSpan +
49 return multiplier + 0x100;
61 return (seed << 8) >> 16;
73 s32 elementDifference) {
78 damage = elementDifference;
84 scaledDamage += 0x1ff;
85 damage = scaledDamage >> 9;
96 s32 powerMultiplier) {
102 scaledPower = scaledPower + 0xffff;
103 return scaledPower >> 16;
117 scaledRecovery = powerMultiplier * scaledRecovery;
118 signedProduct = scaledRecovery;
119 if (signedProduct < 0)
120 signedProduct = signedProduct + 0xffff;
121 return signedProduct >> 16;
150 for (inventorySlot = 0; inventorySlot <
INVENTORY_SLOTS; inventorySlot++) {
153 for (effectIndex = 0; effectIndex < 4; effectIndex++) {
199 effectIndex = effectId - 8;
200 switch (effectIndex) {
244 return 0 - fixedChance;
251 const u8 *weakEffects;
256 for (weaknessIndex = 0; weaknessIndex < 3; weaknessIndex++) {
257 if (*weakEffects == effectId)
263 for (weaknessIndex = 0; weaknessIndex < 3; weaknessIndex++) {
264 if (*weakEffects++ == effectId)
291 s32 effectId,
s32 successScale) {
319 if (unit->
stun == 0 && unit->
sleep == 0 &&
359 score += difference * 3;
371 for (attempt = 0; attempt < attempts; attempt++) {
s32 BattleTarget_IsWeakToEffect(const struct BattleUnit *target, s32 effectId)
Returns 1 when the unit is weak to effect effectId: one of three listed for its enemy kind (EnemyDefi...
s32 RollWeaponUnleash(struct BattleUnit *owner)
Rolls whether a character's weapon unleashes: its chance is the weapon's unleashChance times 5 percen...
s32 Battle_CalcRecovery(s32 power, s32 elementPower, s32 powerMultiplier)
Returns the amount healed: power and powerMultiplier (256 is 1x) times the multiplier for twice the h...
s32 Battle_GetElementMultiplier(s32 input, s32 halve)
Returns the multiplier (256 = 1x) for an element difference input, read from a five-point line (gElem...
s32 Item_GetEquippedElement(s32 owner)
Returns the element the unit attacks with (ELEMENT_NONE for none): an enemy's comes from its kind,...
s32 Battle_IsReviveEffect(s32 effectId)
Returns 1 for the revive effects (Revive, Quartz, Dew), which only work on a downed unit.
s32 Battle_CalcAttackDamage(s32 attack, s32 defense, s32 addedPower, s32 elementDifference)
Scales max(attack - defense, 0) + twice the action's added power by the elemental multiplier,...
s32 BattleFx_GetBaseSuccessRate(s32 effectId)
Returns the base chance, in percent, of effect effectId.
s32 BattleRandom(void)
The battle's random number generator, the same linear congruential one as Random16 with its own seed.
s32 BattleFx_RollSuccess(s32 caster, s32 target, s32 resistanceCategory, s32 effectId, s32 successScale)
Rolls whether effect effectId takes hold on target: it fails at once when there is nothing for it to ...
s32 Battle_CalcPsynergyPower(s32 power, s32 elementDifference, s32 powerMultiplier)
Returns the power of Psynergy: power times the multiplier for the element difference (power minus res...
s32 Equipment_GetUnleashRateBonus(struct BattleUnit *unit)
Returns the unleash chance, in percent, that a unit's equipment adds (ITEM_EFFECT_ADD_UNLEASH_CHANCE)...
u32 BattleRandomPercent(void)
Returns a battle random number from 0 to 99.
@ ABILITY_EFFECT_LEAVE_ONE_HP
Severe Blow, Thrash.
@ ABILITY_EFFECT_SEAL_2_TURNS
Luff.
@ ABILITY_EFFECT_HAUNT
Haunt.
@ ABILITY_EFFECT_INSTANT_DEATH
Condemn.
@ ABILITY_EFFECT_ATTACK_DOWN
Blunt.
@ ABILITY_EFFECT_POISON
Taint.
@ ABILITY_EFFECT_HALVE_DEFENSE
Torch.
@ ABILITY_EFFECT_SEAL
Bind: Psynergy sealed.
@ ABILITY_EFFECT_CURE_ALL
Tonic.
@ ABILITY_EFFECT_REVIVE_HALF
Quartz.
@ ABILITY_EFFECT_DRAIN_HP
Drain.
@ ABILITY_EFFECT_STUN
Paralyze.
@ ABILITY_EFFECT_SLEEP
Sleep.
@ ABILITY_EFFECT_CHARM
Charm.
@ ABILITY_EFFECT_RESISTANCE_DOWN_2
Weaken.
@ ABILITY_EFFECT_RESTORE
Restore, Elixir.
@ ABILITY_EFFECT_REVIVE_80
Dew: 80% of max HP.
@ ABILITY_EFFECT_ATTACK_DOWN_2
Dull.
@ ABILITY_EFFECT_DEFENSE_DOWN
Debilitate.
@ ABILITY_EFFECT_CURSE
Curse: the Grim Reaper's countdown.
@ ABILITY_EFFECT_RESISTANCE_DOWN
Enfeeble.
@ ABILITY_EFFECT_REVIVE
Revive, Water of Life: full HP.
@ ABILITY_EFFECT_DELUSION
Delude.
@ ABILITY_EFFECT_DRAIN_PP
Psy Drain.
@ ABILITY_EFFECT_CONFUSION
Confuse.
@ ABILITY_EFFECT_DEADLY_POISON
Poison.
@ ABILITY_EFFECT_CURE_POISON
Cure Poison, Antidote.
@ ABILITY_EFFECT_DEFENSE_DOWN_2
Impair.
struct ClassDefinition * Class_GetDefinition(s32 classId)
Returns class classId's definition: its series, element requirements, stat multipliers and the Psyner...
s32 Enemy_GetAttackElement(struct BattleUnit *unit)
Returns the element an enemy attacks with, from its element preset.
s32 Unit_GetElementLevel(s32 owner, s32 element)
Returns a unit's level in element (0 to 3).
const s16 gElement_PowerResistCurve[5][2]
What every part of the game object shares: its includes and the inventory helper two parts use.
struct ItemDefinition * Inventory_GetEquippedDefinition(struct BattleUnit *unit, s32 type)
Returns the definition of the unit's equipped item of type, or NULL.
struct ItemDefinition * Item_GetDirect(s32 item)
Returns item item's definition; an inventory entry may be passed, its equipped and quantity bits are ...
@ ITEM_TYPE_WEAPON
swords, axes, maces, rods and staffs
@ ITEM_EFFECT_ADD_UNLEASH_CHANCE
percent added to the weapon's unleash
A unit in battle: a party member's or an enemy's stats, Psynergy, items, Djinn and ailments.
u8 luck
0 to 99 (UnitCalc)
u8 grimReaper
The Grim Reaper's countdown: 7 when cursed, down one at each turn's end; at 0 the unit falls.
u8 psySeal
bits: 7..3 Luff (16 when cast, minus 8 a turn) | 2..0 Bind's turns (7 when cast).
s8 poison
1 poisoned, 2 deadly poison
s16 hp
current HP, 0 when downed
u8 classId
Who the unit is: a character's id (ISAAC to JENNA, below 8) or an enemy's id (BattleUnitSet).
u8 classIndex
The character's class, worked out from its Djinn (Unit_UpdateClass); 0 marks an enemy,...
u16 inventory[15]
Items held, one entry each: bits 15..11 quantity | 10 broken | 9 equipped | 8..0 item id (INVENTORY_*...
u8 delusion
Delusion to sleep: the turns each status has left, 7 when it lands; each may end sooner at the end of...
u8 unk50[4]
[0] to [2]: the ability effects the class is weak to (BattleTarget_IsWeakToEffect); [3] is not read t...
An item's definition: its price, type, who can equip it, its bonuses and unleash, its effects and the...
s32 element
a weapon's attack element; 4 for none
u16 unleashAction
the action a weapon unleashes, or 0
struct ItemEffect effects[4]
what it does while equipped
u8 unleashChance
in steps of 5 percent
u8 kind
enum ItemEffectKind; 0 for none
s8 amount
what the kind adds or scales by
const u8 * Enemy_GetDefinition(s32 selector)
Returns the definition of enemy selector - 8; an id past the first 250 gives the first.
struct BattleUnit * UnitGet(u32 owner)
Returns the unit record of owner: 0 to 7 are the playable characters in the game state,...