Author Topic: Character/Unit management in FFVII  (Read 4030 times)

Akari

  • *
  • Posts: 766
    • View Profile
Character/Unit management in FFVII
« on: 2006-08-30 18:08:12 »
Could someone explain character and unit (doors and other 3d) management on fields in FFVII.

From where models load, how much models can one map help and so on. I need info to write UnitManager for Q-Gears.

Synergy Blades

  • Guest
Re: Character/Unit management in FFVII
« Reply #1 on: 2006-08-30 19:02:54 »
I can help with the PC version; you load the models from Section 3; structure,

Code: [Select]
struct FF_MODEL_LOADER
{
U32 sectionLength;
U16 _blank;
S16 nObjects;
U16 size;
std::vector<FIELDOBJECT> fieldObjectSet;
};


Each object has this structure;

Code: [Select]
struct FIELDOBJECT
{
S16 nameLength;  // Length of string "szName"
_STRING szName;  // Object name (purely representative; doesn't correlate to a physical file)
S16 _blank;
CHAR szSkeletonName[12];  // Model file the object uses
U16 nAnims;  // Number of animations found in animSet
LIGHT light[3];  // Three point lights
COLOR<U8> ambient;   // Ambient lighting
std::vector<ANIMATION> animSet;     // Animation files this object uses
};

/// Lights used for field models, containing colour and position
struct LIGHT
{
COLOR<U8> col;
VERTEX<S16> pos;
};

/// Holds name length, and name, of an animation file
struct ANIMATION
{
S16 nameLength;
_STRING szAnimName;
S16 _unknown;
};

/// Holds a colour triple
template <class type>
struct COLOR
{
type r, g, b;
};

(For the object name: at a guess, the models were originally previewed, lit and animated using a seperate tool/app, then linked into the field file, with their original filenames preserved. It doesn't serve any purpose in the game).

Each field object is linked to a particularly entity if that entity has a CHAR as its first opcode in its first script. Take a look at my explanation of the CHAR opcode on the wiki for more information; basically, while scanning through the script if you encounter a CHAR opcode, assign the next field object to the current entity (whose script you are scanning) and advance the 'field object pointer' to the next entry in the field object set. Ignore the CHAR argument as it has no bearing on the field object loaded for that model; the second example on the wiki entry demonstrates the numerical argument doesn't represent an offset into the model list.

In addition the PC opcode defines a playable character though I'm not 100% on how it works; I tweaked it around a little and the sole argument seems to follow the standard Character IDs (0: Cloud, 1: Tifa, 2: Barret and so on), but this would appear to override the field object's model file setting, so I'm not too sure.

Doors aren't 3D, they are part of the background, and linked to entities that open/close the doors using BGON and BGOFF opcodes to switch parts of the background on and off (i.e particular doors), as well as Triggers from Section 8 which, when crossed, run the particular scripts containing said BGON/BGOFF in the entity that manages the door. There's (usually?) one entity per door.

Not sure about max. number of objects on the field. Theoretically I suppose you could have 256 on a field, since the section 1 "number of visible entities" variable is a byte value.

[Edit] Thought I should also mention, most field objects have an XYZI to initially position them on the walkmesh, but not all. For example, often Cloud doesn't have one, because he can be positioned by the previous field when the player crosses a Gateway (section 8.) which contains the coordinates that the character should be at when the next field loads up. If you get all these factors right I reckon it should look a little like so;



Blue squares being field objects, light blue lines of the same colour are the scripted LINE opcodes.
« Last Edit: 2006-08-30 19:39:07 by Synergy Blades »

Akari

  • *
  • Posts: 766
    • View Profile
Re: Character/Unit management in FFVII
« Reply #2 on: 2006-08-30 19:39:36 »
Doors aren't 3D, they are part of the background, and linked to entities that open/close the doors using BGON and BGOFF opcodes to switch parts of the background on and off (i.e particular doors), as well as Triggers from Section 8 which, when crossed, run the particular scripts containing said BGON/BGOFF in the entity that manages the door. There's (usually?) one entity per door.

There are 3d doors. For example right after the start of the game there are 3d doors that Jessie opens (it slide to the left). And there are some others object like savepoint....

Synergy Blades

  • Guest
Re: Character/Unit management in FFVII
« Reply #3 on: 2006-08-30 19:40:29 »
Ah, those, yeah. They're field objects, as described above, with their own entity, and scripts to manage them.

Akari

  • *
  • Posts: 766
    • View Profile
Re: Character/Unit management in FFVII
« Reply #4 on: 2006-08-31 15:04:11 »
Each field object is linked to a particularly entity if that entity has a CHAR as its first opcode in its first script. Take a look at my explanation of the CHAR opcode on the wiki for more information; basically, while scanning through the script if you encounter a CHAR opcode, assign the next field object to the current entity (whose script you are scanning) and advance the 'field object pointer' to the next entry in the field object set. Ignore the CHAR argument as it has no bearing on the field object loaded for that model; the second example on the wiki entry demonstrates the numerical argument doesn't represent an offset into the model list.

I'm confused about argument for CHAR opcode. I don't believe that it has no meaning....... damn it. =)



