Difference between revisions of "FF7/Battle/Battle scenes"

From Final Fantasy Inside
< FF7‎ | Battle
Jump to navigation Jump to search
my_wiki>NFITC1
m (Data file format)
m (84 revisions imported)
 
(35 intermediate revisions by 5 users not shown)
Line 22: Line 22:
 
order to find these files in scene.bin, you have to know that the file is structured with blocks exactly 0x2000 bytes in length. In the first table (scene.bin block), you will see what contains a block. Blocks are concatenated with each other to form the scene.bin file. So if you want to extract data from scene.bin, you'll need to find the correct blocks and to extract the gziped files from it. After that you simply ungzip those files and you'll find 256 files, with a length is 7808 bytes. Known information about those files can be found in the second table (The Data File specification). Because extracting file manually would be a pain, several tools was developed in order to help you. You can use [http://spinningcone.com/ff/stormmedia/projects/SceneReader.zip Scene Reader] for example, it's a win32 tool to extract and repack scene.bin archive.
 
order to find these files in scene.bin, you have to know that the file is structured with blocks exactly 0x2000 bytes in length. In the first table (scene.bin block), you will see what contains a block. Blocks are concatenated with each other to form the scene.bin file. So if you want to extract data from scene.bin, you'll need to find the correct blocks and to extract the gziped files from it. After that you simply ungzip those files and you'll find 256 files, with a length is 7808 bytes. Known information about those files can be found in the second table (The Data File specification). Because extracting file manually would be a pain, several tools was developed in order to help you. You can use [http://spinningcone.com/ff/stormmedia/projects/SceneReader.zip Scene Reader] for example, it's a win32 tool to extract and repack scene.bin archive.
  
Also note, that in [[FF7/Kernel/Kernel.bin|kernel.bin]] there is a look-up table for scene.bin, which tells how many files there are in each section of scene.bin. You need to update it every time you repack the file and something changes. The table is at offset 0x0F1C of kernel.bin file. You can use [http://forums.qhimm.com/index.php?topic=7127.0 SceneFix] program, which'll update the table for you.
+
Also note, that in [[FF7/Kernel/Kernel.bin|kernel.bin]] there is a look-up table for scene.bin, which tells how many files there are in each section of scene.bin. You need to update it every time you repack the file and something changes. The table is at offset 0x0F1C of the third section of the kernel.bin file. You can use [http://forums.qhimm.com/index.php?topic=7127.0 SceneFix] program, which'll update the table for you.
  
 
We have 1024 possible battle numbers: 0 - 1023. Each group of *4* Battle Numbers refers to a
 
We have 1024 possible battle numbers: 0 - 1023. Each group of *4* Battle Numbers refers to a
 
particular Scene file: for instance, Battles 0-3 refer to File 0 in Scene.bin, Battles 4-7 refer to File 1 in Scene.bin, and so forth.
 
particular Scene file: for instance, Battles 0-3 refer to File 0 in Scene.bin, Battles 4-7 refer to File 1 in Scene.bin, and so forth.
 +
 +
 +
====Japanese format====
 +
 +
In the japanese scene.bin, ennemies names and attacks names have a size of 16 bytes, instead of 32 bytes.
 +
  
 
===General file format===
 
===General file format===
Line 88: Line 94:
 
| 0x0008
 
| 0x0008
 
| 4 * 20 bytes
 
| 4 * 20 bytes
| Battle Setup 1 (4 records) ([[#Battle_Setup_1_format|format explanation]])
+
| Battle Setup (4 records) ([[#Battle_Setup_1_format|format explanation]])
 
|-
 
|-
 
| 0x0058
 
| 0x0058
 
| 4 * 48 bytes
 
| 4 * 48 bytes
| Battle Setup 2 (4 records) ([[#Battle_Setup_2_format|format explanation]])
+
| Camera Placement Data (4 records) ([[#Camera_Placement_Data_format|format explanation]])
 
|-
 
|-
 
| 0x0118
 
| 0x0118
Line 112: Line 118:
 
| 0x0298
 
| 0x0298
 
| 184 bytes
 
| 184 bytes
| Enemy Data 1 ([[#Enemy_data_format|format explaination]])
+
| Enemy Data 1 ([[#Enemy_data_format|format explanation]])
 
|-
 
|-
 
| 0x0350
 
| 0x0350
Line 124: Line 130:
 
| 0x04C0
 
| 0x04C0
 
| 32 * 28 bytes
 
| 32 * 28 bytes
| Attack Data (32 records)
+
| Attack Data (32 records) ([[FF7/Attack_data|format explanation]])
 
|-
 
|-
 
| 0x0840
 
| 0x0840
Line 135: Line 141:
 
|-
 
|-
 
| 0x0C80
 
| 0x0C80
| 512 bytes
+
| 2 bytes
| FFh Padding
+
| Formation 1 AI Script Offset
 +
|-
 +
| 0x0C82
 +
| 2 bytes
 +
| Formation 2 AI Script Offset
 +
|-
 +
| 0x0C84
 +
| 2 bytes
 +
| Formation 3 AI Script Offset
 +
|-
 +
| 0x0C86
 +
| 2 bytes
 +
| Formation 4 AI Script Offset
 +
|-
 +
| 0x0C88
 +
| 0 - 504 bytes
 +
| Beginning of Formation AI Data ([[#AI_Data|format explanation]])
 
|-
 
|-
 
| 0x0E80
 
| 0x0E80
Line 151: Line 173:
 
|-
 
|-
 
| 0x0E86
 
| 0x0E86
| varies
+
| 0 - 4090 bytes
| Beginning of AI Data ([[#AI_Data|format explaination]])
+
| Beginning of AI Data ([[#AI_Data|format explanation]])
 
|}
 
|}
  
Line 167: Line 189:
 
| '''Battle location, as follows:'''
 
| '''Battle location, as follows:'''
 
|-
 
|-
|
+
|style="background:rgb(204,204,255)" align="center" colspan="2" rowspan="2" | &nbsp;
|
+
|-
 
| 0000h : Blank<br>0001h : Bizarro Battle - Center<br>0002h : Grassland<br>0003h : Mt Nibel<br>0004h : Forest<br>0005h : Beach<br>0006h : Desert<br>0007h : Snow<br>0008h : Swamp<br>0009h : Sector 1 Train Station<br>000Ah : Reactor 1<br>000Bh : Reactor 1 Core<br>000Ch : Reactor 1 Entrance<br>000Dh : Sector 4 Subway<br>000Eh : Nibel Caves or AForest Caves<br>000Fh : Shinra HQ<br>0010h : Midgar Raid Subway<br>0011h : Hojo's Lab<br>0012h : Shinra Elevators<br>0013h : Shinra Roof<br>0014h : Midgar Highway<br>0015h : Wutai Pagoda<br>0016h : Church<br>0017h : Coral Valley<br>0018h : Midgar Slums<br>0019h : Sector 4 Corridors or Junon Path<br>001Ah : Sector 4 Gantries or Midgar Underground<br>001Bh : Sector 7 Support Pillar Stairway<br>001Ch : Sector 7 Support Pillar Top<br>001Dh : Sector 8<br>001Eh : Sewers<br>001Fh : Mythril Mines<br>0020h : Northern Crater - Floating Platforms<br>0021h : Corel Mountain Path<br>0022h : Junon Beach<br>0023h : Junon Cargo Ship<br>0024h : Corel Prison<br>0025h : Battle Square<br>0026h : Da Chao - Rapps Battle<br>0027h : Cid's Backyard<br>0028h : Final Descent to Sephiroth<br>0029h : Reactor 5 Entrance<br>002Ah : Temple of the Ancients - Escher Room<br>002Bh : Shinra Mansion<br>002Ch : Junon Airship Dock<br>002Dh : Whirlwind Maze<br>002Eh : Junon Underwater Reactor<br>002Fh : Gongaga Reactor<br>0030h : Gelnika<br>0031h : Train Graveyard<br>0032h : Great Glacier Ice Caves & Gaea Cliffs - Inside<br>0033h : Sister Ray<br>0034h : Sister Ray Base<br>0035h : Forgotten City Altar<br>0036h : Northern Crater - Initial Descent<br>0037h : Northern Crater - Hatchery<br>0038h : Northern Crater - Water Area<br>0039h : Safer Battle<br>003Ah : Kalm Flashback - Dragon Battle<br>003Bh : Junon Underwater Pipe<br>003Ch : Blank<br>003Dh : Corel Railway - Canyon<br>003Eh : Whirlwind Maze - Crater<br>003Fh : Corel Railway - Rollercoaster<br>0040h : Wooden Bridge<br>0041h : Da Chao<br>0042h : Fort Condor<br>0043h : Dirt Wasteland<br>0044h : Bizarro Battle - Right Side<br>0045h : Bizarro Battle - Left Side<br>0046h : Jenova*SYNTHESIS Battle<br>0047h : Corel Train Battle<br>0048h : Cosmo Canyon<br>0049h : Caverns of the Gi<br>004Ah : Nibelheim Mansion Basement<br>004Bh : Temple of the Ancients - Demons Gate<br>004Ch : Temple of the Ancients - Mural Room<br>004Dh : Temple of the Ancients - Clock Passage<br>004Eh : Final Battle - Sephiroth<br>004Fh : Jungle<br>0050h : Ultimate Weapon - Battle on Highwind<br>0051h : Corel Reactor<br>0052h : Unused<br>0053h : Don Corneo's Mansion<br>0054h : Emerald Weapon Battle<br>0055h : Reactor 5<br>0056h : Shinra HQ - Escape<br>0057h : Ultimate Weapon - Gongaga Reactor<br>0058h : Corel Prison - Dyne Battle<br>0059h : Ultimate Weapon - Forest
 
| 0000h : Blank<br>0001h : Bizarro Battle - Center<br>0002h : Grassland<br>0003h : Mt Nibel<br>0004h : Forest<br>0005h : Beach<br>0006h : Desert<br>0007h : Snow<br>0008h : Swamp<br>0009h : Sector 1 Train Station<br>000Ah : Reactor 1<br>000Bh : Reactor 1 Core<br>000Ch : Reactor 1 Entrance<br>000Dh : Sector 4 Subway<br>000Eh : Nibel Caves or AForest Caves<br>000Fh : Shinra HQ<br>0010h : Midgar Raid Subway<br>0011h : Hojo's Lab<br>0012h : Shinra Elevators<br>0013h : Shinra Roof<br>0014h : Midgar Highway<br>0015h : Wutai Pagoda<br>0016h : Church<br>0017h : Coral Valley<br>0018h : Midgar Slums<br>0019h : Sector 4 Corridors or Junon Path<br>001Ah : Sector 4 Gantries or Midgar Underground<br>001Bh : Sector 7 Support Pillar Stairway<br>001Ch : Sector 7 Support Pillar Top<br>001Dh : Sector 8<br>001Eh : Sewers<br>001Fh : Mythril Mines<br>0020h : Northern Crater - Floating Platforms<br>0021h : Corel Mountain Path<br>0022h : Junon Beach<br>0023h : Junon Cargo Ship<br>0024h : Corel Prison<br>0025h : Battle Square<br>0026h : Da Chao - Rapps Battle<br>0027h : Cid's Backyard<br>0028h : Final Descent to Sephiroth<br>0029h : Reactor 5 Entrance<br>002Ah : Temple of the Ancients - Escher Room<br>002Bh : Shinra Mansion<br>002Ch : Junon Airship Dock<br>002Dh : Whirlwind Maze<br>002Eh : Junon Underwater Reactor<br>002Fh : Gongaga Reactor<br>0030h : Gelnika<br>0031h : Train Graveyard<br>0032h : Great Glacier Ice Caves & Gaea Cliffs - Inside<br>0033h : Sister Ray<br>0034h : Sister Ray Base<br>0035h : Forgotten City Altar<br>0036h : Northern Crater - Initial Descent<br>0037h : Northern Crater - Hatchery<br>0038h : Northern Crater - Water Area<br>0039h : Safer Battle<br>003Ah : Kalm Flashback - Dragon Battle<br>003Bh : Junon Underwater Pipe<br>003Ch : Blank<br>003Dh : Corel Railway - Canyon<br>003Eh : Whirlwind Maze - Crater<br>003Fh : Corel Railway - Rollercoaster<br>0040h : Wooden Bridge<br>0041h : Da Chao<br>0042h : Fort Condor<br>0043h : Dirt Wasteland<br>0044h : Bizarro Battle - Right Side<br>0045h : Bizarro Battle - Left Side<br>0046h : Jenova*SYNTHESIS Battle<br>0047h : Corel Train Battle<br>0048h : Cosmo Canyon<br>0049h : Caverns of the Gi<br>004Ah : Nibelheim Mansion Basement<br>004Bh : Temple of the Ancients - Demons Gate<br>004Ch : Temple of the Ancients - Mural Room<br>004Dh : Temple of the Ancients - Clock Passage<br>004Eh : Final Battle - Sephiroth<br>004Fh : Jungle<br>0050h : Ultimate Weapon - Battle on Highwind<br>0051h : Corel Reactor<br>0052h : Unused<br>0053h : Don Corneo's Mansion<br>0054h : Emerald Weapon Battle<br>0055h : Reactor 5<br>0056h : Shinra HQ - Escape<br>0057h : Ultimate Weapon - Gongaga Reactor<br>0058h : Corel Prison - Dyne Battle<br>0059h : Ultimate Weapon - Forest
 
|-
 
|-
Line 179: Line 201:
 
| Escape Counter
 
| Escape Counter
 
|-
 
|-
|style="background:rgb(255,255,204)" | 0x0006
+
| 0x0006
|style="background:rgb(255,255,204)" | 10 bytes
+
| 2 bytes
|style="background:rgb(255,255,204)" | Unknown
+
| Unused/Align 'FF'
 +
|-
 +
| 0x0008
 +
| 4 * 2 bytes
 +
| [[FF7/Battle/Battle_scenes#Formation_ID|Formation ID]] of candidates for next Battle Arena battle. (default of 03E7h)
 
|-
 
|-
 
| 0x0010
 
| 0x0010
 
| 2 bytes
 
| 2 bytes
| Escapable Flag (Perhaps other flags)
+
| Escapable Flag (Along with other flags)
 
|-
 
|-
 
| 0x0012
 
| 0x0012
Line 191: Line 217:
 
| Battle layout type (normal, ambush, side). 0-8 types.
 
| Battle layout type (normal, ambush, side). 0-8 types.
 
|-
 
|-
|style="background:rgb(255,255,204)" | 0x0013
+
|style="background:rgb(204,204,255)" align="center" colspan="2" rowspan="10" | &nbsp;
|style="background:rgb(255,255,204)" | 1 byte
+
|-
|style="background:rgb(255,255,204)" | Unknown
+
| 00 - Normal fight
 +
|-
 +
| 01 - Preemptive
 +
|-
 +
| 02 - Back attack
 +
|-
 +
| 03 - Side attack
 +
|-
 +
| 04 - Attacked from both sides (pincer attack, reverse side attack)
 +
|-
 +
| 05 - Another attack from both sides battle (different maybe?)
 +
|-
 +
| 06 - Another side attack
 +
|-
 +
| 07 - A third side attack
 +
|-
 +
| 08 - Normal battle that locks you in the front row, change command is disabled
 +
|-
 +
| 0x0013
 +
| 1 byte
 +
| Indexed Pre-Battle Camera position
 
|}
 
|}
  
==== Battle Setup 2 format ====
+
==== Camera Placement Data format ====
  
48 bytes per formation
+
48 bytes per Formation
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
! style="background:rgb(204,204,204)" align="center" | Offset
 
! style="background:rgb(204,204,204)" align="center" | Offset
Line 205: Line 251:
 
|-
 
|-
 
| 0x00
 
| 0x00
| 2 bytes
+
| 12 bytes
| Final Camera X Position
+
| Primary Battle Idle Camera Position
 +
|-
 +
|style="background:rgb(204,204,255)" align="center" colspan="1" rowspan="7" | &nbsp;
 +
|-
 +
| 0x0
 +
| Camera X Position
 +
|-
 +
| 0x2
 +
| Camera Y Position
 
|-
 
|-
| 0x02
+
| 0x4
| 2 bytes
+
| Camera Z Position
| Final Camera Y Position
 
 
|-
 
|-
| 0x04
+
| 0x6
| 2 bytes
+
| Camera X Direction
| Final Camera Z Position
 
 
|-
 
|-
| 0x06
+
| 0x8
| 2 bytes
+
| Camera Y Direction
| Final Camera X Direction
 
 
|-
 
|-
| 0x08
+
| 0xA
| 2 bytes
+
| Camera Z Direction
| Final Camera Y Direction
 
 
|-
 
|-
| 0x0A
+
| 0x0C
| 2 bytes
+
| 2 * 12 bytes
| Final Camera Z Direction
+
| Other Camera Positions in the above format referenced in enemies' animations.
 
|-
 
|-
| style="background:rgb(255,255,204)" | 0x0C
+
| 0x24
| style="background:rgb(255,255,204)" | 42 bytes
+
| 12 bytes
| style="background:rgb(255,255,204)" | Unknown
+
| Unused/Align 'FF'
 
|}
 
|}
  
 
==== Battle Formation Data ====
 
==== Battle Formation Data ====
  
4 Possible battle formations per scene, maximum of 6 monsters per battle. Each monster entry contains the following data:
+
4 Possible battle formations per scene, maximum of 6 enemies per battle. Each enemy entry contains the following data:
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
{| border="1" cellspacing="1" cellpadding="3" style="border: 1px solid black; border-collapse: collapse;"
 
! style="background:rgb(204,204,204)" align="center" | Offset
 
! style="background:rgb(204,204,204)" align="center" | Offset
 
! style="background:rgb(204,204,204)" align="center" | Length
 
! style="background:rgb(204,204,204)" align="center" | Length
! style="background:rgb(204,204,204)" align="center" | Description
+
! style="background:rgb(204,204,204)" align="center" colspan="2" | Description
 
|-
 
|-
 
| 0x00
 
| 0x00
 
| 2 bytes
 
| 2 bytes
| Monster ID
+
| colspan="2" | Enemy ID
 
|-
 
|-
| 0x03
+
| 0x02
 
| 2 bytes
 
| 2 bytes
| position X
+
| colspan="2" | position X
 
|-
 
|-
 
| 0x04
 
| 0x04
 
| 2 bytes
 
| 2 bytes
| position Y
+
| colspan="2" | position Y
 
|-
 
|-
 
| 0x06
 
| 0x06
 
| 2 bytes
 
| 2 bytes
| position Z
+
| colspan="2" | position Z
 
|-
 
|-
 
| 0x08
 
| 0x08
 
| 2 bytes
 
| 2 bytes
| Row
+
| colspan="2" | Row
 
|-
 
|-
|style="background:rgb(255,255,204)" | 0x0A
+
| 0x0A
|style="background:rgb(255,255,204)" | 2 bytes
+
| 2 bytes
|style="background:rgb(255,255,204)" | Unknown
+
| colspan="2" | [[#Binary_"Cover_Flags"|Binary "Cover flags"]]
 
|-
 
|-
 
| 0x0C
 
| 0x0C
 
| 4 bytes
 
| 4 bytes
| Default unit flags (copied to unit structure). Some of them don't set from here. This flags the same as one set from script to invisible or untargetable enemy.
+
| colspan="2" | Initial condition flags. Only last 5 bits are considered.
 +
|-
 +
| style="background:rgb(204,204,255)" colspan ="2" rowspan="5" |
 +
| 0x0001
 +
| Visible
 +
|-
 +
| 0x0002
 +
| Indicates initial direction facing if players get a side attack.
 +
|-
 +
| style="background:rgb(255,255,204)" | 0x0004
 +
| style="background:rgb(255,255,204)" | Unknown
 +
|-
 +
|0x0008
 +
| Targetable
 +
|-
 +
|0x0010
 +
| Main Script Active
 
|}
 
|}
  
Line 315: Line 381:
 
| 0x0028
 
| 0x0028
 
| 8 bytes
 
| 8 bytes
| Element types (8 records):<br>00h - Fire<br>01h - Ice<br>02h - Bolt<br>03h - Earth<br>04h - Bio<br>05h - Gravity<br>06h - Water<br>07h - Wind<br>08h - Holy<br>09h - Health<br>0Ah - Cut<br>0Bh - Hit<br>0Ch - Punch<br>0Dh - Shoot<br>0Eh - Scream<br>FFh - No element
+
| Element types (8 records):<br>00h - Fire<br>01h - Ice<br>02h - Bolt<br>03h - Earth<br>04h - Bio<br>05h - Gravity<br>06h - Water<br>07h - Wind<br>08h - Holy<br>09h - Health<br>0Ah - Cut<br>0Bh - Hit<br>0Ch - Punch<br>0Dh - Shoot<br>0Eh - Scream<br>0Fh - HIDDEN<br>10h-1Fh - No Effect<br>20h-3Fh - [[FF7/Battle/Status Effects|Statuses]] (Damage done by actions that inflict these statuses will be modified)<br>FFh - No element
 
|-
 
|-
 
| 0x0030
 
| 0x0030
Line 323: Line 389:
 
| 0x0038
 
| 0x0038
 
| 16 bytes
 
| 16 bytes
| Attack action script id (1 byte each)
+
| Action animation index (1 byte each).
 
|-
 
|-
 
| 0x0048
 
| 0x0048
 
| 32 bytes
 
| 32 bytes
| Enemy Attack ID's (2 bytes each)
+
| Enemy Attack ID's (2 bytes each).
 
|-
 
|-
|style="background:rgb(255,255,204)" | 0x0058
+
|style="background:rgb(255,255,255)" | 0x0068
|style="background:rgb(255,255,204)" | 38 bytes
+
|style="background:rgb(255,255,255)" | 32 bytes
|style="background:rgb(255,255,204)" | Unknown data
+
|style="background:rgb(255,255,255)" | Enemy Attacks [[FF7/Battle/Camera Movement Id List|Camera Movement Id]] for single and multiple targets (2 bytes each). If set this will overwrite camera movement set in attack itself.
 
|-
 
|-
 
| 0x0088
 
| 0x0088
Line 387: Line 453:
 
|style="background:rgb(255,255,204)" | 0x00B4
 
|style="background:rgb(255,255,204)" | 0x00B4
 
|style="background:rgb(255,255,204)" | 4 bytes
 
|style="background:rgb(255,255,204)" | 4 bytes
|style="background:rgb(255,255,204)" | Unknown
+
|style="background:rgb(255,255,204)" | Unknown [Always FFFFFFFFh]
 
|}
 
|}
 
  
 
====Formation ID====
 
====Formation ID====
Line 436: Line 501:
 
| Magical Counter
 
| Magical Counter
 
|-
 
|-
|style="background:rgb(255,255,204)" | 0x0C
+
| 0x0C
|style="background:rgb(255,255,204)" | Party Member Death?
+
| Battle End
 
|-
 
|-
 
| 0x0E
 
| 0x0E
| Post-Attack
+
| Pre-Action Setup
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x10
 
|style="background:rgb(255,255,204)" | 0x10
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 1
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x12
 
|style="background:rgb(255,255,204)" | 0x12
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 2
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x14
 
|style="background:rgb(255,255,204)" | 0x14
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 3
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x16
 
|style="background:rgb(255,255,204)" | 0x16
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 4
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x18
 
|style="background:rgb(255,255,204)" | 0x18
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 5
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x1A
 
|style="background:rgb(255,255,204)" | 0x1A
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 6
 
|-
 
|-
 
|style="background:rgb(255,255,204)" | 0x1C
 
|style="background:rgb(255,255,204)" | 0x1C
|style="background:rgb(255,255,204)" | Unused
+
|style="background:rgb(255,255,204)" | Custom Event 7
 
|-
 
|-
 
| 0x1E
 
| 0x1E
| Post-Battle
+
| Custom Event 8
 
|}
 
|}
It's structure and opcodes are described [[FF7/Battle/Battle_Scenes/Battle_Script|here]].
+
Its structure and opcodes are described [[FF7/Battle/Battle_Scenes/Battle_Script|here]].
  
 
NOTES:
 
NOTES:
 
*A monster's total AI size will always be an even number of bytes. If the actual scripts are an odd number, a single NULL (FFh) will be placed before the next monster's AI header (may not be required).
 
*A monster's total AI size will always be an even number of bytes. If the actual scripts are an odd number, a single NULL (FFh) will be placed before the next monster's AI header (may not be required).
*Battle begins after all characters' Initialize scripts have been run (order to be determined).
+
*Battle begins after all characters' Initialize scripts have been run (Players first, then enemies, then formation).
*Party Member Death is only used on Cloud's AI. It's meant to lower the character's Love Points with him if he lets them die or he dies with them in the party (not sure which). Script never seems to activate on other characters and may not even execute on Cloud's.
+
*The only character with "Battle End" is in Cloud's AI. It's meant to lower the character's Love Points with him if he lets them die or he dies with them in the party (not sure which).  
*Post-Attack occurs immediately after any character performs any attack to any target regardless whether damage is dealt or not. Script owner can be flagged as dead and script would still activate. It's priority is higher than that of other Counter Scripts.
+
*Pre-Action Event occurs on all battle participants prior to any actions performed by any participant regardless of actor or target. This includes all executed 92 commands that have a command index of less than 21h. If any 92 commands are called in this section, the command that caused this script to run has priority.
*Post-Battle is only used on Mystery Ninja (all), Ultimate Weapons in location other than above Cosmo Canyon, Safer Sephiroth, and the final "showdown" between Cloud and Sephiroth. These characters have scripts on them that do not remove them from battle when they are defeated. This Script section is used to remove them from the battle probably to clean up memory. Executed after "victory dance".
+
*The Custom Event sections are not called by any event. They only occur if they are called with the 92 command.
*The order of scripts executed after an attack is:
+
60 22 <- command index "Run script"
*#Post-Attack
+
60 0X <- where X is the script section in hex (eg. X = 8 would call Custom Event 1 since it is script id 08
*#Death Counter (If script owner died, execution stops here)
+
          [not to be confused with offset])
*#General Counter (If script owner was target)
+
92
*#Physical Counter/Magical Counter (depending on damage type)
+
 
 +
*Custom Event 8 is only used on Mystery Ninja (all), Ultimate Weapons in location other than above Cosmo Canyon, Safer Sephiroth, and the final "showdown" between Cloud and Sephiroth. These characters have scripts on them that do not remove them from battle when they are defeated.
 +
*Custom Events 1-7 may not work. (not thoroughly tested)
 +
*The order of scripts executed:
 +
:*Beginning of battle
 +
::Pre-Battle (all participants)
 +
:*Once a "main-script enabled" enemy's time gauge is full:
 +
::Main (Enemy performs action)
 +
:*Pre-Attack (If enemy script uses a 92 command with a command index of 20h or less)
 +
::Pre-Action Setup (occurs on all participants)
 +
:*Post-Attack
 +
:*#Death Counter (If script owner died, execution stops here)
 +
:*#General Counter (Executed by all targets)
 +
:*#Physical Counter/Magical Counter (Executed by all targets depending on damage type)
 +
:*Battle ends
 +
::Battle End (all participants)
 +
 
 +
==== Binary "Cover Flags" ====
 +
 
 +
These flags are used in conjunction with row to determine if a target can be selected as the target of a '''short-range attack'''. The determination of this is worked out in this way:
 +
An enemy exists in row 1 and another in row 2. If the enemy in row 1 shares a cover flag with the enemy in row 2 then the enemy in row 2 cannot be targeted until all enemies in row 1 that share a cover flag with the row 2 enemy is defeated.
 +
It works like this. Two active enemies exist, A and B.
 +
If ((B's row > A's row) and (B's cover flags AND A's cover flags) > 0) then enemy B cannot be targeted by short-range attacks.
 +
for any enemies A and B.<br />
 +
Example:<br />
 +
Consider the Battery Cap x6 battle in the forest between Nibelheim and Rocket Town. Their cover flags (in binary) are:
 +
Row 1:      00100
 +
Row 2:    00110 01100
 +
Row 3: 00011 00100 11000
 +
The battery caps in row 2 cannot be targeted by a short-range attack until the one in row 1 has been defeated because they share the 0x4 cover flag. Once row 1 has been cleared:
 +
Row 2:    00110 01100
 +
Row 3: 00011 00100 11000
 +
The battery cap on left in row 2 covers the left two in row 3 because it shares flag 0x4 with the one in the middle and flag 0x2 with the one on the far left. As long as it is active these in row 3 cannot be targeted.
 +
Similarly, the battery cap on the right in row 2 shares the 0x4 flag with the middle of row 3 and the 0x8 flag with the far right of row 3 so these cannot be targeted until the right side of row 2 is defeated.<br />
 +
It is also necessary to note that because row 1 does not share any flags with the extreme right and left of row 3, they can be targeted if the corresponding enemy in row 2 is defeated even if the row 1 enemy is still active.<br />
 +
Also of note is that enemies in the same row that share cover flags are not considered.<br />
 +
Only the first five bits may be considered even though the value is stored as a word.<br />
  
 
== Useful downloads ==
 
== Useful downloads ==

Latest revision as of 05:11, 23 May 2019

Introduction

FF7 keeps each enemy battle configuration is a file called "scene.bin" This file is located in the following directories.

PSX Version PC Version
/DATA/BATTLE/SCENE.BIN /BATTLE/SCENE.BIN

This file is exactly the same in both versions. This holds all the battle configurations for all enemies encountered in the game.

Scene.Bin file format

Overview

The scene.bin file contains 256 gziped files which give us information for all the FF7 monsters. In order to find these files in scene.bin, you have to know that the file is structured with blocks exactly 0x2000 bytes in length. In the first table (scene.bin block), you will see what contains a block. Blocks are concatenated with each other to form the scene.bin file. So if you want to extract data from scene.bin, you'll need to find the correct blocks and to extract the gziped files from it. After that you simply ungzip those files and you'll find 256 files, with a length is 7808 bytes. Known information about those files can be found in the second table (The Data File specification). Because extracting file manually would be a pain, several tools was developed in order to help you. You can use Scene Reader for example, it's a win32 tool to extract and repack scene.bin archive.

Also note, that in kernel.bin there is a look-up table for scene.bin, which tells how many files there are in each section of scene.bin. You need to update it every time you repack the file and something changes. The table is at offset 0x0F1C of the third section of the kernel.bin file. You can use SceneFix program, which'll update the table for you.

We have 1024 possible battle numbers: 0 - 1023. Each group of *4* Battle Numbers refers to a particular Scene file: for instance, Battles 0-3 refer to File 0 in Scene.bin, Battles 4-7 refer to File 1 in Scene.bin, and so forth.


Japanese format

In the japanese scene.bin, ennemies names and attacks names have a size of 16 bytes, instead of 32 bytes.


General file format

Offset Length Description
0x0000 4 bytes Pointer to first data file. You must multiply it by 4 to get actual data file offset. If the pointer is equal to FFFFFFFFh then it means that the end of block has been reached.
0x0004 4 bytes Pointer to second data file. You must multiply it by 4 to get actual data file offset. If the pointer is equal to FFFFFFFFh then it means that the end of block has been reached.
...
0x003C 4 bytes Last pointer, usually it equal FFFFFFFFh.
0x0040 4 * (pointer2 - pointer1) bytes First data file in block. It's a gziped file.
Note: Sometimes it may finish by 0xFF bytes, because its size must be multiple of 4.
pointer2 * 4 4 * (pointer3 - pointer2) bytes Second data file in block. It's a gziped file.
Note: Sometimes it may finish by 0xFF bytes, because its size must be multiple of 4.
...
lastpointer * 4 4 * (2000h - lastpointer) bytes Last data file in block.
Note: There are about 6 to 12 files in each block. Each block finishes by 0xFF bytes, because its length must be 2000h (8192d) bytes.

Data file format

Offset Length Description
0x0000 2 bytes Enemy ID 1
0x0002 2 bytes Enemy ID 2
0x0004 2 bytes Enemy ID 3
0x0006 2 bytes Padding (always FFFFh)
0x0008 4 * 20 bytes Battle Setup (4 records) (format explanation)
0x0058 4 * 48 bytes Camera Placement Data (4 records) (format explanation)
0x0118 6 * 16 bytes Battle Formation 1 (6 records) (format explanation)
0x0178 6 * 16 bytes Battle Formation 2 (6 records)
0x01E8 6 * 16 bytes Battle Formation 3 (6 records)
0x0238 6 * 16 bytes Battle Formation 4 (6 records)
0x0298 184 bytes Enemy Data 1 (format explanation)
0x0350 184 bytes Enemy Data 2
0x0408 184 bytes Enemy Data 3
0x04C0 32 * 28 bytes Attack Data (32 records) (format explanation)
0x0840 32 * 2 bytes Attack IDs (32 records)
0x0880 32 * 32 bytes Attack Names (32 records, in FF Text format)
0x0C80 2 bytes Formation 1 AI Script Offset
0x0C82 2 bytes Formation 2 AI Script Offset
0x0C84 2 bytes Formation 3 AI Script Offset
0x0C86 2 bytes Formation 4 AI Script Offset
0x0C88 0 - 504 bytes Beginning of Formation AI Data (format explanation)
0x0E80 2 bytes Enemy 1 AI Offset
0x0E82 2 bytes Enemy 2 AI Offset
0x0E84 2 bytes Enemy 3 AI Offset
0x0E86 0 - 4090 bytes Beginning of AI Data (format explanation)


Battle Setup 1 format

Offset Length Description
0x0000 2 bytes Battle location, as follows:
 
0000h : Blank
0001h : Bizarro Battle - Center
0002h : Grassland
0003h : Mt Nibel
0004h : Forest
0005h : Beach
0006h : Desert
0007h : Snow
0008h : Swamp
0009h : Sector 1 Train Station
000Ah : Reactor 1
000Bh : Reactor 1 Core
000Ch : Reactor 1 Entrance
000Dh : Sector 4 Subway
000Eh : Nibel Caves or AForest Caves
000Fh : Shinra HQ
0010h : Midgar Raid Subway
0011h : Hojo's Lab
0012h : Shinra Elevators
0013h : Shinra Roof
0014h : Midgar Highway
0015h : Wutai Pagoda
0016h : Church
0017h : Coral Valley
0018h : Midgar Slums
0019h : Sector 4 Corridors or Junon Path
001Ah : Sector 4 Gantries or Midgar Underground
001Bh : Sector 7 Support Pillar Stairway
001Ch : Sector 7 Support Pillar Top
001Dh : Sector 8
001Eh : Sewers
001Fh : Mythril Mines
0020h : Northern Crater - Floating Platforms
0021h : Corel Mountain Path
0022h : Junon Beach
0023h : Junon Cargo Ship
0024h : Corel Prison
0025h : Battle Square
0026h : Da Chao - Rapps Battle
0027h : Cid's Backyard
0028h : Final Descent to Sephiroth
0029h : Reactor 5 Entrance
002Ah : Temple of the Ancients - Escher Room
002Bh : Shinra Mansion
002Ch : Junon Airship Dock
002Dh : Whirlwind Maze
002Eh : Junon Underwater Reactor
002Fh : Gongaga Reactor
0030h : Gelnika
0031h : Train Graveyard
0032h : Great Glacier Ice Caves & Gaea Cliffs - Inside
0033h : Sister Ray
0034h : Sister Ray Base
0035h : Forgotten City Altar
0036h : Northern Crater - Initial Descent
0037h : Northern Crater - Hatchery
0038h : Northern Crater - Water Area
0039h : Safer Battle
003Ah : Kalm Flashback - Dragon Battle
003Bh : Junon Underwater Pipe
003Ch : Blank
003Dh : Corel Railway - Canyon
003Eh : Whirlwind Maze - Crater
003Fh : Corel Railway - Rollercoaster
0040h : Wooden Bridge
0041h : Da Chao
0042h : Fort Condor
0043h : Dirt Wasteland
0044h : Bizarro Battle - Right Side
0045h : Bizarro Battle - Left Side
0046h : Jenova*SYNTHESIS Battle
0047h : Corel Train Battle
0048h : Cosmo Canyon
0049h : Caverns of the Gi
004Ah : Nibelheim Mansion Basement
004Bh : Temple of the Ancients - Demons Gate
004Ch : Temple of the Ancients - Mural Room
004Dh : Temple of the Ancients - Clock Passage
004Eh : Final Battle - Sephiroth
004Fh : Jungle
0050h : Ultimate Weapon - Battle on Highwind
0051h : Corel Reactor
0052h : Unused
0053h : Don Corneo's Mansion
0054h : Emerald Weapon Battle
0055h : Reactor 5
0056h : Shinra HQ - Escape
0057h : Ultimate Weapon - Gongaga Reactor
0058h : Corel Prison - Dyne Battle
0059h : Ultimate Weapon - Forest
0x0002 2 bytes Upon defeat of all opponents in current formation, begin battle with Formation ID without ending battle scene
0x0004 2 bytes Escape Counter
0x0006 2 bytes Unused/Align 'FF'
0x0008 4 * 2 bytes Formation ID of candidates for next Battle Arena battle. (default of 03E7h)
0x0010 2 bytes Escapable Flag (Along with other flags)
0x0012 1 byte Battle layout type (normal, ambush, side). 0-8 types.
 
00 - Normal fight
01 - Preemptive
02 - Back attack
03 - Side attack
04 - Attacked from both sides (pincer attack, reverse side attack)
05 - Another attack from both sides battle (different maybe?)
06 - Another side attack
07 - A third side attack
08 - Normal battle that locks you in the front row, change command is disabled
0x0013 1 byte Indexed Pre-Battle Camera position

Camera Placement Data format

48 bytes per Formation

Offset Length Description
0x00 12 bytes Primary Battle Idle Camera Position
 
0x0 Camera X Position
0x2 Camera Y Position
0x4 Camera Z Position
0x6 Camera X Direction
0x8 Camera Y Direction
0xA Camera Z Direction
0x0C 2 * 12 bytes Other Camera Positions in the above format referenced in enemies' animations.
0x24 12 bytes Unused/Align 'FF'

Battle Formation Data

4 Possible battle formations per scene, maximum of 6 enemies per battle. Each enemy entry contains the following data:

Offset Length Description
0x00 2 bytes Enemy ID
0x02 2 bytes position X
0x04 2 bytes position Y
0x06 2 bytes position Z
0x08 2 bytes Row
0x0A 2 bytes Binary "Cover flags"
0x0C 4 bytes Initial condition flags. Only last 5 bits are considered.
0x0001 Visible
0x0002 Indicates initial direction facing if players get a side attack.
0x0004 Unknown
0x0008 Targetable
0x0010 Main Script Active

Enemy data format

Offset Length Description
0x0000 32 bytes Enemy's name (completed by FFh bytes)
0x0020 1 byte Enemy's level
0x0021 1 byte Enemy's speed
0x0022 1 byte Enemy's luck
0x0023 1 byte Enemy's evade
0x0024 1 byte Enemy's strength
0x0025 1 byte Enemy's defense
0x0026 1 byte Enemy's magic
0x0027 1 byte Enemy's magic defense
0x0028 8 bytes Element types (8 records):
00h - Fire
01h - Ice
02h - Bolt
03h - Earth
04h - Bio
05h - Gravity
06h - Water
07h - Wind
08h - Holy
09h - Health
0Ah - Cut
0Bh - Hit
0Ch - Punch
0Dh - Shoot
0Eh - Scream
0Fh - HIDDEN
10h-1Fh - No Effect
20h-3Fh - Statuses (Damage done by actions that inflict these statuses will be modified)
FFh - No element
0x0030 8 bytes Element rates for elements above, respectively (8 records):
00h - Death
02h - Double Damage
04h - Half Damage
05h - Nullify Damage
06h - Absorb 100%
07h - Full Cure
FFh - Nothing
0x0038 16 bytes Action animation index (1 byte each).
0x0048 32 bytes Enemy Attack ID's (2 bytes each).
0x0068 32 bytes Enemy Attacks Camera Movement Id for single and multiple targets (2 bytes each). If set this will overwrite camera movement set in attack itself.
0x0088 4 bytes Item drop/steal rates.
These are chances to get items listed in next section. 1 byte per item. If the rate is lower than 80h, for e.g. 08h - then this is a drop item and has 8/63 [63 is max] chance for drop. But if rate is higher than 80h, let's say... A0h, then this is an item for steal, and chances for successful steal is A0h - 80h = 20h = 32/63.
0x008C 8 bytes This is a list of Item ID's which are described above. 2 bytes per item. FFFFh means no item.
0x0094 6 bytes Indexes of up to three attacks (2 bytes each) that enemy can perform while manipulated or berserked
0x009A 2 bytes Unknown data
0x009C 2 bytes Enemy's MP
0x009E 2 bytes AP points you receive when you win the battle
0x00A0 2 bytes Enemy can be morphed into this item. FFFFh if it can't be morphed into anything.
0x00A2 1 byte Multiplier for back damage. damage = damage * 0xXX / 8.
0x00A3 1 byte align 0xff.
0x00A4 4 bytes Enemy's HP
0x00A8 4 bytes Exp points you receive when you win the battle
0x00AC 4 bytes Gil you receive when you win the battle
0x00B0 4 bytes Status immunities
0x00B4 4 bytes Unknown [Always FFFFFFFFh]

Formation ID

Formation ID is an index to a formation within a given scene. It is the scene index bit shifted 2 to the left plus formation index within the scene.

0 1 2 3 4 5 6 7 8 9 A B C D E F
[ - - - - - - - - - - - - ] [ ]
        scene index         formation index

For this reason, the Formation ID will not exceed 03FFh.

example: Formation 028Dh bit shift two to the right to get scene

028D >> 2 = 00A3 (right-most bits are truncated)

This is Scene 163 Formation Index is just the ID ANDed with 3.

028D AND 3 = 01

Formation 1 So this is Formation 1 in scene 163. (SOLDIER:3rd x2)

AI Data

This section contains Battle Script that is executed before or/and during every fight. Every enemy has it's own script, and this script is divided to a number of sections. Each script starts with 32 bytes of header that are divided into 16 parts representing 16 script types. The 2-byte number in any section is an offset relative to the beginning of this 32 byte block that tells the script reader where the script starts for that script type.

Offset Script Type
0x00 Initialize
0x02 Main
0x04 General Counter
0x06 Death Counter
0x08 Physical Counter
0x0A Magical Counter
0x0C Battle End
0x0E Pre-Action Setup
0x10 Custom Event 1
0x12 Custom Event 2
0x14 Custom Event 3
0x16 Custom Event 4
0x18 Custom Event 5
0x1A Custom Event 6
0x1C Custom Event 7
0x1E Custom Event 8

Its structure and opcodes are described here.

NOTES:

  • A monster's total AI size will always be an even number of bytes. If the actual scripts are an odd number, a single NULL (FFh) will be placed before the next monster's AI header (may not be required).
  • Battle begins after all characters' Initialize scripts have been run (Players first, then enemies, then formation).
  • The only character with "Battle End" is in Cloud's AI. It's meant to lower the character's Love Points with him if he lets them die or he dies with them in the party (not sure which).
  • Pre-Action Event occurs on all battle participants prior to any actions performed by any participant regardless of actor or target. This includes all executed 92 commands that have a command index of less than 21h. If any 92 commands are called in this section, the command that caused this script to run has priority.
  • The Custom Event sections are not called by any event. They only occur if they are called with the 92 command.
60 22 <- command index "Run script"
60 0X <- where X is the script section in hex (eg. X = 8 would call Custom Event 1 since it is script id 08
         [not to be confused with offset])
92
  • Custom Event 8 is only used on Mystery Ninja (all), Ultimate Weapons in location other than above Cosmo Canyon, Safer Sephiroth, and the final "showdown" between Cloud and Sephiroth. These characters have scripts on them that do not remove them from battle when they are defeated.
  • Custom Events 1-7 may not work. (not thoroughly tested)
  • The order of scripts executed:
  • Beginning of battle
Pre-Battle (all participants)
  • Once a "main-script enabled" enemy's time gauge is full:
Main (Enemy performs action)
  • Pre-Attack (If enemy script uses a 92 command with a command index of 20h or less)
Pre-Action Setup (occurs on all participants)
  • Post-Attack
    1. Death Counter (If script owner died, execution stops here)
    2. General Counter (Executed by all targets)
    3. Physical Counter/Magical Counter (Executed by all targets depending on damage type)
  • Battle ends
Battle End (all participants)

Binary "Cover Flags"

These flags are used in conjunction with row to determine if a target can be selected as the target of a short-range attack. The determination of this is worked out in this way: An enemy exists in row 1 and another in row 2. If the enemy in row 1 shares a cover flag with the enemy in row 2 then the enemy in row 2 cannot be targeted until all enemies in row 1 that share a cover flag with the row 2 enemy is defeated. It works like this. Two active enemies exist, A and B.

If ((B's row > A's row) and (B's cover flags AND A's cover flags) > 0) then enemy B cannot be targeted by short-range attacks.

for any enemies A and B.
Example:
Consider the Battery Cap x6 battle in the forest between Nibelheim and Rocket Town. Their cover flags (in binary) are:

Row 1:       00100
Row 2:    00110 01100
Row 3: 00011 00100 11000

The battery caps in row 2 cannot be targeted by a short-range attack until the one in row 1 has been defeated because they share the 0x4 cover flag. Once row 1 has been cleared:

Row 2:    00110 01100
Row 3: 00011 00100 11000

The battery cap on left in row 2 covers the left two in row 3 because it shares flag 0x4 with the one in the middle and flag 0x2 with the one on the far left. As long as it is active these in row 3 cannot be targeted. Similarly, the battery cap on the right in row 2 shares the 0x4 flag with the middle of row 3 and the 0x8 flag with the far right of row 3 so these cannot be targeted until the right side of row 2 is defeated.
It is also necessary to note that because row 1 does not share any flags with the extreme right and left of row 3, they can be targeted if the corresponding enemy in row 2 is defeated even if the row 1 enemy is still active.
Also of note is that enemies in the same row that share cover flags are not considered.
Only the first five bits may be considered even though the value is stored as a word.

Useful downloads

There are few programs written that will help you edit scene.bin file: