Jump to content

An introduction to VEF files

Recommended Posts

An introduction to VEF files




The VEF format (short for: Visual Effect File) has been discovered not too long ago by the forum member Ascension64. Although it is relatively unknown yet, the format can be a big help if used right.


Basically a VEF file enables you to group any number of visual effects (VEF/VVC), animations (BAM), and sounds (WAV) together and specify a delay for each component to be triggered. That way you can create a series of visual effects to be played back on (a single!) command, without the hassle to put lots of Wait() or SmallWait() instructions in between.


It is also possible to use VEF files in spells. By using effect opcode #215 (Play 3D Effect) you can add a VEF file into the resource field as you can already do for BAMs or VVCs. There is a minor drawback however. The effect state 1 (Play on target (attached)) doesn't appear to be supported.


Setting up a VEF file is pretty straightforward. The format consists of a global header and an array of two kinds of components ('Component1' and 'Component2') containing the definitions of the actual effects. It doesn't really matter which one of the components you want to use. Both kinds appear to be used equally by the BG2 engine. The components don't have to be ordered chronologically as well. The game engine will do that for you.


Caution: It is possible to recursively nest a VEF file in itself. This will produce an endless loop and, in some cases, may cause the game to grind to a halt.



Creating a VEF file


The easiest way to understand the format is by creating a VEF by yourself. That's why I will provide a step-by-step instruction to create a nifty visual effect that could be used for imprisonment spells or the like.


Note: You will need a version of Near Infinity that includes VEF support to follow this tutorial. You can find it here.


Starting with Near Infinity w1.3.0, you can easily create a new VEF file by selecting the menu entry File->New Resource->VEF.





Enter the name A7FLASHY.VEF (or any other name you like) into the file creation dialog and click "Save". Press F5 or select Game->Refresh Tree to register the newly created file in Near Infinity.


Depending on how you have configured NI, the resource can be found in the Override or VEF folder and should look like this:







We are now ready to add our effects into the VEF. Each effect has to be defined within a 'component' structure. To create a new component, click on the Add... button in the bottom panel and select either 'Component1' or 'Component2'. It doesn't matter which one you choose. Both types are processed equally by the game engine. Double click the resulting table entry to open our new component for further editing. The table contains five relevant fields:






As this is the first component in our VEF, we want it to be triggered immediately. That's why we leave the 'Ticks until start' field as it is. I will explain this field further down below.


Now to the interesting parts. The 'Resource type' field determines what kind of resource the VEF will be looking for, when it is about to be triggered. As you can see, I have selected 'VVC/BAM'. That will cause the game engine to look for a VVC file first and fall back to a BAM resource if no VVC has been found. The same is true if you select 'VEF/VVC/BAM'. It will signal the game engine to look for the resource in the order VEF->VVC->BAM. The 'WAV' entry will cause the game engine to look for sound files only. For the effect in our example it isn't important whether you choose 'VVC/BAM' or 'VEF/VVC/BAM'.


The 'Resource' field should present you a list of available VVC and BAM files. The files in the list reflect the resource type you have chosen in the field above, so make sure you have already selected 'VVC/BAM'. As the file SPFLSRIN is available as both VVC and BAM, the game engine will choose to trigger the VVC version when you activate the VEF.


The remaining fields won't be touched in our VEF. If you set 'Ticks until loop' to a non-zero value, the animation will be looped endlessly, starting at the first frame of the animation. The specified number of ticks defines how long each pass will take until the loop starts over again. The field 'Continuous cycles?' determines whether only the first or all cycles within a BAM resource will be processed. This field will only be taken into account by the game engine if you select 'VVC/BAM' in the 'Resource type' field.


After our first component has been defined, you can close the window to return to the parent structure.


The second component should be triggered a short while after our first. So we enter a value into the field 'Ticks until start'. In our case, a value of 30 is suitable. One tick is processed in 1/30th seconds, therefore our effect will be triggered after exactly one second. As the default frame rate of animations is 15 fps, you can divide our delay value by two, if you want to find out how many frames of the animation defined in our first component have been processed, before our second component starts up. Sometimes you have to add or remove one tick to ensure a seamless transition between the animations.


Select 'VVC/BAM' again and select SPPLANAR.VVC in the 'Resource' field. The resulting component should now look like this:







For our third component we set the field 'Ticks after start' to 70 and select the BAM resource SPIMPPT.BAM, as seen in the screenshot.







Our fourth and last component contains a sound effect. That's because the previous component makes use of a simple BAM file, which isn't associated with a sound resource. We use the same number of ticks as for the previous component and choose WAV in the 'Resource type' field. The file list of the Resource field should now display all available WAV resources of the game. Select the file EFF_P92.WAV as shown below:







