Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Brief summary of FF4 $03:C499, which handles physical damage calculation.
- This summary is focused on the actual calculation of physical damage and
- status effects, and as such, ignores the few modifications to the
- audiovisual script the routine does.
- 1. If the acting slot has darkness, reduce accuracy by one-half.
- 2. If the acting slot is in the the back row and not long range or jumping,
- reduce accuracy by one half.
- 3. If the middle slot, multiply accuracy by 5/4. If a monster, this is if
- they are in monster slot 0. This changes based on formation.
- 4. If the target is in the back row and the actor is not long range or jumping,
- reduce accuracy by one half.
- 5. Calculate hits from accuracy and multiplier. A hit is successful if RND(0, 98)
- is less than the accuracy.
- 6. Check for barrier or image status on the target. The following checks occur
- only if neither:
- a. If the target has darkness, reduce their evade by one half.
- b. If the target is in slot 0 (either character or monster), multiply their
- evade by 5/4.
- c. Calculate the number of hits the target will evade based on their defense
- multiplier and evade. If the target is a toad or small, their multiplier
- is set to zero. An evade attempt is successful if RND(0,98) is less than
- the evade stat.
- 7. Calculate the total number of hits by subtracting the number of evaded hits
- (255 if barrier or image) from the number of attack hits.
- 8. If monster target and monsters invincible, pretend it's a miss anyway.
- 9. Continuing for actual hits:
- a. Remove Charm status from the target.
- b. Determine the elemental multiplier. In order, check for these matches:
- strong weakness, regular weakness, immunity, resistance. If any match, set
- the multiplier to 8, 4, 0 or 1, respectively. Any further checks are
- skipped. The default value of the multiplier is 2.
- c. Determine the race multiplier. If a character is attacking a monster and
- it matches, the value is 8. If a monster is attacking a character and it
- matches, the value is 1. Otherwise, it defaults to 2.
- d. If the actor is berserked, set the attack power to 3/2 the original value.
- e. If the actor is jumping or charging, multiply the attack power by two.
- f. If the actor is cursed, divide the attack power by two.
- g. If the target is in the back row, multiply their defense power by two.
- h. If the target is cursed, divide their defense power by two.
- i. If RND(0,98) is less than the actor's critical rate, it's a critical hit.
- j. If the target is defending, multiply their defense power by two.
- k. If the target is charging, divide their defense power by two.
- l. If the actor is a toad or small, set attack power to 1, unset critical.
- m. If the target is a toad or small, multiply attack power by two and set
- defense power to zero.
- n. Calculate actual attack power: power + RND(0, power / 2). If after
- the earlier adjustments, power ends up 512 or greater, the random number
- added is capped at RND(0,255) nonetheless.
- o. Apply elemental multipliers and racial multipliers to that value. Multiplier
- is divided by two. (The 1 case is handled specially to divide the value by
- two.)
- p. Add the actor's critical bonus to the attack power.
- q. Subtract the target's defense power from the attack power. Set it to zero
- if negative.
- r. Multiply the result by the previously calculated number of hits.
- 10. Next, apply any relevant status changes. This only applies if the attack was
- not a miss.
- a. Nothing is done if the target is immune to any of the attacking statuses.
- b. If the target's evade is greater than or equal to the actor's accuracy,
- no status will be applied.
- c. The actor now has X number of chances to land a status, where X is equal to
- the number of hits that were used in the damage portion of the calculation.
- Each chance has an (accuracy - evade) chance of connecting. Only one of
- these needs to connect to pass the check.
- d. If the target is a boss, no status will be applied.
- e. If the target already has any of the statuses in the attacking status,
- no status changes will be applied.
- f. If the target's action timer status byte has any bits set, no status
- changes will be applied.
- g. If the actor is a toad or small, no status changes will be applied.
- h. If attacking with the swoon status and the target monster is undead or a
- machine, no status will be applied.
- i. If the target already has a status with a higher bit value (treating the
- first two status bytes as a single 16-bit little endian value), return
- without applying any status.
- j. Set the pending status bytes to be applied later.
- k. Set the poison timer if applying poison status. Timer length is equal to
- vitality + 20 for characters or $2F + 20 for monsters (both subject to
- the speed modifier).
- l. Set the action timer if applying the sleep/paralyze statuses. If so, no
- further checks are done. The timer value is (300 - (will * 4)) / 6 for
- characters, and the same for monsters except will is replaced with $2F.
- The speed modifier is applied before the division by 6. If will/$2F * 4
- overflows beyond a single byte, any bits above the 8-bit limit will be
- ignored, leading to odd behavior once will exceeds 63.
- m. Apply any gradual petrification. The timer is set as with sleep/paralyze.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement