Its complicated.
First you have to make the effect. These typically look like this (for an example S44 tank cannon muzzleflash):
Code: Select all
[LARGE_MUZZLEFLASH]
{
[BitmapMuzzleFlame]
{
class = CBitmapMuzzleFlame;
[properties]
{
dir = dir;
colorMap=1 1 0.5 0.01 1 0.7 0 0.01 0 0 0 0.01;
size=0.5;
length=1;
sizeGrowth=70;
ttl=5;
frontOffset=0.3;
sideTexture=plasma2;
frontTexture=plasma0029;
alwaysvisible=1;
}
water=1;
air=1;
underwater=1;
ground=1;
count=1;
}
[muzzlesmoke]
{
class=CSimpleParticleSystem;
[properties]
{
sizeGrowth=0;
sizeMod=1.0;
pos=0, 0, 0;
emitVector=dir;
gravity=0, 0, 0;
colorMap=0 0 0 0.01 0.5 0.5 0.5 0.5 0 0 0 0.01;
Texture=smokesmall;
airdrag=0.8;
particleLife=20;
particleLifeSpread=0;
numParticles=1;
particleSpeed=10 i-1;
particleSpeedSpread=1;
particleSize=7 i-0.4;
particleSizeSpread=1;
emitRot=0;
emitRotSpread=10;
directional=0;
alwaysvisible=1;
}
air=1;
water=1;
ground=1;
count=10;
}
}
"LARGE_MUZZLEFLASH" is its name for future use.
Then you have to go to the unitdef of the unit you want to use this FX. There are lots of examples from other games/mods, but in general it uses the [sfxtype] section:
Code: Select all
[sfxtypes]
{
explosionGenerator1=custom:MEDIUMLARGE_MUZZLEFLASH;
}
Then finally, in the unit's script file you have to #define the effect properly (and then of course emit it wherever in your script, such as when a weapon fires). To #define it, you'll make a line like this:
#define MEDIUMLARGE_Muzzleflash 1024+1
this allows the script to "detect" the FX; by using the "1024+[the FX included in the sfxtypes section of the unitdef] it will then use that effect when told to, for instance "emit-sfx MEDIUMLARGE_Muzzleflash from flare;"
In S44 we also use emit-sfx to reproduce tracer fire for machineguns, since there's no native way to do that with the engine (and with machineguns, only 1/3 or so bullets fired are actually tracers with the rest being "invisible"). So we made a weapon that effectively does 0 damage which fires little tracer-like lasers, and use the script to force-fire this weapon when the actual machinegun fires.
This is done similarly to above. Make the weapon you want to fire, and include it as a weapon in the unit's unitdef. It doesn't need any parameters, just weapon#=sfxweapon; or whatever.
In your script you'll want a line like this:
#define SMALL_TRACER 2048+4
The '2048' tells the script that "SMALL_TRACER" is a weapon the unit has (in its unitdef file), with the +# telling it which weapon. To figure out this number, take the weapon# (ie in this instance weapon5) and subtract 1 (I have no fucking clue why) -- in this instance in the line above, 2048+4 would define the unit's weapon5. Then you just emit-sfx as normal when you want:
emit-sfx SMALL_TRACER from coaxflare;
Note that the weapon will fire according to the global orientation of the emit piece, so weapons with high tolerances (that appear to shoot slightly sideways out of their barrels) will look kinda silly as the script-emit'd weapon will only fire directly straight. This is most apparent in S44 from sandbag machineguns, when placed on elevated terrain, their emit-sfx tracers will fire straight out above targets that are actually on lower terrain below.
Hope this helps you (and anyone else).