Difference between revisions of "FF7/Field/Encounter"

From Final Fantasy Inside
< FF7‎ | Field
Jump to navigation Jump to search
my_wiki>Synergy Blades
m (Section 7 (Terrence Ferguson))
m (13 revisions imported)
 
(11 intermediate revisions by 3 users not shown)
Line 1: Line 1:
=== Section 7 ([[User:Terence Fergusson|Terence Fergusson]]) ===
+
== Overview  ==
  
As stated, Section 7 is the Encounter listing, and is generally 48 bytes long (not including the Length dword). I've not even started to decrpyt what the other bytes mean around there... I suspect encounter rates and other things. Each encounter is stored something like: xxxxxxxx yyyyyyxx, where the 'x's are the standard Battle ID we're familiar with, and the 'y's are something connected to that specific encounter. Encounters where you can get ambushed appear to be held seperately from the others, too, starting at... what... 0x14? Unsure.
+
The encounter section provides encounter data for the field by referencing [[FF7/Battle/Battle_Scenes|battle IDs]] and providing probabilites for each type of encounter required. The section consists of two ''encounter tables'' that hold sets of these battle configurations; these tables may be switched between using field scripting. The two encounter tables are contiguous and follow directly after the section's length description; due to the presence of the two encounter tables regardless of whether they are used or not, the section length is always 48 bytes.
  
First, every Field file's Encounter section is 48 bytes long (52 if you include the size). It's then split into definite partitions:
+
  struct SECTION_ENCOUNTER
 +
  {
 +
      u32      section_length;    /* 0x30 */
 +
      ENC_TABLE tables[2];
 +
  };
  
0x00: Encounter Data 1, possibly enounter rate in 2nd bytes? (2 bytes)
+
<br />
0x02-0x0D: Encounter+Chance(?) bytes, as stated before. The total of the 'Chance(?)' bytes for this part always adds up to 64 if encounters are possible.
+
 
0x0E-0x17: Secondary encounters. Sometimes blank, sometimes gaps. No clue on the chance bytes, or how it relates to previous data.
+
==  Encounter Table Structure  ==
0x18: Encounter Data 2, same setup as Encounter Data 1. Very often blank, no idea what this data is for.  
+
 
0x1A-0x25: Encounter+Chance(?) bytes for Encounter Data 2. Again, adds up to 64.  
+
  struct ENC_TABLE
0x26-0x2F: Secondary encounters for Encounter Data 2. Again, no idea what it's used for.
+
  {
 +
      u8        enabled;
 +
      u8        rate;
 +
      ENCOUNTER enc_standard[6];
 +
      ENCOUNTER enc_special[4];
 +
      u16      _pad;
 +
  }
 +
 
 +
The first byte of the table provides a switch to signify whether this table is used or not. If set to ''0'' encounters will not be used, regardless of the table contents; ''1'' signifies the table will be used. The second byte signifies the main encounter rate, and ranges from 0xFF (battles occur infrequently) to 0x01 (battles occur very frequently). 0x00 value causes a division by zero.
 +
 
 +
Following these are the ten encounter structures; these are divided into two groups of six and four, as detailed below. There is also a further two-byte "padding" value, used for alignment.
 +
 
 +
===  Switching Between Tables  ===
 +
 
 +
The purpose of two tables is to allow the scripting system to switch between a choice of two sets of encounter data. This is used in-game to allow two levels of difficulty within one field, so that if the player revisits an area in a later part of the game (such as areas of Midgar), the enemies will be suitably more difficult. This can be implemented by placing "easier" encounters in the first table, harder encounter IDs in the second table, and switching appropriately (perhaps by checking the Plot Point Variable).
 +
 
 +
Tables are switched between by simply passing a 0 or 1 to the [[FF7/Field/Script/Opcodes/4B_BTLTB|BTLTB]] opcode, representing the required table. The first table is the default if no BTLTB opcode is specified; either table may be empty, but if switched to using BTLTB, encounters will be deactivated as there will be no encounter data set for that table.
 +
 
 +
