SPECIAL VFX (SKILLS & EQUIPMENT)

This section describes how we created the visual effects for almost all skills and equipment. This does NOT mean it is the only way and we'd like to encourage those interested in creating better and more varied visual effects for those features. As is customary, we'll use an example. In this case we'll use Spg2\SpecialEffect\RepairBots\activation.sal and it's prudent to have the script opened up in Notepad++ for a better overview.

THE THEORY

The Repair bots activation visual effect uses a simple principle:

  1. Create desired models, import them etc.
  2. Decide on the wanted animation (usually a series of simple animations like repositioning, rotation, scaling, transparency...)
  3. Write a script to animate the whole thing, model by model, in the correct sequence

Similarly to explosions, this kind of scripts look more complex than they really are.


GETTING THE MODELS ASSEMBLED AND READY FOR USAGE

  1. It's always good practice to know in advance what you want to do with the individual models, how to animate them etc. A bit of planning, but useful in the long run. Makes the next step easier.
  2. Link all the models you'll be using into the same assembly (*.asb). This will make it easier to manipulate them later. Our general procedure was to have all such models scaled to size 1. This makes it easier to calculate resizing via scripts later.
  3. Add the assembly as a new entry in the FreeModel.wds. You'll be referencing this database from the animation script. It CANNOT work in any other way!

SCRIPTING ANIMATIONS

	/* set scale size */
	float3 scaleReal = 1.0 1.0 1.0 ;
	float3 scaleRealInterim = 1.0 1.0 1.0 ;
	float3 scaleStart = 1.0 1.0 1.0 ;
	float shipRadius = 1.0 ;
	ship GetPlayer GetRadius shipRadius ;
	math scaleRealInterim = scaleStart * shipRadius ;
	math scaleReal = scaleRealInterim * 1.0 ;
	

The initial segment does some basic size calculations to make the script reusable regardless of the ship size the effect is seen on/around. This is where it comes in handy to have all effect models scaled to 1.0.

	/* asbId -> FreeModel.wds */
	int retId = 0 ;
	float delay = 0.0 ;
	float3 position = 0.0 0.0 0.0 ;
	int asbId = 206 ;
	float lifetime = 3.0 ;
	assemblyex Create retId delay position asbId lifetime ;
	

This portion Creates the actual model in the game. We initially give it a lifetime so there's no potential memory leak left open.

	/* starting properties */
	float interpolation = 0.0 ;
	assemblyex GetMesh retId 1 SetScale scaleReal interpolation delay ;
	assemblyex GetMesh retId 2 SetScale scaleReal interpolation delay ;
	assemblyex GetMesh retId 3 SetScale scaleReal interpolation delay ;
	/* gears */
	assemblyex GetMesh retId 0 SetScale scaleReal interpolation delay ;
	assemblyex GetMesh retId 15 SetScale scaleReal interpolation delay ;
	assemblyex GetMesh retId 16 SetScale scaleReal interpolation delay ;

	float3 posGear2 = -0.11	0.00	-0.41 ;
	float3 posGear3 = 0.24	0.00	0.35 ;
	math posGear2 = posGear2 * shipRadius ;
	math posGear3 = posGear3 * shipRadius ;

	assemblyex GetMesh retId 15 SetPosition posGear2 interpolation delay ;
	assemblyex GetMesh retId 16 SetPosition posGear3 interpolation delay ;

	float3 scaleLinesStart = 0.0 0.0 0.0 ;
	float3 scaleStartAdjust = 1.0 0.0 1.0 ;
	math scaleLinesStart = scaleReal * scaleStartAdjust ;
	assemblyex GetMesh retId 4 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 5 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 6 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 7 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 8 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 9 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 10 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 11 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 12 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 13 SetScale scaleLinesStart interpolation delay ;
	assemblyex GetMesh retId 14 SetScale scaleLinesStart interpolation delay ;

	pause 0.1 ;
	

We primarily set initial values to the individual models in the assembly. Their size, transparency, position, whatever... What is needed depends on what the animation will look like. A very short pause is set, so the next block doesn't override the initial state.

	float transparency = 1.0 ;
	interpolation = 1.25 ;
	assemblyex GetMesh retId 1 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 2 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 3 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 0 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 15 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 16 SetTransparent transparency interpolation delay ;

	float3 posLine1 = 0.0 3.0 0.0 ;
	float3 posLine2 = 0.0 -3.0 0.0 ;
	assemblyex GetMesh retId 2 SetPosition posLine1 interpolation delay ;
	assemblyex GetMesh retId 3 SetPosition posLine2 interpolation delay ;

	interpolation = 0.5 ;
	assemblyex GetMesh retId 4 SetScale scaleReal interpolation delay ;
	assemblyex GetMesh retId 5 SetScale scaleReal interpolation 0.1 ;
	assemblyex GetMesh retId 6 SetScale scaleReal interpolation 0.2 ;
	assemblyex GetMesh retId 7 SetScale scaleReal interpolation 0.3 ;
	assemblyex GetMesh retId 8 SetScale scaleReal interpolation 0.4 ;
	assemblyex GetMesh retId 9 SetScale scaleReal interpolation 0.5 ;
	assemblyex GetMesh retId 10 SetScale scaleReal interpolation 0.6 ;
	assemblyex GetMesh retId 11 SetScale scaleReal interpolation 0.7 ;
	assemblyex GetMesh retId 12 SetScale scaleReal interpolation 0.8 ;

	transparency = 0.0 ;
	interpolation = 1.25 ;
	assemblyex GetMesh retId 1 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 2 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 3 SetTransparent transparency interpolation delay ;

	pause 0.5 ;
	

The above section is simple playing around with the model parameters over a period of time. We change transparency so the models fade in and with scale to make them stretch out from the center...

	interpolation = 0.5 ;
	transparency = 0.0 ;
	assemblyex GetMesh retId 4 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 5 SetTransparent transparency interpolation 0.1 ;
	assemblyex GetMesh retId 6 SetTransparent transparency interpolation 0.2 ;
	assemblyex GetMesh retId 7 SetTransparent transparency interpolation 0.3 ;
	assemblyex GetMesh retId 8 SetTransparent transparency interpolation 0.4 ;
	assemblyex GetMesh retId 9 SetTransparent transparency interpolation 0.5 ;
	assemblyex GetMesh retId 10 SetTransparent transparency interpolation 0.6 ;
	assemblyex GetMesh retId 11 SetTransparent transparency interpolation 0.7 ;
	assemblyex GetMesh retId 12 SetTransparent transparency interpolation 0.8 ;

	pause 0.1 ;
	

After a short pause, we again changed some model parameters for variation and a slightly longer animation. How long an animation will last depends only on YOU. We kept them between 3 and 6 seconds.

	/* models fade out */
	transparency = 0.0 ;
	interpolation = 1.0 ;
	assemblyex GetMesh retId 0 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 15 SetTransparent transparency interpolation delay ;
	assemblyex GetMesh retId 16 SetTransparent transparency interpolation delay ;
	

To wrap it all up, we fade out each model. Notice the entire animation script, when all interpolations and pauses are combined, takes less time to play out than the initially set Lifetime of the Created assembly ;).