Skip to content

KFUS: Game Database

TheStolenBattenberg edited this page Mar 6, 2021 · 6 revisions

This page describes the Game Database file.

Storage

The Game Database is stored in FDAT.T as true file 28. This file contains 9 sections of data used internally by the game. Each data section is preceded by its size as a 4-byte unsigned integer.

The offsets to the sections (skipping the integer that defines their size) are as follows:

Offset Description
0x0004 Section 1 - Object Class Declarations
0x1E08 Section 2 - Weapon Stats
0x22DC Section 3 - Armor Stats
0x2AE0 Section 4 - Player Level Data
0x2F94 Section 5 - Magic Data
0x3618 Section 6 - Tile Render Param
0x411C Section 7 - Sound Effect Param
0x4B20 Section 8 - Unknown
0x63AC Section 9 - Unknown

Section 1 - Object Class Declarations

This section is used by the game to check the behavior of objects of a certain type. This section contains 320 instances of the structure below.

Offset Type Name
0x0 byte Unknown
0x1 byte Some Type ?
0x2 byte Unknown
0x3 byte Unknown
0x4 u_short Collision Radius
0x6 byte Unknown
0x7 byte Unknown
0x8 u_short Unknown
0xa u_short Unknown
0xc byte Unknown
0xd byte Unknown
0xe byte Unknown
0xf byte Unknown
0x10 byte Unknown
0x11 byte Unknown
0x12 byte Unknown
0x13 byte Unknown
0x14 byte Unknown
0x15 byte Unknown
0x16 byte Unknown
0x17 byte Unknown

Section 2 - Weapon Stats

This section is used to store the stats for each weapon item in the game. This section contains 18 instances of the structure below.

Offset Type Name
0x0 KingsFieldSFX Sound Effect
0x1 byte Strength Stamina Cost
0x2 byte Unknown
0x3 KingsFieldMagicID Spell 1
0x4 KingsFieldMagicID Spell 2
0x5 byte Spell 1 Shot Amount
0x6 u_short Slash Offense
0x8 u_short Chop Offense
0xa u_short Stab Offense
0xc u_short Holy Magic Offense
0xe u_short Fire Magic Offense
0x10 u_short Earth Magic Offense
0x12 u_short Wind Magic Offense
0x14 u_short Water Magic Offense
0x16 u_short HP Restore Timer
0x18 u_short MP Restore Timer
0x1a short Attack Range
0x1c u_short Swing Speed
0x1e u_short Swing Damage Start Time
0x20 u_short Spell 1 Cast Start Time
0x22 u_short Spell 1 Cast End Time
0x24 short Spell 2 Animation Speed
0x26 u_short Unknown
0x28 u_short Spell 2 Damage Start Time?
0x2a u_short Unknown
0x2c u_short Unknown
0x2e u_short Unknown
0x30 u_short Unknown
0x32 short Unknown
0x34 SVECTOR Position?
0x3c SVECTOR SomeVec

Section 3 - Armor Stats

This section is used to store the stats for each armor item in the game. This section contains 64 instances of the structure below.

Offset Type Name
0x0 u_short Thingie?
0x2 u_short Slash Defense
0x4 u_short Chop Defense
0x6 u_short Stab Defense
0x8 u_short Poison Defense
0xa u_short Dark Magic Defense
0xc u_short Fire Magic Defense
0xe u_short Earth Magic Defense
0x10 u_short Wind Magic Defense
0x12 u_short Water Magic Defense
0x14 u_short Unknown
0x16 u_short Unknown
0x18 u_short Unknown
0x1a u_short Unknown
0x1c u_short Unknown
0x1e u_short Unknown

Section 4 - Player Level Data

This section is used to store the data for each player level. This section contains 100 instances of the structure below.

Offset Type Name
0x00 unsigned short HP
0x02 unsigned short MP
0x04 unsigned short Strength Power Increase
0x06 unsigned short Magic Power Increase
0x08 unsigned int Experience for the next level

For the first player level, Str Power Increase and Mag Power Increase are the actual Str Power and Mag Power values. For each level afterwards, they are the amount by which the powers increase in relation to the previous level.

Example data:

Level 1

Description Value
HP 50
MP 30
Str Power Increase 20
Mag Power Increase 20
Experience for the next level 50

Level 2

Description Value
HP 57
MP 34
Str Power Increase 1
Mag Power Increase 1
Experience for the next level 110

Section 5 - Magic Data

This section contains information about the magic spells in the game such as MP cost and damage. This section contains 64 instances of the structure below. Spells are indexed using the IDs from KingsFieldMagicID.

Offset Type Name
0x0 bool Player Has
0x1 byte Magic Stamina Cost
0x2 byte Unknown
0x3 byte Unknown
0x4 byte Status Effect
0x5 byte Unknown
0x6 byte Unknown
0x7 byte Unknown
0x8 u_short Some Damage 1
0xa u_short Some Damage 2
0xc u_short Some Damage 3
0xe u_short Fire Damage
0x10 u_short Earth Damage
0x12 u_short Wind Damage
0x14 u_short Water Damage
0x16 u_short MP Cost
0x18 byte Unknown
0x19 byte Unknown

Section 6 - Tile Render Param

This section is used to control tile/object lighting (basically grid lighting), there is 80 of them, 64 of which are loaded dynamically from this section of the Game DB. They appear to be a PsyQ colour matrix, followed by a basic colour and draw distance.

Offset Type Name
.... .... ....
0x26 byte Red
0x27 byte Green
0x28 byte Blue
0x29 byte Unknown
0x2A ushort Draw Distance

* Red, Green, Blue and Unknown are seen as a single int. Unknown is probably padding.

Section 7 - Sound Effect Param

This section contains a list of simple structures which control how different sound effects are played.

Offset Type Name
0x00 short Unknown *
0x02 short Unknown
0x04 short VAB Tone ID
0x06 short Pitch
0x08 short Unknown

* This is equal to 0xFFFF when it is unused.

Section 8 - MO List

This section contains a weird list of TMDs (for hud/magic purposes), with a 16 byte header for each entry

Offset Type Name
0x0 u_int Unknown
0x4 u_int Offset to next TMD
0x8 u_int Unknown
0xC u_int Unknown

Section 9 - MO List

This section is identical to section 8, but has different TMDs.