==  Encounter Structure  ==
 +
 
 +
  struct ENCOUNTER                      /* pseudo */
 +
  {
 +
      bit      prob[6];
 +
      bit      encounter_id[10];
 +
  }
 +
 
 +
  // Create from two-byte value
 +
  u16 enc_entry;                        /* holds the read value */
 +
  u8  prob        = enc_entry &gt;&gt; 10;
 +
  u16 encounter_id = enc_entry &amp; 0x03FF;
 +
 
 +
Each individual two-byte encounter entry is further split into two groups of bits.
 +
 
 +
The first six bits denote the probability for this encounter; the sum of all the probabilites for the standard encounters is 64, though this is not the case for the special battles. For further information on how encounter probabilities are used and calculated, Terence Fergusson's [http://db.gamefaqs.com/console/psx/file/final_fantasy_vii_enemy_mech.txt Battle Mechanics Guide] contains detailed information.
 +
 
 +
The second ten bits denote the [[FF7/Battle/Battle_Scenes|ID]] of the battle.
 +
 
 +
===  Encounter Entry Types  ===
 +
 
 +
The set of ten battles is split into two groups. The first six battles are generic battles, intended for general use, whose probabilities must total 64. The final four battles are intended to be used in the following order:
 +
 
 +
* Back Attack 1
 +
* Back Attack 2
 +
* Side Attack
 +
* Attack From Both Sides

Latest revision as of 05:14, 23 May 2019

Overview

The encounter section provides encounter data for the field by referencing battle IDs and providing probabilites for each type of encounter required. The section consists of two encounter tables that hold sets of these battle configurations; these tables may be switched between using field scripting. The two encounter tables are contiguous and follow directly after the section's length description; due to the presence of the two encounter tables regardless of whether they are used or not, the section length is always 48 bytes.

 struct SECTION_ENCOUNTER
 {
     u32       section_length;    /* 0x30 */
     ENC_TABLE tables[2];
 };


Encounter Table Structure

 struct ENC_TABLE
 {
     u8        enabled;
     u8        rate;
     ENCOUNTER enc_standard[6];
     ENCOUNTER enc_special[4];
     u16       _pad;
 }

The first byte of the table provides a switch to signify whether this table is used or not. If set to 0 encounters will not be used, regardless of the table contents; 1 signifies the table will be used. The second byte signifies the main encounter rate, and ranges from 0xFF (battles occur infrequently) to 0x01 (battles occur very frequently). 0x00 value causes a division by zero.

Following these are the ten encounter structures; these are divided into two groups of six and four, as detailed below. There is also a further two-byte "padding" value, used for alignment.

Switching Between Tables

The purpose of two tables is to allow the scripting system to switch between a choice of two sets of encounter data. This is used in-game to allow two levels of difficulty within one field, so that if the player revisits an area in a later part of the game (such as areas of Midgar), the enemies will be suitably more difficult. This can be implemented by placing "easier" encounters in the first table, harder encounter IDs in the second table, and switching appropriately (perhaps by checking the Plot Point Variable).

Tables are switched between by simply passing a 0 or 1 to the BTLTB opcode, representing the required table. The first table is the default if no BTLTB opcode is specified; either table may be empty, but if switched to using BTLTB, encounters will be deactivated as there will be no encounter data set for that table.

Encounter Structure

 struct ENCOUNTER                      /* pseudo */
 {
     bit       prob[6];
     bit       encounter_id[10];
 }
 // Create from two-byte value
 u16 enc_entry;                        /* holds the read value */
 u8  prob         = enc_entry >> 10;
 u16 encounter_id = enc_entry & 0x03FF;

Each individual two-byte encounter entry is further split into two groups of bits.

The first six bits denote the probability for this encounter; the sum of all the probabilites for the standard encounters is 64, though this is not the case for the special battles. For further information on how encounter probabilities are used and calculated, Terence Fergusson's Battle Mechanics Guide contains detailed information.

The second ten bits denote the ID of the battle.

Encounter Entry Types

The set of ten battles is split into two groups. The first six battles are generic battles, intended for general use, whose probabilities must total 64. The final four battles are intended to be used in the following order:

  • Back Attack 1
  • Back Attack 2
  • Side Attack
  • Attack From Both Sides