ps: By the way, could you describe all window opcode? I want to implement them all first. The base opcodes such as WINDOW, MESSAGE and ASK are done... but a lot of others remains =)

Synergy Blades

  • Guest
Re: Character/Unit management in FFVII
« Reply #5 on: 2006-08-31 15:32:17 »
I'm sure about it. In playing around with uutai I set all CHARs to FF, and it loads and operates entirely as normal. So looking at uutai, you have these entities;

Code: [Select]
...
directr
CLOUD*
EARITH*
BALLET*
...
VINCENT*
AD
AD2
PEPA*
PEPB*
....

As you read the CLOUD entity you see it has a CHAR opcode, so you assign it field object[0]; the same with EARITH, so assign it the next field object, [1], and so on; VINCENT gets [8], PEPA[9].

Don't know much about the window opcodes, only really digged into the ones I've put on the Wiki. I know a little about the remainder but I decided not to put up ones where I have an unknown in the argument list. You're bound to hit problems with scripting and bits of the field file in general since you'll get to the point where you need opcodes we can't fully describe yet, or parts of the field file that are as yet unknown.  :-D
« Last Edit: 2006-08-31 15:34:49 by Synergy Blades »

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Character/Unit management in FFVII
« Reply #6 on: 2006-08-31 15:54:37 »
There is another area of 3d field objects used as doors.
The train graveyard which is in section 6 of midgard. There are 2 trains sitting in the field screen that are movable. These are 3d objects.
I am not certain but one you need to enter to move to get back to sector 7 for the pillar event to trigger.
I think doors are triggered portals no? They don't use the Jump Opcode at all if I remember correctly.

Anyhow I think Akari is trying to get script interaction going. (IE talking et al).

Akari what are you using for the window system? Have you looked at Xenogears information for the conversations?
It might be good to use a more 'generic' system for the window system base and translate the FF7 opcodes and specifics acordingly.
I'm almost done with the ISO 'changes' (mutter).

Cyb

Akari

  • *
  • Posts: 766
    • View Profile
Re: Character/Unit management in FFVII
« Reply #7 on: 2006-09-01 14:56:16 »
Akari what are you using for the window system? Have you looked at Xenogears information for the conversations?
It might be good to use a more 'generic' system for the window system base and translate the FF7 opcodes and specifics acordingly.

The only class that handles window is WindowManager.

Mmm i found opcodes that shows dialog.... but not all of them and oll of them are understand clearly.

Code: [Select]
0xD2         DialogShow(u8 dialog_id, u16 flags);
                 flags meaning are dont known

Maybe it will be good... but window system in xenogears are still in clouds so I try not haste.
Right now I adding XML support to q-gears and then will add external script and dialog support. I need this because write my own script like this just for test is a bit hard =)

Code: [Select]
    Entity* entity = new Entity();
    entity->SetName("temp");

    u8 script_a[114] = {
    0x50,0x01,0xFF,0x00,0xFF,0x00,0x8A,0x00,0xA9,0x00,
    0x48,0x05,0x01,0x00,0x00,0x09,0x00,
    0x10,0x33,

    0x52,0x01,0x02,0x00,
    0x50,0x01,0xFF,0x00,0xFF,0x00,0x81,0x00,0x59,0x00,
    0x48,0x05,0x01,0x01,0x00,0x04,0x00,
    0x52,0x01,0x00,0x00,
    0x10,0x21,

    0x52,0x01,0x02,0x00,
    0x50,0x01,0xFF,0x00,0xFF,0x00,0x81,0x00,0x59,0x00,
    0x40,0x01,0x01,
    0x52,0x01,0x00,0x00,
    0x12,0x43,

    0x15,0x50,0x00,0x00,0x00,0x16,0x00,
    0x12,0x39,

    0x15,0x50,0x00,0x00,0x00,0x04,0x00,
    0x12,0x55,
    0x15,0x50,0x00,0x01,0x00,0x04,0x00,
    0x12,0x30,
    0x15,0x50,0x00,0x02,0x00,0x0C,0x00,
    0x60,0x74,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
    0x00
    };


    Script* script = new Script(script_a, 114);
    entity->AddScript(0, script);
    scriptManager.PushEntity(entity);

Cyberman

  • *
  • Posts: 1572
    • View Profile
Re: Character/Unit management in FFVII
« Reply #8 on: 2006-09-01 19:06:57 »
The only class that handles window is WindowManager.

Mmm i found opcodes that shows dialog.... but not all of them and oll of them are understand clearly.

Code: [Select]
0xD2         DialogShow(u8 dialog_id, u16 flags);
                 flags meaning are dont known

Maybe it will be good... but window system in xenogears are still in clouds so I try not haste.
Right now I adding XML support to q-gears and then will add external script and dialog support. I need this because write my own script like this just for test is a bit hard =)
Basically you need to make scripts to test the window system. IE Unit test scripts. Ones that do not use unimplemented features of the script system yet namely ;)

It would probably would be a good idea to start setting up schema for command information in an XML database.
Now comes the time of setting things up so it's not a mess later :D

Cyb