The resulting VEF resource should now look like this:






Note: The order of the components within the VEF file doesn't really matter. The game engine looks only for the starting delay and orders the components appropriately.


Save the changes you've made to the VEF file and we are done.


If you want to test it without creating a VEF by yourself, you can try out this pre-built one: a7flashy.zip


To trigger the VEF resource within the game, you can either use a script action, for example


CreateVisualEffectObject("A7FLASHY", "Edwin")

...or place it into a spell or item by using effect opcode #215 (Play 3D Effect). You can not set effect state=1, however.


Note: For testing purposes, you can also open the CLUA console and enter CLUAConsole:CreateVEFVidCell("A7FLASHY") to trigger our VEF resource at the center of the screen.


If everything went well, you should see a sequence of visual effects as shown below:







To do the same sequence of effects the old way, you would have to come up with something like this:

CreateVisualEffectObject("SPFLSRIN", "Edwin")


CreateVisualEffectObject("SPPLANAR", "Edwin")


CreateVisualEffectObject("SPIMPPT", "Edwin")

ActionOverride("Edwin", PlaySound("EFF_P92"))

As you can see, you can save a lot of code (and trouble) by using VEF files instead. This is especially true when you need to trigger the same sequence more than once or use more complex VEFs.


This tutorial has covered only a small part of what you can do with VEF files. Using the ability to nest VEF resources, you can easily produce a great number of complex sequences in short time. The same would have been accomplished by putting down dozens or even hundreds of lines of repetitive script code that would become unmanageable very soon.

Edited by argent77

Share this post

Link to post

I never tested this, but what happens if you change the game's frame rate? Will stuff go out of sync if you decided to use cutscene actions with a single VEF?

Edited by Ascension64

Share this post

Link to post

I have just tested it by doubling and halving the value of the 'Maximum Frame Rate' entry in my baldur.ini. In both cases the delays and speed rates of the animations within the VEF were reflecting the new speed rate of the game perfectly, i.e. there were no gaps or overlappings when playing back the different animation segments.


As a side note, if you specify a negative value in the 'Ticks until start' field, it will be treated as 0 by the game engine.

Share this post

Link to post

I try to create a VEF file with a splitted bam file.


The goal is to play the three cycles together, just like the "draw all cycles" option in DLTCEP.


All my attempts failed : using the single bam, creating 3 vvc files playing one cycle and mixing them with 0 "tick" in a VEF file.


Does anyone have a single clue how to make it ?



Edited by Gwendolyne

Share this post

Link to post

You can't address BAM cycles in VEF files directly. The easiest way to accomplish this is by creating a VVC for each cycle and add the VVCs to the VEF. If you want to play all cycles simultaneously, just leave the "Ticks until start" value to 0 for all VEF entries.


You can use this test sample to see if it works. (For a quick in-game test, use the CLUA command CLUAConsole:CreateVEFVidCell("GWANIM").)


Edit: VEF files can only be used for stationary effects, so don't use effect opcode #215 (Play visual effect) with param2 set to 1 (Over target attached).

Edited by argent77

Share this post

Link to post

Thanks for the sample ! :)


In fact, I finally managed to create a VEF file that works : the same ! ;)


But I have another pb : GWFILET.VEF refers to 3 VEF Files. The 1st one GWFILET1 is the empty net that is going down. The 3rd GWFILET3 is the net full of fishes going up.

The 2d GWFILET2 is the empty net staying down for about 2 mn before GWFILET3 starts. This last one doesn't work : the bam file has the same structure but with only one frame splitted into three parts. I use the "Ticks until loop" set to 1 to display it continuously, but it only displays the top part of the net (cycle 1), and not cycles 2 and 3 (all of them using vvc files as for GWFILET1 and GWFILET3).


Maybe have I missed something ?

Share this post

Link to post

Did you set "Ticks until loop" for all segments in the VEF? If not, the remaining parts will probably be shown only for a split second.

Share this post

Link to post

You need to Continuous cycles, not ticks until loop (the latter is how many updates until the animation restarts). This would need to be set for your last resource only (not in the primary VEF).

Edited by Ascension64

Share this post

Link to post

I have got a problem with a trigger script :

    DisplayStringHead(Myself,@2001038)    // ~La roue est difficile à tourner, mais vous y parvenez tout de même. Vous entendez le craquement du monte-charge qui descend.~

GWASC1DE is a VEF file displaying 4 vvc files at the same time (a splitted bam file). I checked it with success using the CLUAConsole:CreateVEFVidCell("GWASC1DE") command.


But launched with above script above, the animation is not displayed. I can only hear the sound associated with the fiirst vvc file.


Any idea?


Share this post

Link to post
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...