-
Notifications
You must be signed in to change notification settings - Fork 1
Evade
Clément Gallet edited this page Jun 18, 2014
·
2 revisions
For every frame in battle, function C2/111B
is called. Every two calls of that function, battle timer ($3A3E
, 16-bit integer) is incremented and function C2/5A83
is called.
For every call of C2/5A83
:
- if (low byte of battle timer % 16) n is < 10, manage entity number n (0-3: characters, 4-9: enemies)
- increment entity's counter (
$3ADC,X
) by ATB multiplier (64 for normal, 84 for hasted, 32 for slowed) - if entity's counter is over 255:
- remove 256 from entity's counter
- if entity tries to run, call function (
C2/5C1B
):- if run difficulty (
$3A3B
, set atC2/5C73
) is non zero:- increment entity's "run success" variable by a random number between 1 and a character specific value (see
C2/0EC2
for how this value is set) - if entity's "run success" variable is >= run difficulty, character is successfully running (set corresponding bit in
$3A38
)
- increment entity's "run success" variable by a random number between 1 and a character specific value (see
- else (preemptive, side attack)
- character is automatically running (also set corresponding bit in
$3A38
) - queue the flee command (see
$4E91
with A = 0x2A)
- character is automatically running (also set corresponding bit in
- if run difficulty (
- increment entity's counter (
- else
- subtract 10 from n
- call function n:
- 1/ Enemy Roulette completion (
C2/5AFA
) - 2/ Increment time counters (
C2/5AFC
) - 3/ Nothing
- 4/ Nothing
- 5/ Nothing
- 6/ Check if characters run (
C2/5B04
):- if (low byte of battle timer & 0x70) == 0 and some characters are successfully running
- queue the flee command (see
$4E91
with A = 0x2A)
- queue the flee command (see
- if (low byte of battle timer & 0x70) == 0 and some characters are successfully running
- 1/ Enemy Roulette completion (
C2/0EC2: BF B5 7C ED LDA $ED7CB5,X (character start level info)
C2/0EC6: 29 03 AND #$03
C2/0EC8: 49 03 EOR #$03
C2/0ECA: 1A INC
C2/0ECB: 1A INC
C2/0ECC: 8D DC 11 STA $11DC (invert and add 2. this gives you
5 - (bottom two bits of Level byte) ,
the amount to add to the character's
"Run Success" variable.)
...
C2/28C9: A5 DC LDA $DC ($11DC)
C2/28CB: 9D 71 3D STA $3D71,X (Amount to add to character's "Run Success" variable. has range
of 2 thru 5. higher means that, on average, they can run away
quicker from battle.)
C2/5C73: C2 20 REP #$20 (Set 16-bit Accumulator)
C2/5C75: A0 08 LDY #$08 (the following loop nulls the list of enemy
names [and quantities, shown in FF6j but not FF3us]
that appears on the bottom left corner of the
screen in battle?)
C2/5C77: 7B TDC (A = 0000h)
C2/5C78: 99 13 20 STA $2013,Y (store to $2015 - $201B, each having a 16-bit
monster quantity)
C2/5C7B: 3A DEC (A = FFFFh)
C2/5C7C: 99 0B 20 STA $200B,Y (store to $200D - $2013, each having a 16-bit
monster ID)
C2/5C7F: 88 DEY
C2/5C80: 88 DEY
C2/5C81: D0 F4 BNE $5C77 (iterate 4 times, as there are 4 list entries)
C2/5C83: E2 20 SEP #$20 (Set 8-bit Accumulator)
C2/5C85: A9 06 LDA #$06
C2/5C87: 14 B1 TRB $B1 (clear Can't Run and Can't Escape)
C2/5C89: AD 1F 20 LDA $201F (get encounter type. 0 = front, 1 = back,
2 = pincer, 3 = side)
C2/5C8C: C9 02 CMP #$02
C2/5C8E: D0 14 BNE $5CA4 (branch if not pincer)
C2/5C90: AD AC 2E LDA $2EAC (bitfield of enemies in left "clump".
set in function C1/1588.)
C2/5C93: 2D 2F 2F AND $2F2F (compare to bitfield of remaining enemies?)
C2/5C96: F0 0C BEQ $5CA4 (branch if no enemy on left side remaining)
C2/5C98: AD AD 2E LDA $2EAD (bitfield of enemies in right "clump".
set in function C1/1588.)
C2/5C9B: 2D 2F 2F AND $2F2F (compare to bitfield of remaining enemies?)
C2/5C9E: F0 04 BEQ $5CA4 (branch if no enemy on right side remaining)
C2/5CA0: A9 02 LDA #$02
C2/5CA2: 04 B1 TSB $B1 (set Can't Run)
C2/5CA4: 9C 3B 3A STZ $3A3B (set Run Difficulty to zero)
C2/5CA7: 9C CA 3E STZ $3ECA (set Number of Unique enemy names who are currently
active to zero? this variable will have a max
of 4, even though the actual number of unique
enemy names can go to 6.)
C2/5CAA: B9 A8 3A LDA $3AA8,Y
C2/5CAD: 4A LSR
C2/5CAE: 90 54 BCC $5D04
C2/5CB0: B9 21 30 LDA $3021,Y
C2/5CB3: 2C 3A 3A BIT $3A3A
C2/5CB6: D0 4C BNE $5D04
C2/5CB8: 2C 09 34 BIT $3409
C2/5CBB: F0 47 BEQ $5D04
C2/5CBD: B9 EC 3E LDA $3EEC,Y (get monster's status byte 1)
C2/5CC0: 89 C2 BIT #$C2
C2/5CC2: D0 40 BNE $5D04 (branch if Zombie, Petrify, or Wound is set)
C2/5CC4: B9 88 3C LDA $3C88,Y (monster Misc/Special Byte 2. normally accessed as
"$3C80,Y" , but we're only looking at enemies here.)
C2/5CC7: 4A LSR (put "Harder to Run From" bit in Carry flag)
C2/5CC8: 89 04 BIT #$04 (is "Can't Escape" bit set in monster data? [called
"Can't Run" in FF3usME])
C2/5CCA: F0 04 BEQ $5CD0
C2/5CCC: A9 06 LDA #$06
C2/5CCE: 04 B1 TSB $B1 (if so, set both Can't Run and Can't Escape. the latter
will stop Warp, Warp Stones, and Smoke Bombs. even though
a failed Smoke Bomb gives a "Can't run away!!" rather than
a "Can't escape!!" message, it just looks at the
Can't Escape bit. )
C2/5CD0: 7B TDC
C2/5CD1: 2A ROL
C2/5CD2: 38 SEC
C2/5CD3: 2A ROL
C2/5CD4: 0A ASL (if "Harder to Run From" was set, A = 6. if not, A = 2.)
C2/5CD5: 6D 3B 3A ADC $3A3B
C2/5CD8: 8D 3B 3A STA $3A3B (add to Run Difficulty)
C2/5CDB: B9 9D 3C LDA $3C9D,Y (normally accessed as $3C95,Y , but we're only looking
at enemies here.)
C2/5CDE: 89 04 BIT #$04 (is "Name Hidden" property set?)
C2/5CE0: D0 22 BNE $5D04 (branch if so)
C2/5CE2: C2 20 REP #$20
C2/5CE4: A2 00 LDX #$00
C2/5CE6: BD 0D 20 LDA $200D,X (entry in list of enemy names you see on bottom left
of screen in battle?)
C2/5CE9: 10 09 BPL $5CF4 (branch if this entry has already been assigned an
enemy ID)
C2/5CEB: B9 88 33 LDA $3388,Y (get entry from Enemy Name structure, initialized
in function C2/2C30 [using $3380], for our current
monster pointed to by Y. this structure has a list
of enemy IDs for the up to 6 enemies in a battle,
but it's normalized so enemies with matching names have
matching IDs.)
C2/5CEE: 9D 0D 20 STA $200D,X (save it in list of names?)
C2/5CF1: EE CA 3E INC $3ECA (increment the number of unique names of active enemies?
this counter will max out at 4, because the in-battle
list shows a maximum of 4 names, even though the actual
# of unique enemy names goes up to 6.
this variable is used by the FC 10 monster script
command.)
C2/5CF4: D9 88 33 CMP $3388,Y (compare enemy ID previously in this screen list entry
to one in the Name Structure entry. they'll match for
sure if we didn't follow the branch at C2/5CE9.)
C2/5CF7: D0 05 BNE $5CFE (if they don't match, skip to next screen list entry)
C2/5CF9: FE 15 20 INC $2015,X (they did match, so increase the quantity of enemies
who have this name. FF6j displayed a quantity in
battle. FF3us increased enemy names from 8 to 10
characters, so it never shows the quantity.)
C2/5CFC: 80 06 BRA $5D04 (exit this loop, as our enemy ID [as indexed by Y] is
already in the screen list.)
C2/5CFE: E8 INX
C2/5CFF: E8 INX
C2/5D00: E0 08 CPX #$08
C2/5D02: 90 E2 BCC $5CE6 (iterate 4 times, as the battle enemy name list has
4 entries.)
C2/5D04: E2 20 SEP #$20
C2/5D06: C8 INY
C2/5D07: C8 INY
C2/5D08: C0 0C CPY #$0C
C2/5D0A: 90 9E BCC $5CAA (iterate for all 6 monsters)
C2/5D0C: AD 1F 20 LDA $201F (get encounter type. 0 = front, 1 = back,
2 = pincer, 3 = side)
C2/5D0F: C9 03 CMP #$03
C2/5D11: F0 06 BEQ $5D19 (branch if side attack)
C2/5D13: A5 B0 LDA $B0
C2/5D15: 89 40 BIT #$40
C2/5D17: F0 03 BEQ $5D1C (branch if not Preemptive attack)
C2/5D19: 9C 3B 3A STZ $3A3B (set Run Difficulty to zero)
C2/5D1C: AD 42 3A LDA $3A42 (list of present and living characters acting
as enemies?)
C2/5D1F: F0 04 BEQ $5D25 (branch if none)
C2/5D21: A9 02 LDA #$02
C2/5D23: 04 B1 TSB $B1 (set Can't Run)
C2/5D25: 60 RTS