CEG:Defs
CEG Definitions
Source
The engine source code which loads the tags from these files is viewable here:
Data Types
CEGs use the following data types:
- int
- An integer number. eg. 5
- float
- A number with decimals. eg 1.023
- bool
- A value which can be true or false. eg true
- string
- Text, or more precisely a string of alphanumeric characters. eg "string of characters"
- rgb
- Three float components, representing red, green and blue components, ranged from 0.0 to 1.0. eg {0.0, 0.0, 0.0}
- float3
- Three float components, eg {0.0, 0.0, 0.0}
- float4
- Four float components, eg {0.0, 0.0, 0.0, 0.0}
You can use CEG:Operators to define floats that are not fixed.
CEG Textures
- Textures on CEG definitions are referenced by name.
- The list of available textures and their names should be in resources.lua
- Texture definitions to be used in projectile classes should be placed within the
projectiletextures
category and textures to be used with #CSimpleGroundFlash class should be placed within thegroundfx
category. - Texture images are usually placed in the "bitmaps" subfolder.
Overall Format
A CEG file contains one or more CEGs. Each CEG follows this format:
return { ["ceg_name"] = { -- EXPLOSION LEVEL useDefaultExplosions = false, spawner1_name = { -- SPAWNER LEVEL class = "CClassName", count = 1, air = true, ground = true, water = true, properties = { -- CLASS LEVEL }, }, }, spawner2_name = { -- SPAWNER LEVEL -- each spawner follows the above format }, groundflash = { -- groundflash is a special spawner name; it always generates a CStandardGroundFlash -- CStandardGroundFlash properties }, -- other special spawner names exist, although their use is discouraged in favour of class="CSomeClass" -- see https://github.com/spring/spring/blob/develop/cont/base/springcontent/gamedata/explosion_alias.lua#L61 }, }
Explosion Level Tags
bool useDefaultExplosions default: false
- If this is set, the CEG will use the default explosion (based on damage and area of effect) in addition to any spawners you define. The default explosions are sometimes very performance heavy, especially for large damage values (leading to higher particle counts).
Spawner Level Tags
A CEG can contain any number of spawners. The name of the spawners don't really matter, as long as it's not groundflash
, which has a special meaning. You can think of each spawner as being one component of the overall explosion.
string class default: spawner_name
- Each spawner has a class that determines what kind of graphical effect it creates. Spring has a number of standard classes that you can choose from. Currently available classes are:
- CExpGenSpawner
- CBitmapMuzzleFlame
- CExploSpikeProjectile
- CHeatCloudProjectile
- CSimpleParticleSystem
- CSpherePartSpawner
- CSimpleGroundFlash
- CStandardGroundFlash
int count default: 1
- The count determines the number of times the spawner will run.
Visibility Conditions
These determine under what conditions the spawner will run. If you set the condition to true, the spawner will run if the explosion takes place under that condition. If you set more than one condition, the spawner will run if any of them are true. If you want a spawner to run only if two or more conditions are all true, you have to do a little trick with the #CExpGenSpawner class as explained in "suggested use".
bool air default: false
- The CEG will run if at least 20 elmos above ground/sea level.
bool water default: false
- The CEG will run if in water to a depth of -5 elmos.
bool underwater default: false
- The CEG will run if under water deeper than 5 elmos.
bool ground default: false
- The CEG will run if less than 20 elmos above ground.
bool unit default: false
- The CEG will run if the weapon hits a unit.
bool nounit default: false
- The CEG will run if the weapon does not hit a unit.
Class Level Tags
Common Properties
All classes have the following properties, although not all of them use them:
bool alwaysVisible default: false
- If true, the spawner is always visible, ignoring LoS. Note that prior to 98.0 this did not work correctly.
bool useAirLos default: false
- Whether the spawner uses air LoS to determine if it is visible. This may allow the spawner to be seen from a further distance than normal.
float[3] pos default: {0.0, 0.0, 0.0}
- The initial position vector of the spawner.
float[3] speed default: {0.0, 0.0, 0.0}
- The initial speed vector of the spawner.
float[3] dir default: ?
- The initial direction vector of the spawner.
CExpGenSpawner
This is the closest thing CEG has to a function call. Instead of creating a graphical effect on its own, it creates another CEG.
Suggested Use
- If you use a spawner a lot of times, you may want to make it a separate CEG to avoid having to copy-paste many times.
- This is the only way to truly delay a graphical effect.
- The spawned CEG still checks conditions, so if you want to, say, spawn an effect only if it is in water and doesn't hit a unit, you can give the CExpGenSpawner
nounit = 1;
and the spawnedCEG water = 1;
. - This allows you to give a set of spawners the same (and possibly random) direction.
- You can animate an explosion flip-book style using delays and several bitmaps.
Properties
int delay default: 1
- How long to wait (in frames?) before spawning the CEG.
float damage default: 0.0
- The CEG will be called with this damage. The CEG doesn't actually deal any damage, but you can use this as a parameter and read it using the 'd' operator.
string explosionGenerator default: ""
- The name of the CEG you want to spawn.
CBitmapMuzzleFlame
This creates three rectangular textures at right angles to each other. The frontTexture has dir as its normal.
Suggested Use
- Muzzle flames, obviously.
- You can use an upward-pointing CBitmapMuzzleFlame as a simple splash of water or dirt.
- Railgun trails.
- This is the only class that both obeys perspective and allows for a custom texture.
Properties
string sideTexture default: ""
- Texture as viewed from the side.
string frontTexture default: ""
- Texture as viewed from the front.
string colorMap default: ""
- See CColorMap.
float size default: 0.0
- The initial width of the muzzle flame.
float length default: 0.0
- The initial length of the muzzle flame.
float sizeGrowth default: 0.0
- By the end of its life, the muzzle flame grows to
1 + sizeGrowth
times its initial size and length. The flame grows quickly at first and more slowly toward the end.
int ttl default: 0
- How long the muzzle flame lasts.
float frontOffset default: 0.0
- Where the frontTexture is along the length of the muzzle flame.
0
means it is in the back,1
is in the front.
CExploSpikeProjectile
This creates a glowy spike. Note that the spike is two sided, i.e., symmetric about the position of the spawner.
Suggested Use
- Anything glowy.
- For large, slow missiles, you can try using this as an extended engine flame. Set the width to something fairly large.
- Long and thin spikes will look spiky; meanwhile, shorter and wider spikes look more blobby.
- The colors of spikes add together, so if you have several spikes and all three color channels are non-zero, it will be white in the center.
- The length growth of the spike depends on the norm of the dir vector. The spike does not grow in width.
Properties
float length default: 0.0
- The initial length of (half) of the spike (multiplied by dir).
float lengthGrowth default: dir.Length() * (0.5 + RandFloat() * 0.4)
- How much the length increases by per update.
float width default: 0.0
- Half the initial width of of the spike. This is an absolute value.
float alpha default: 0.0
- The starting alpha of the spike.
float alphaDecay default: 0.0
- How quickly the alpha of the spike decreases.
rgb color default: {1.0, 0.8, 0.5}
- The color of the spike.
CHeatCloudProjectile
Creates an expanding sprite. Simple but effective.
Suggested Use
- As the main background to an explosion.
Properties
float heat default: 0.0
- Used in alpha calculations. See heatFalloff.
float maxheat default: 0.0
- Used in alpha calculations. See heatFalloff.
float heatFalloff default: 0.0
- This is really confusing way of representing alpha and alphaDecay. Basically
alpha =
heat/
maxheat, andalphaDecay =
heatFalloff/
maxHeat.
float size default: 0.0
- The initial radius of the heatcloud.
float sizeGrowth default: 0.0
- The heatcloud grows by this amount every frame.
float sizeMod default: 0.0
- The size of the heatcloud is multiplied by
1 - sizeMod
.
float sizeModMod default: 0.0
- Each frame, sizeMod is multiplied by sizeModMod.
string texture default: "heatcloud" as referenced in resources.lua
- The texture used for the heatcloud.
CSimpleParticleSystem
Creates a sprite that can undergo complex motion. Probably the most versatile class.
Suggested Use
- Anything moving that is not doing so at constant velocity.
- If you want something that expands (or shrinks) to some size then stops, set sizeMod to something less than
1
, and sizeGrowth to something positive. The particle will grow to a size equal tosizeGrowth / (1 - sizeMod)
and stop. The smaller sizeMod is, the faster it will reach this size.
Properties
Initial Velocity Properties
float[3] emitVector default: {0.0, 0.0, 0.0}
- The initial direction vector in which the particle is emitted. When spawning CEGs via EmitSfx you can make the particles go into the direction of the emiting piece with emitvector = dir. This is useful for e.g. fire coming out of a gun barrel.
float emitRot default: 0.0
- At what angle to emit the particle relative to emitVector.
0
means that the particle will be emitted in emitVector's direction;180
will emit the particle in the opposite direction.90
will emit the particle in a random direction perpendicular to emitVector, which is good for creating rings.
float emitRotSpread default: 0.0
- For each particle, a random number between
0
and emitRotSpread is added to the emitRot.
float[3] emitMul default: {1.0, 1.0, 1.0}
- Scales the initial particle velocity; for this property, +y is considered to be in the direction of emitVector. Good if you want to create an egg-shaped explosion.
float particleSpeed default: 0.0
- The particle's initial speed.
float particleSpeedSpread default: 0.0
- For each particle, a random number between
0
and particleSpeedSpread is added to the particleSpeed.
Movement Properties
float[3] gravity default: {0.0, 0.0, 0.0}
- This will be added to the particle's velocity every frame.
float airdrag default: 0.0
- The particle's velocity is multiplied by this every frame.
Size Properties
float particleSize default: 0.0
- The initial size of the particle.
float particleSizeSpread default: 0.0
- For each particle, a random number between
0
and particleSizeSpread is added to the particleSize.
float sizeGrowth default: 0.0
- How much the particle grows each frame.
float sizeMod default: 0.0
- The size of the particle is multiplied by this each frame.
Visual Properties
bool directional default: false
- If true, the particle will point in the direction it is moving.
string texture default: ""
- The texture to use for the particle.
string colorMap default: ""
- See CColorMap.
Life Properties
int numParticles default: 0
- How many particles to create. This is not the same as
count
; if you spawn multiple particles usingcount
, any CEG:Operators will be re-evaluated for each particle, whereas if you use numParticles they will not be. However, the spread properties are evaluated separately for each particle regardless of which one you use.
float particleLife default: 0.0
- How long each particle lasts.
float particleLifeSpread default: 0.0
- For each particle, a random number between
0
and particleLifeSpread is added to the particleLife.
CSpherePartSpawner
Draws an expanding sphere.
Suggested Use
- Looks like a shockwave.
Properties
float alpha default: 0.0
- The alpha of the sphere.
int ttl default: 0
- Time to live, in frames(?).
float expansionSpeed default: 0.0
- How quickly the sphere expands.
rgb color default: {0.0, 0.0, 0.0}
- The color of the sphere.
CSimpleGroundFlash
Draws an expanding ground texture.
Suggested Use
- A short groundflash (~8 frames) is good for any explosion that gives off light. You can also use a longer groundflash to suggest the ground is glowing from heat.
Properties
float size default: 0.0
- The radius of the particle.
float sizeGrowth default: 0.0
- How much the particle grows each frame.
int ttl default: 0
- Time to live, in frames(?).
string texture default: ""
- The texture to use for the particle.
string colorMap default: ""
- See CColorMap.
CStandardGroundFlash
If you name a spawner "groundflash," it will always generate a standard groundflash.
Suggested Use
A short groundflash (~8 frames) is good for any explosion that gives off light. You can also use a longer groundflash to suggest the ground is glowing from heat.
Properties
float flashSize default: 0.0
- The radius of the groundflash.
float flashAlpha default: 0.0 range: [0, 1]
- How transparent the groundflash is. Generally the higher the brighter.
float circleGrowth default: 0.0
- A groundflash can have an additional circle that expands outwards. This controls how fast the circle grows.
float circleAlpha default: 0.0 range: [0, 1]
- How transparent the circle is.
int ttl default: 0
- How long the groundflash lasts.
rgb color default: {1.0, 1.0, 0.8}
- The color of the groundflash.
CSmokeProjectile2
( FIXME: newly added to wiki. someone cross-check then remove this note )
Particles that begin with a hard-coded yellow-red colorfade and then fade to monochrom. (shades of grey)
Movement is influenced by the random wind.
Finer details of visual and position update are best explained by looking at the formulas in CSmokeProjectile2::Update() & CSmokeProjectile2::Draw()
Suggested Use
Smoke. Smokestacks, rocket exhaust, burning wreckage,...
For a nicer stream of smoke spawn it frequently over multiple frames, otherwise it looks rather bland.
Properties
float color default: 0.5
- How dark the final monochrom color of a particle is. 0 is black.
(Use >1 for slightly bugged funnies, like slightly non-monochrome colors or interessting black/white changes.)
float size default: 0.0
- Size of a particle.
float ageSpeed default: 0.5
- How fast the particle ages. Every frame:
age += ageSpeed
The particle is deleted atif (age > 1)
float glowFalloff default: 0.0
- How fast the particle fades to monochrom.
float3 wantedPos default: "0,0,0"
- In which direction the smoke tends to drift. Less effective in y-coordinate and influenced by random wind.
float3 speed default: "0,0,0"
wantedPos += speed;
How fast and in which vector the particles move.
hardcoded texture default: randomly chosen.
- Particles randomly pick one of the smoke textures (bitmaps\smoke) and remain with it until death.
CSmokeProjectile
Monochrome particles that fade out. A more "primitive" version of CSmokeProjectile2. No hardcoded red-yellow start but it misses wantedPos to tweak the look a bit more detailed.
Suggested Use
Smoke. For a nicer stream of smoke spawn it frequently over multiple frames, otherwise it looks rather bland.
Properties
float color default: 0.5
- Brightness of the particle. 0 is black.
float size default: 0.0
- Size of a particle
float ageSpeed default: 0.5
- How fast the particle ages. Every frame:
age += ageSpeed
The particle is deleted atif (age > 1)
float3 speed default: "0,0,0"
pos += speed;
How fast and in which vector the particles move.
hardcoded texture default: randomly chosen.
- Particles randomly pick one of the smoke textures (bitmaps\smoke) and remain with it until death.
Examples
'Balanced Annihilation' CEGs (TDF format)
'Imperial Winter' CEGs (TDF format)
'MechCommander: Legacy' CEGs (TDF format)
'Spring: 1944' CEGs (TDF format)
'XTA' CEGs (TDF format)