Author Topic: [FF7] Action Data Structure  (Read 6253 times)

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
[FF7] Action Data Structure
« on: 2012-02-29 14:32:24 »
So I've been trying my darnedest to figure out new battle addresses and reverse damage equations and such. A long while back I found this structure of data that is used over 1200 times in the exe and is only used during battle. This seems to be populated per-target of an action whenever a battle actor initiates a command. I'd put this on the wiki, but there doesn't seem to be a place for it since the wiki doesn't deal with direct memory.

This is all for the PC's structure, first of all. The actual data is stored at 0x99E308, but there is a constant pointer to that address at 0x99CE0C that is what's always referenced. The next mapped memory address appears to be 0x99F308, but it hardly uses any of that. It consists solely of 32-bit DWords even if the value stored is a single byte. It uses 256 bytes for the actor and technical information of the attack then an additional 100 bytes for target data with a 256 byte gap between them. So the valid ranges look like 0 - 260h for the size of the array. I've mapped out quite a bit of it, but some is still eluding me. I thought I'd share what I have so far. For these purposes, "Actor" is the one performing the action.

Code: [Select]
000 - Actor Index (0-2 are playable characters, 4-9 are enemies)
004 - Actor Level
008 - Battle Formation Index?
00C - Command Index
010 - Action Index
014 - Action Data Base (0 for magic, 38h for summon, 48h for E.Skill, something else for scene.bin and limit attacks)
018 - Allowed Targets (seems to only select non-dead, active targets)
01C - Active Allies
020 - Actor's Command Animation (animation index for current action)
024 - Action Visual Effect
028 - Command Index again?
02C - Action Index again? (lots of repeats)
030 -
034 -
038 - MP Cost
03C - Action Accuracy
040 - Damage Calculation
044 - Action Element
048 - Action Power (typically 16, 2 for morph)
04C - Actor Attack or MAttack (depends on what type of attack it is)
050 - Action Targets (bitmask)
054 - Action Impact Sound
058 - Action Impact Sound again?
05C - Action Impact Sound yet again?
060 - Action Single target Camera index
064 - Action Multiple target Camera index
068 - Action Impact Anim Index
06C - Special Attack Flags
070 - Not used?
074 - Not used?
078 - ?
07C - ?
080 - Inflicting Statuses
084 - Curing Statuses
088 - Toggle Statuses (these are only ones the Action is told to effect, not the ones that actually connect and inflict)
08C - Chance to Affect Statuses
090 - Command Properties (4h - Steal attempt; 2000h - Morph attempt; etc)
094 - Some other flags?
098 - Action Index position in scene
09C - ?
0A0 - Accuracy check function (upper nybble of damage calculation value)
0A4 - Action Damage Function (lower nybble of damage calculation value)
0A8 - ?
0AC - related to magic effects, but I'm not sure what
0B0 - Number of damage calculations?
0B4 - ?
0B8 - number of targets?
0BC - Action Additional Effects
0C0 - Action Additional Effect Magnitude
0C4 - Action Power (copy of 48 above)
0C8 - Actor's current statuses
0CC - Target's Action connect animation
0D0 - ?
0D4 - ? (these two are related somehow
0D8 - Actor's Strength
0DC - Some battle related flags (36h indicates successful escape)
0E0 - ?
0E4 - ?
0E8 - ?
0EC - ?
0F0 - AllowedMagic[7] (I don't know what that means)
0F4 - ?
0F8 - AllowedMagic[3] (might be allowed multiple toggles)
0FC - ?
...
<these get changed per target>
200 - ??
204 - Character Map address (playable chars only)
208 - Target Index
20C - Formation Slot (enemy only)
210 - Target Def/MagDefense
214 - Damage taken from Action
218 - lots of flags (1h - successful hit; 4h - steal attempt; 20h - some always hit check?; 4000h - Barrier active; 8000h - MBarrier active)
21C - ?
220 - Some flags (1h - damage is healed; 2h - Critical Hit; 4h - Damages MP)
224 - Target Reaction Animation (copied from CC above I think)
228 - Target's current statuses
22C - Target's status immunities
230 - Some other weird flags (1h and 80h are used by the "Recover" damage calculation)
234 - more flags (1h - back exposed; 2h - multiple targets?)
238 - Status related (statuses successfully inflicts?)
23C - Action removes these statuses from target
240 - Status related also (statuses toggled?)
244 - ?
248 - Sound to play
24C - Action Animation to use
250 - ?
254 - Target's Level
258 - Target's HP
25C - Target's MP
260 - Action Accuracy

That's all I got. If anyone has any more info on this I'd like to know.

Akari

  • *
  • Posts: 766
    • View Profile
Re: [FF7] Action Data Structure
« Reply #1 on: 2012-03-02 04:43:45 »
Here is mine notes on this.

Code: [Select]
1f800000 attacker id.
1f800004 attacker level
1f800008 init with -1. Store enemy index here if this is enemy attack.
1f80000c action id. (0x20 - enemy attack)
1f800010 attack index
1f800014 init with -1. Store attacker id here if specified attack was magic, summon or enemy skill and player has it.
1f800018 target mask
1f80001c init with 1. Active Allies???
1f800020 animation script id to play.
1F800024 copy D byte from attack data here. (Attack effect id)
1f800028 action id.
1f80002c attack id.
1f800030 attacker mask.
1f800038 -1. MP cost.
1f80003c hit%
1f800040 damage formula id (default action damage formula id). Copy weapon damage formula id here.
1F800044 attack elements mask.
1f800048 power modifier.
1f80004c base damage.
1F800050 init with 0xFF. Set target type data from kernel if action id < 0x20. Target type data. (self/all/1target)
1f800054 init witn -1. Copy 6th byte from attack data here (normal attack sound).
1f800058 init with -1. Copy 6th byte from attack data here (critical attack sound).
1f80005c init with -1. Copy 6th byte from attack data here (miss attack sound).
1f800060 init with -1. Load default 8th byte here. Copy 8th 2bytes from attack data here or 0x0c from weapon attack. (Camera movement single).
1f800064 init with -1. Load default Ath byte here. Copy Ath 2bytes from attack data here or 0x0c from weapon attack. (Camera movement multiple).
1f800068 init with -1. Impact effect id.
1f80006c init with -1. Special attack flags. 0x0004 - magic attack.
                                             0x0002 - if not set - add bit 0x2000 to 0x220
                                             0x0080 - if not set - ignore status effect defense when attempting to inflict.
                                             0x0200 - if not set - can be reflected
                                             0x0400 - if not set - ignore defense (if this bit is set we calculate defense)
                                             0x2000 - if not set - critical hit in case of physical damage calculation.
1f800078 we add here target unit mask for current damage calculation if we not attacking self.
1f800080 status to add.
1f800084 status to remove.
1f800088 status to change.
1f80008c init with FF. Status infliction chance (0-255).
1f800090 something from 800a0002 (default action flags). (00000002 - flag checked in funcaa738 function.
                                                          00000004 - if steal as well need to be performed.
                                                          00000010 - check if this == 0 in funcab674 function.
                                                          00000040 - if hp absorb need to be performed.
                                                          00000080 - if mp absorb need to be performed.
                                                          00000200 - seted if there is no target (for player) or more than one target)
                                                          00000800 - if add cut need to be performed.
                                                          00020000 - add if long range materia equipped in something related to target rows in funcab674.
                                                          00080000 - if this flag is set - do something in action_type_09 function.
                                                          00400000 - add bit if unknown data in large function file exist.
                                                          00100000 - add bit if no mega all stars left (force single target?).
                                                          01000000 - if this bit is set we can attack dead units too.
1f800094 target mask
1f800098 attack index. Attack index in group magic summon enemy skill, limit or attack index in scene data.
1f8000a0 formula upper
1f8000a4 formula lower
1f8000a8 reset it after action if we use sense.
1f8000ac store high byte of unknown data seted in large_function file + 3 if it not 0 (if greater than 8 store 8). Quater damage.
1f8000b0 number of multiple attacks.
1f8000b4 init with 1. Time to caclulate whole cycle of attack (only for 2x and 4x cut).
1F8000b8 number of targets (counted with target mask).
1f8000bc init with -1. Copy 12th byte from attack data here (Additional effects). Set this with special byte related to lower damage function if upped damage function 0xa.
1F8000c0 copy 13 byte from attack data here (additional effect modifier).
1f8000c4 store power modifier here.
1f8000c8 attacker status.
1f8000cc copy 2nd byte from attack data here. Hurt action id?
1f8000d0 init with 0xFFFFFFFF.
1f8000d4 init with 0xFFFFFFFF.
1f8000d8 *2 used in 0x09 lower formula as base damage.
1f8000dc init with -1. String to display.
1f8000e0 init with 0. This is increment when we do damage.
1f8000e4 init with -1.
1f8000e8 set ((w[1f8000f0] >> 5) * 0xa) if w[1f8000f0] & 0xe0 != 0. Mp Turbo stars * 0xa. Mp boost%
1f8000ec store target mask here.
1f8000f0 store lower byte of unknown data seted in large_function file. Set flags (0x01 - mp absorb, 0x02 - hp absorb, 0x08 - steal as well, 0x10 - added cut) from unit data for actions that we perform if priority 5 or 6.
1f8000f4 store current unit id here in damage cycle.
1f8000f8 store high byte of unknown data seted in large_function file here if it not 0.
1f8000fc copy number of multiple attacks here.
1f800200 address 800f5bb8 + target * 44.
1f800204 address 800f5e60 + target * 34 or -1 in case of not player.
1f800208 target entity id.
1f80020c store -1. Set enemy index here (1 2 3) (only in case of enemy).
1f800210 init with 0. Calculated defense.
1f800214 init with 0. Calculated damage.
1f800218 init with 1f800090 flags. 0x0001 if we have power modifier 0 and we not add/remove/change statuses and if unit is undamagable (auto-miss).
                                   0x0002 add this bit in case of lower function 0 or if we done no damage.
                                   0x0020 then we hit target for sure in case of physical attack.
1f80021c init with 0.
1f800220 init with 0. attack flag. (0x0001 - heal, 0x0002 - critical damage, 0x0004 - damage to MP)
1f800224 store hurt action id. Store 33 here if 1f800048 == 0.
1f800228 target status.
1f80022c target status immunities mask.
1f800230 init with 0. mask of immunities to current attack (0x01 - death, 0x04 - double, 0x10 - half, 0x20 - nullify, 0x40 - absorb, 0x80 - full cure)
1f800234 init with 0. flags. 0x0001 - attack from back
                             0x0002 in funcb0c14 in upper_function_00.
1f800238 init with 0. Copy status to add here.
1f80023c init with 0. Copy status to remove here. Flags based on statuses of target. 0x0004 - target sleeps.
                                            0x0040 - target confused
                                            0x00a0 - target is manipulated
1f800240 init with 0. Copy status to change here.
1f800244 init with 0. Statuses to add/remove/change (united mask).
1f800248 init with -1. Store attack (impact sound here).
1f80024c init with -1. Store impact effect id here.
1f800250 init with -1. store fffffffe here if need to we kill target instantly (due to 1f800230 death). fffffffd if we recover. Or copy damage here from 1f800214.
1f800254 init with target level.
1f800258 init with target current hp.
1f80025c init with target current mp.
1f800260 init with 1f80003c hit%.

nfitc1

  • *
  • Posts: 3011
  • I just don't know what went wrong.
    • View Profile
    • WM/PrC Blog
Re: [FF7] Action Data Structure
« Reply #2 on: 2012-03-02 06:26:56 »
Awesome. I'd figured you'd have something on this. I'm glad you chimed in. You have a lot of values that I hadn't fully traced yet. Thanks!

Akari

  • *
  • Posts: 766
    • View Profile
Re: [FF7] Action Data Structure
« Reply #3 on: 2012-03-02 07:57:31 »
Create pages in wiki about structures layout in ram. It will be useful for me too. Lately I work on FFIX, but soon I return to complete battle reverse in FFVII. =)