The FX system in id tech 4 is a great way to create an effect that is essentially a multi-layered effect using any combination of media types you'd like. While you can typically create the same type of effect using various scripting methods, it's often easier and more efficient to create an FX declaration.
The types of actions you can call within a single FX decl. are lights, particles, models, entities, sounds, decals, and projectiles.
You can set these in DEF entries as well as call them directly in scripts. An FX declaration is contained within a .fx file placed in your /base/fx directory.
Keywords include(table from iddevnet.com):
delay <time> | How long (in seconds) after starting the effect before this action happens |
shake <time> <amplitude> <distance> <falloff> <impulse> | Shake the player around a bit. |
ignoreMaster | Don't shake the entity this effect is attached to |
random <min>, <max> | A random time added to the delay. |
fire <sibling> | Causes the sibling action to happen when this action does. This is a way of synching two random actions.
|
duration <time> | How long the action lasts before it is killed or restarted |
restart <bool> | Set to 1 if the action starts again after the 'duration' has run out |
fadeIn <time> | Fade in the RGB of the light or model over <time> seconds |
fadeOut <time> | Fade out the light/model. Ignored if fadeIn is set, you can use 2 separate actions (tied together with uselight) if you want a light to fade in and out. |
offset <x>, <y>, <z> | Offset from the origin of the entity (or bind point) this action is located at |
axis <x>, <y>, <z> | Axis of the model, mutually exclusive with angle |
angle <pitch>, <yaw>, <roll> | Alternate way of setting the axis of the model |
light <material>, <red>, <green>, <blue>, <radius> | Create a light |
noshadows | The light in this effect doesn't cast shadows |
attachlight <light> | Attach to external light (a light not defined in the effect) for fading. |
attachentity <entity> | Attach to an external entity. |
launch <entity> | Launches a projectile. |
uselight <sibling> | Modify the light values in a sibling action. Can be used to fade out a light that faded in earlier.
|
useModel <model> | Modify the model in a sibling action. Can be used to fade out a particle in a sibling. |
model <model> | Creates (or fades in) a model |
particle <model> | Creates (or fades in) a particle |
decal <material> | Applies the specified decal to the ground (and anything else in the area) |
size <int> | Size of the decal |
trackorigin <bool> | Move around with the entity (vs stationary after spawning) |
sound <sndshader> | Start a sound (on any channel) |
Example FX entry:
fx fx/velch_death
{
{
name "gibpart1"
delay 0
duration 3.0
particle "hex_gib_eoc_01.prt"
}
{
name "velchdecal"
delay 0
duration 25
decal "textures/decals/dsplat2"
size 96
}
}
This a basic 2 part FX used when monster_velch dies. When the decl is called it spawns two different entities. The first named “gibpart1” is the dense blood particle you see in the image. With a 0 delay and 3.0 duration the particle spawns the specified particle immediately and is removed after 3 seconds.
The second part named “velchdecal” is the splatter you see on the floor. Again we spawn it immediately using a 0 delay but we leave the decal on the ground for a duration of 25 seconds. We use the material declaration "textures/decals/dsplat2" scaled at 96x96.
In ai_monster_velch.script, we simply call it during "state_killed":
void monster_velch::state_Killed() {
startFx("fx/velch_death");
animState( ANIMCHANNEL_TORSO, "Torso_Death", 0 );
animState( ANIMCHANNEL_LEGS, "Legs_Death", 0 );
waitAction( "dead" );
hide();
sys.wait( 4 ); //give sounds time to fade out
stopMove();
stopSound( SND_CHANNEL_ANY, 0 );
setState( "state_Dead" );
}