Creating an Effectscript model
An effectscript model is a model with attachment animation sequence events. With an effectscript file, it'll create sprite animation effects in game. Examples are models\effects\teleporttrail.mdl
and models\effects\teleporttrail_Alyx.mdl
, utilized during the teleport scene in the chapter 'Red Letter Day' of Half-Life 2.
You can place one in your map with the env_effectscript
entity.
The default effectscript model consists of a single cube textured with materials/models/effects/base.vmt (this is maybe because if there is no mesh, .SMD wont't be exported), several bones(one root parent, others are child bones of the root), and attachments corresponding to child bones. It also has a sequence that animates bones and attachments. Check Attachments and Bones in HLMV.exe render tab to preview it.
Authoring effectscript models
3D Package
- Make an animating model.
- Place some nulls. Name one null "root", and make this one the parent of the other nulls.
- Name the other nulls like "test1", "test2", etc. You'll make attachments to these bones in .qc file.
- Make keyframe animations with the child nulls. (Use the translate tool)
- Add a small cube, with the
base.tga
texture (only the name matters; you don't have to extract the original one).
- Export it as reference and animation .smd files. Make sure to uncheck "Remove all unused bones" when you are using XSI's SMD exporter.
Setting up the .qc
- In .qc, make attachments to child bones, and add a sequence with AE_START_SCRIPTED_EFFECT and AE_STOP_SCRIPTED_EFFECT events.
Here is a sample .qc:
$modelname "effects/testtrail.mdl" $model "Body" "test_ref.smd" $cdmaterials "models/effects/" $hboxset "default" $hbox 0 "root" -1.000 -1.000 -1.000 1.000 1.000 1.000 // Model uses material "base.vmt" $attachment "MyParticle1" "test1" 0.00 0.00 0.00 rotate 0.00 0.00 0.00 $surfaceprop "metalpanel" $sequence idle "test_ref" fps 30.00 $sequence spiral "test_anim" fps 30.00 { { event AE_START_SCRIPTED_EFFECT 1 "mytest_sprite" } //specify the effect name and its start frame { event AE_STOP_SCRIPTED_EFFECT 99 "mytest_sprite" } //specify the effect name and its end frame. }
effectscript file
- Write an effect script file. Valve puts their effect script file in
hl2\scripts\effects\testeffect.txt
, but you can put your file anywhere under the game directory. You can specify the script file location in env_effectscript entity.
sample "mytesteffect.txt":
effect "mytest_sprite" //effect name { type "sprite" //the other option is "trail" material "sprites/glow01.vmt" attachment "MyParticle1" //point to the attachment in your effectscript model color "255 50 240 128" scale 1 fadetime 3 stopfollowonkill 1 }
Hammer
- In Hammer, place env_effectscript. Specify your model and scriptfile there.
- Effect starts when the env_effectscript receives SetSequence input.