Creating an Effectscript model: Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(stub with .qc and script sample)
 
m (minute tweak for clarity)
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{stub}}
{{stub}}
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 <code>models\effects\teleporttrail.mdl</code> and <code>models\effects\teleporttrail_Alyx.mdl</code>, utilized during the teleport scene in the chapter 'Red Letter Day' of Half-Life 2.
You can place one in your map with the <code>[[Env effectscript|env_effectscript]]</code> 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.
*Make an animating model.
*In .qc, make attachments, and add a sequence with AE_START_SCRIPTED_EFFECT and AE_STOP_SCRIPTED_EFFECT events.
**Place some nulls. Name one null "root", and make this one the parent of the other nulls.
*Write an effect script file.
**Name the other nulls like "test1", "test2", etc. You'll make attachments to these bones in .qc file.  
*In Hammer, place [[Env effectscript|env_effectscript]]. Specify your model and scriptfile there.
**Make keyframe animations with the child nulls. (Use the translate tool)
*Effect starts when the [[Env effectscript|env_effectscript]] receives SetSequence input.
**Add a small cube, with the <code>base.tga</code> 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 ''un''check "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:


sample .qc:
<pre>
<pre>
$modelname "effects/testtrail.mdl"
$modelname "effects/testtrail.mdl"
Line 21: Line 36:
$sequence spiral "test_anim" 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_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 end frame.
   { event AE_STOP_SCRIPTED_EFFECT 99 "mytest_sprite" } //specify the effect name and its end frame.
}
}
</pre>
</pre>


sample effect script:
===effectscript file===
 
*Write an effect script file. Valve puts their effect script file in <code>hl2\scripts\effects\testeffect.txt</code>, but you can put your file anywhere under the game directory. You can specify the script file location in [[Env effectscript|env_effectscript]] entity.
 
sample "mytesteffect.txt":
<pre>
<pre>
effect "mytest_sprite" //effect name
effect "mytest_sprite" //effect name
Line 38: Line 57:
}
}
</pre>
</pre>
===Hammer===
*In Hammer, place [[Env effectscript|env_effectscript]]. Specify your model and scriptfile there.
*Effect starts when the [[Env effectscript|env_effectscript]] receives SetSequence input.
[[Category:Modeling]]

Latest revision as of 20:15, 16 May 2012

Stub

This article or section is a stub. You can help by expanding it.

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