CEG:Defs: Difference between revisions

From Spring
Jump to navigationJump to search
Flozi (talk | contribs)
m →groundflash: complete defaults
 
(17 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= CEG Classes =
= CEG Definitions =


==Source==  
==Source==  
Line 6: Line 6:
* {{sourcelink|file=rts/Sim/Projectiles/}}  
* {{sourcelink|file=rts/Sim/Projectiles/}}  
* {{sourcelink|file=rts/Sim/Projectiles/Unsynced/}}
* {{sourcelink|file=rts/Sim/Projectiles/Unsynced/}}
* {{sourcelink|file=rts/Rendering/GroundFlash.cpp}}
== Data Types ==
CEGs use the following data types:
{{DataTypes}}
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 <code>projectiletextures</code> category and textures to be used with [[#CSimpleGroundFlash]] class should be placed within the <code>groundfx</code> category.
* Texture images are usually placed in the "bitmaps" subfolder.


== Overall Format ==
== Overall Format ==
Line 11: Line 25:
A CEG file contains one or more CEGs. Each CEG follows this format:
A CEG file contains one or more CEGs. Each CEG follows this format:


<code><pre>
<pre>
["ceg_name"] = {
return {
  useDefaultExplosions = false,
  ["ceg_name"] = {
  spawner1_name = {
    -- EXPLOSION LEVEL
    class        = "CClassName",
    useDefaultExplosions = false,
    count              = 1,
 
    air                = true,
    spawner1_name = {
    ground            = true,
      -- SPAWNER LEVEL
    water              = true,
      class        = "CClassName",
    properties = {
      count              = 1,
      -- ... See tags below
      air                = true,
      ground            = true,
      water              = true,
      properties = {
        -- CLASS LEVEL
        },
       },
       },
     },
     },
  },
    spawner2_name = {
  spawner2_name = {
      -- SPAWNER LEVEL
    -- each spawner follows the above format
      -- each spawner follows the above format
  },
    },
  groundflash = {
    groundflash = {
    -- groundflash is a special name; it always generates a groundflash
      -- groundflash is a special spawner name; it always generates a CStandardGroundFlash
     -- groundflash properties
      -- 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
   },
   },
}
}
</pre></code>
</pre>


== Explosion Level Tags ==
{{tag
{{tag
|name = useDefaultExplosions
|name = useDefaultExplosions
Line 42: Line 65:
}}
}}


=== Spawners ===
== 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 <code>groundflash</code>, which has a special meaning. You can think of each spawner as being one component of the overall explosion.
A CEG can contain any number of spawners. The name of the spawners don't really matter, as long as it's not <code>groundflash</code>, which has a special meaning. You can think of each spawner as being one component of the overall explosion.


Line 48: Line 71:
|name = class
|name = class
|type = string
|type = string
|default = ???
|default = spawner_name
|description = 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. See [[CEG-Classes]] for details.
|description = 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|CExpGenSpawner]]
* [[#CBitmapMuzzleFlame|CBitmapMuzzleFlame]]
* [[#CExploSpikeProjectile|CExploSpikeProjectile]]
* [[#CHeatCloudProjectile|CHeatCloudProjectile]]
* [[#CSimpleParticleSystem|CSimpleParticleSystem]]
* [[#CSpherePartSpawner|CSpherePartSpawner]]
* [[#CSimpleGroundFlash|CSimpleGroundFlash]]
* [[#CStandardGroundFlash|CStandardGroundFlash]]
}}
}}


Line 59: Line 90:
}}
}}


==== Conditions ====
=== 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 {{FIXME}}What is the trick?.
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".


{{tag
{{tag
Line 104: Line 135:
}}
}}


==== Properties ====
== Class Level Tags ==
Depending on what class a spawner is, it will have a set of properties that allow you to fine-tune what the spawner displays. Again, see [[CEG-Classes]] for details.
=== Common Properties ===
 
=== groundflash ===
If you name a spawner "groundflash," it will always generate a 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. A groundflash has the following properties:
 
{{tag
|name = flashSize
|type = float
|default = 0.0
|description = The radius of the groundflash.
}}
 
{{tag
|name = flashAlpha
|type = float
|range = [0, 1]
|default = 0.0
|description = How transparent the groundflash is. Generally the higher the brighter.
}}
 
{{tag
|name = circleGrowth
|type = float
|default = 0.0
|description = A groundflash can have an additional circle that expands outwards. This controls how fast the circle grows.
}}
 
{{tag
|name = circleAlpha
|type = float
|range = [0, 1]
|default = 0.0
|description = How transparent the circle is.
}}
 
{{tag
|name = ttl
|type = int
|default = 0
|description = How long the groundflash lasts.
}}
 
{{tag
|name = color
|type = rgb
|default = {1.0, 1.0, 0.8}
|description = The color of the groundflash.
}}
 
=== Data Types ===
CEGs use the following data types:
{{DataTypes}}
 
You can use [[CEG-Operators]] to define floats that are not fixed.
 
=== Units ===
 
All distances are in elmos; all time is in frames.
 
== 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 the "groundfx" category.
* Texture images are usually placed in the "bitmaps" subfolder.
 
 
== Common Properties ==
All classes have the following properties, although not all of them use them:
All classes have the following properties, although not all of them use them:


Line 179: Line 143:
|type = bool
|type = bool
|default = false
|default = false
|description = If true, the spawner is always visible, ignoring LoS.
|description = If true, the spawner is always visible, ignoring LoS. Note that prior to 98.0 this did not work correctly.
}}
}}


Line 193: Line 157:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|default = {0.0, 0.0, 0.0}
|description = The initial position of the spawner.
|description = The initial position vector of the spawner.
}}
}}


Line 200: Line 164:
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|default = {0.0, 0.0, 0.0}
|description = The initial speed of the spawner.
|description = The initial speed vector of the spawner.
}}
}}


{{tag
|name = dir
|type = float[3]
|description = The initial direction vector of the spawner.
}}


== CExpGenSpawner ==
=== 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.
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 ===
==== 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.
* 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.
* This is the only way to truly delay a graphical effect.
Line 214: Line 183:
* You can animate an explosion flip-book style using delays and several bitmaps.
* You can animate an explosion flip-book style using delays and several bitmaps.


=== Properties ===
==== Properties ====


{{tag
{{tag
|name = delay
|name = delay
|type = int
|type = int
|default = 1
|description = How long to wait (in frames?) before spawning the CEG.
|description = How long to wait (in frames?) before spawning the CEG.
}}
{{tag
|name = dir
|type = float[3]
|description = The CEG will be called with this direction vector.
}}
}}


Line 231: Line 195:
|name = damage
|name = damage
|type = float
|type = float
|description = 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.
|default = 0.0
|description = 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 [[CEG:Operators#Damage_.28.27d.27.29|'d' operator]].
}}
}}


Line 237: Line 202:
|name = explosionGenerator
|name = explosionGenerator
|type = string
|type = string
|default = ""
|description = The name of the CEG you want to spawn.
|description = The name of the CEG you want to spawn.
}}
}}




== CBitmapMuzzleFlame ==
=== CBitmapMuzzleFlame ===
This creates three rectangular textures at right angles to each other. The {{taglink|frontTexture}} has {{taglink|dir}} as its normal.
This creates three rectangular textures at right angles to each other. The {{taglink|frontTexture}} has {{taglink|dir}} as its normal.


=== Suggested Use ===
==== Suggested Use ====
*Muzzle flames, obviously.
*Muzzle flames, obviously.
*You can use an upward-pointing CBitmapMuzzleFlame as a simple splash of water or dirt.
*You can use an upward-pointing CBitmapMuzzleFlame as a simple splash of water or dirt.
Line 250: Line 216:
*This is the only class that both obeys perspective and allows for a custom texture.
*This is the only class that both obeys perspective and allows for a custom texture.


=== Properties ===
==== Properties ====


{{tag
{{tag
Line 264: Line 230:
|default = ""
|default = ""
|description = Texture as viewed from the front.
|description = Texture as viewed from the front.
}}
{{tag
|name = dir
|type = float[3]
|default = {0.0, 0.0, 1.0}
|description = The direction vector of the muzzle flame.
}}
}}


Line 283: Line 242:
|name = size
|name = size
|type = float
|type = float
|default = ???
|default = 0.0
|description = The initial width of the muzzle flame.
|description = The initial width of the muzzle flame.
}}
}}
Line 290: Line 249:
|name = length
|name = length
|type = float
|type = float
|default = ???
|default = 0.0
|description = The initial length of the muzzle flame.
|description = The initial length of the muzzle flame.
}}
}}
Line 297: Line 256:
|name = sizeGrowth  
|name = sizeGrowth  
|type = float
|type = float
|default = ???
|default = 0.0
|description = By the end of its life, the muzzle flame grows to <code>1 + sizeGrowth</code> times its initial {{taglink|size}} and {{taglink|length}}. The flame grows quickly at first and more slowly toward the end.
|description = By the end of its life, the muzzle flame grows to <code>1 + sizeGrowth</code> times its initial {{taglink|size}} and {{taglink|length}}. The flame grows quickly at first and more slowly toward the end.
}}
}}
Line 304: Line 263:
|name = ttl
|name = ttl
|type = int
|type = int
|default = ???
|default = 0
|description = How long the muzzle flame lasts.
|description = How long the muzzle flame lasts.
}}
}}
Line 311: Line 270:
|name = frontOffset
|name = frontOffset
|type = float
|type = float
|default = ???
|default = 0.0
|description = Where the frontTexture is along the length of the muzzle flame. <code>0</code> means it is in the back, <code>1</code> is in the front.
|description = Where the frontTexture is along the length of the muzzle flame. <code>0</code> means it is in the back, <code>1</code> is in the front.
}}
}}




== CExploSpikeProjectile ==
=== CExploSpikeProjectile ===


This creates a glowy spike. Note that the spike is two sided, i.e., symmetric about the position of the spawner.
This creates a glowy spike. Note that the spike is two sided, i.e., symmetric about the position of the spawner.


=== Suggested Use ===
==== Suggested Use ====
* Anything glowy.
* Anything glowy.
* For large, slow missiles, you can try using this as an extended engine flame. Set the width to something fairly large.
* For large, slow missiles, you can try using this as an extended engine flame. Set the width to something fairly large.
Line 327: Line 286:
* The length growth of the spike depends on the norm of the dir vector. The spike does not grow in width.
* The length growth of the spike depends on the norm of the dir vector. The spike does not grow in width.


=== Properties ===
==== Properties ====
{{tag
{{tag
|name = length
|name = length
|type = float
|type = float
|default = 0.0
|description = The initial length of (half) of the spike (multiplied by {{taglink|dir}}).
|description = The initial length of (half) of the spike (multiplied by {{taglink|dir}}).
}}
{{tag
|name = lengthGrowth
|type = float
|default = dir.Length() * (0.5 + RandFloat() * 0.4)
|description = How much the length increases by per update.
}}
}}


Line 337: Line 304:
|name = width
|name = width
|type = float
|type = float
|default = 0.0
|description = Half the initial width of of the spike. This is an absolute value.
|description = Half the initial width of of the spike. This is an absolute value.
}}
}}
Line 343: Line 311:
|name = alpha
|name = alpha
|type = float
|type = float
|default = 0.0
|description = The starting alpha of the spike.
|description = The starting alpha of the spike.
}}
}}
Line 349: Line 318:
|name = alphaDecay
|name = alphaDecay
|type = float
|type = float
|default = 0.0
|description = How quickly the alpha of the spike decreases.
|description = How quickly the alpha of the spike decreases.
}}
{{tag
|name = dir
|type = float[3]
|description = The direction of the spike. Not normalized.
}}
}}


{{tag
{{tag
|name = color
|name = color
|type = float[3]
|type = rgb
|default = {1.0, 0.8, 0.5}
|description = The color of the spike.
|description = The color of the spike.
}}
}}




== CHeatCloudProjectile ==
=== CHeatCloudProjectile ===


Creates an expanding sprite. Simple but effective.
Creates an expanding sprite. Simple but effective.


=== Suggested Use ===
==== Suggested Use ====
* As the main background to an explosion.
* As the main background to an explosion.


=== Properties ===  
==== Properties ====
{{tag
{{tag
|name = heat
|name = heat
|type = float
|type = float
|default = 0.0
|description = Used in alpha calculations. See {{taglink|heatFalloff}}.
}}
}}


Line 381: Line 348:
|name = maxheat
|name = maxheat
|type = float
|type = float
|default = 0.0
|description = Used in alpha calculations. See {{taglink|heatFalloff}}.
}}
}}


Line 386: Line 355:
|name = heatFalloff
|name = heatFalloff
|type = float
|type = float
|description = This is really confusing way of representing alpha and alphaDecay. Basically <code>alpha = heat/maxheat</code>, and <code>alphaDecay = heatFalloff/maxHeat</code>.
|default = 0.0
|description = This is really confusing way of representing alpha and alphaDecay. Basically <code>alpha = </code>{{taglink|heat}}<code>/</code>{{taglink|maxheat}}, and <code>alphaDecay = </code>{{taglink|heatFalloff}}<code>/</code>{{taglink|maxHeat}}.
}}
}}


Line 392: Line 362:
|name = size
|name = size
|type = float
|type = float
|default = 0.0
|description = The initial radius of the heatcloud.
|description = The initial radius of the heatcloud.
}}
}}
Line 398: Line 369:
|name = sizeGrowth
|name = sizeGrowth
|type = float
|type = float
|default = 0.0
|description = The heatcloud grows by this amount every frame.
|description = The heatcloud grows by this amount every frame.
}}
}}
Line 404: Line 376:
|name = sizeMod
|name = sizeMod
|type = float
|type = float
|default = 0.0
|description = The size of the heatcloud is multiplied by <code>1 - sizeMod</code>.
|description = The size of the heatcloud is multiplied by <code>1 - sizeMod</code>.
}}
}}
Line 410: Line 383:
|name = sizeModMod
|name = sizeModMod
|type = float
|type = float
|default = 0.0
|description = Each frame, {{taglink|sizeMod}} is multiplied by {{taglink|sizeModMod}}.
|description = Each frame, {{taglink|sizeMod}} is multiplied by {{taglink|sizeModMod}}.
}}
}}
Line 416: Line 390:
|name = texture
|name = texture
|type = string
|type = string
|default = "heatcloud" as referenced in [[resources.lua]]
|description = The texture used for the heatcloud.
|description = The texture used for the heatcloud.
}}
}}


 
=== CSimpleParticleSystem ===
== CSimpleParticleSystem ==


Creates a sprite that can undergo complex motion. Probably the most versatile class.
Creates a sprite that can undergo complex motion. Probably the most versatile class.


=== Suggested Use ===
==== Suggested Use ====
* Anything moving that is not doing so at constant velocity.
* Anything moving that is not doing so at constant velocity.
* If you want something that expands (or shrinks) to some size then stops, set {{taglink|sizeMod}} to something less than <code>1</code>, and {{taglink|sizeGrowth}} to something positive. The particle will grow to a size equal to <code>sizeGrowth / (1 - sizeMod)</code> and stop. The smaller {{taglink|sizeMod}} is, the faster it will reach this size.
* If you want something that expands (or shrinks) to some size then stops, set {{taglink|sizeMod}} to something less than <code>1</code>, and {{taglink|sizeGrowth}} to something positive. The particle will grow to a size equal to <code>sizeGrowth / (1 - sizeMod)</code> and stop. The smaller {{taglink|sizeMod}} is, the faster it will reach this size.


=== Properties ===
==== Properties ====
==== Initial Velocity Properties ====
===== Initial Velocity Properties =====
{{tag
{{tag
|name = emitVector
|name = emitVector
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|description = 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 {{taglink|emitvector|dir}}. This is useful for e.g. fire coming out of a gun barrel.
|description = 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 {{taglink|emitvector|dir}}. This is useful for e.g. fire coming out of a gun barrel.
}}
}}
Line 439: Line 414:
|name = emitRot
|name = emitRot
|type = float
|type = float
|default = 0.0
|description = At what angle to emit the particle relative to {{taglink|emitVector}}. <code>0</code> means that the particle will be emitted in {{taglink|emitVector}}'s direction; <code>180</code> will emit the particle in the opposite direction. <code>90</code> will emit the particle in a random direction perpendicular to {{taglink|emitVector}}, which is good for creating rings.
|description = At what angle to emit the particle relative to {{taglink|emitVector}}. <code>0</code> means that the particle will be emitted in {{taglink|emitVector}}'s direction; <code>180</code> will emit the particle in the opposite direction. <code>90</code> will emit the particle in a random direction perpendicular to {{taglink|emitVector}}, which is good for creating rings.
}}
}}
Line 445: Line 421:
|name = emitRotSpread
|name = emitRotSpread
|type = float
|type = float
|default = 0.0
|description = For each particle, a random number between <code>0</code> and {{taglink|emitRotSpread}} is added to the {{taglink|emitRot}}.
|description = For each particle, a random number between <code>0</code> and {{taglink|emitRotSpread}} is added to the {{taglink|emitRot}}.
}}
}}
Line 451: Line 428:
|name = emitMul
|name = emitMul
|type = float[3]
|type = float[3]
|default = {1.0, 1.0, 1.0}
|description = Scales the initial particle velocity; for this property, +y is considered to be in the direction of {{taglink|emitVector}}. Good if you want to create an egg-shaped explosion.
|description = Scales the initial particle velocity; for this property, +y is considered to be in the direction of {{taglink|emitVector}}. Good if you want to create an egg-shaped explosion.
}}
}}
Line 457: Line 435:
|name = particleSpeed  
|name = particleSpeed  
|type = float
|type = float
|default = 0.0
|description = The particle's initial speed.
|description = The particle's initial speed.
}}
}}
Line 463: Line 442:
|name = particleSpeedSpread
|name = particleSpeedSpread
|type = float
|type = float
|default = 0.0
|description = For each particle, a random number between <code>0</code> and {{taglink|particleSpeedSpread}} is added to the {{taglink|particleSpeed}}.
|description = For each particle, a random number between <code>0</code> and {{taglink|particleSpeedSpread}} is added to the {{taglink|particleSpeed}}.
}}
}}


==== Movement Properties ====
===== Movement Properties =====


{{tag
{{tag
|name = gravity
|name = gravity
|type = float[3]
|type = float[3]
|default = {0.0, 0.0, 0.0}
|description = This will be added to the particle's velocity every frame.
|description = This will be added to the particle's velocity every frame.
}}
}}
Line 477: Line 458:
|name = airdrag
|name = airdrag
|type = float
|type = float
|default = 0.0
|description = The particle's velocity is multiplied by this every frame.
|description = The particle's velocity is multiplied by this every frame.
}}
}}


==== Size Properties ====
===== Size Properties =====


{{tag
{{tag
|name = particleSize  
|name = particleSize  
|type = float
|type = float
|default = 0.0
|description = The initial size of the particle.
|description = The initial size of the particle.
}}
}}
Line 491: Line 474:
|name = particleSizeSpread
|name = particleSizeSpread
|type = float
|type = float
|default = 0.0
|description = For each particle, a random number between <code>0</code> and {{taglink|particleSizeSpread}} is added to the {{taglink|particleSize}}.
|description = For each particle, a random number between <code>0</code> and {{taglink|particleSizeSpread}} is added to the {{taglink|particleSize}}.
}}
}}
Line 497: Line 481:
|name = sizeGrowth
|name = sizeGrowth
|type = float
|type = float
|default = 0.0
|description = How much the particle grows each frame.
|description = How much the particle grows each frame.
}}
}}
Line 503: Line 488:
|name = sizeMod
|name = sizeMod
|type = float
|type = float
|default = 0.0
|description = The size of the particle is multiplied by this each frame.
|description = The size of the particle is multiplied by this each frame.
}}
}}


==== Visual Properties ====
===== Visual Properties =====


{{tag
{{tag
|name = directional
|name = directional
|type = bool
|type = bool
|default = false
|description = If true, the particle will point in the direction it is moving.
|description = If true, the particle will point in the direction it is moving.
}}
}}
Line 517: Line 504:
|name = texture
|name = texture
|type = string
|type = string
|default = ""
|description = The texture to use for the particle.
|description = The texture to use for the particle.
}}
}}
Line 523: Line 511:
|name = colorMap
|name = colorMap
|type = string
|type = string
|default = ""
|description = See [[CColorMap]].
|description = See [[CColorMap]].
}}
}}


==== Life Properties ====
===== Life Properties =====


{{tag
{{tag
|name = numParticles
|name = numParticles
|type = int
|type = int
|description = How many particles to create. This is not the same as <code>count</code>; if you spawn multiple particles using <code>count</code>, any [[CEG-Operators]] will be re-evaluated for each particle, whereas if you use {{taglink|numParticles}} they will not be. However, the spread properties are evaluated separately for each particle regardless of which one you use.
|default = 0
|description = How many particles to create. This is not the same as <code>count</code>; if you spawn multiple particles using <code>count</code>, any [[CEG:Operators]] will be re-evaluated for each particle, whereas if you use {{taglink|numParticles}} they will not be. However, the spread properties are evaluated separately for each particle regardless of which one you use.
}}
}}


Line 537: Line 527:
|name = particleLife
|name = particleLife
|type = float
|type = float
|default = 0.0
|description = How long each particle lasts.  
|description = How long each particle lasts.  
}}
}}
Line 543: Line 534:
|name = particleLifeSpread
|name = particleLifeSpread
|type = float
|type = float
|default = 0.0
|description = For each particle, a random number between <code>0</code> and {{taglink|particleLifeSpread}} is added to the {{taglink|particleLife}}.
|description = For each particle, a random number between <code>0</code> and {{taglink|particleLifeSpread}} is added to the {{taglink|particleLife}}.
}}
}}


== CSpherePartSpawner ==
=== CSpherePartSpawner ===


Draws an expanding sphere.
Draws an expanding sphere.


=== Suggested Use ===
==== Suggested Use ====
*Looks like a shockwave.
*Looks like a shockwave.


=== Properties ===
==== Properties ====


{{tag
{{tag
|name = alpha
|name = alpha
|type = float
|type = float
|default = 0.0
|description = The alpha of the sphere.
|description = The alpha of the sphere.
}}
}}
Line 564: Line 557:
|name = ttl
|name = ttl
|type = int
|type = int
|default = 0
|description = Time to live, in frames(?).
|description = Time to live, in frames(?).
}}
}}
Line 570: Line 564:
|name = expansionSpeed
|name = expansionSpeed
|type = float
|type = float
|default = 0.0
|description = How quickly the sphere expands.
|description = How quickly the sphere expands.
}}
}}
Line 575: Line 570:
{{tag
{{tag
|name = color
|name = color
|type = float[3]
|type = rgb
|default = {0.0, 0.0, 0.0}
|description = The color of the sphere.
|description = The color of the sphere.
}}
}}




== CSimpleGroundFlash ==
=== CSimpleGroundFlash ===


Draws an expanding ground texture.
Draws an expanding ground texture.


=== Suggested Use ===
==== 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.
* 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 ===
==== Properties ====


{{tag
{{tag
|name = size
|name = size
|type = float
|type = float
|default = 0.0
|description = The radius of the particle.
|description = The radius of the particle.
}}
}}
Line 598: Line 595:
|name = sizeGrowth
|name = sizeGrowth
|type = float
|type = float
|default = 0.0
|description = How much the particle grows each frame.
|description = How much the particle grows each frame.
}}
}}
Line 604: Line 602:
|name = ttl
|name = ttl
|type = int
|type = int
|default = 0
|description = Time to live, in frames(?).
|description = Time to live, in frames(?).
}}
}}
Line 610: Line 609:
|name = texture
|name = texture
|type = string
|type = string
|default = ""
|description = The texture to use for the particle.
|description = The texture to use for the particle.
}}
}}
Line 616: Line 616:
|name = colorMap
|name = colorMap
|type = string
|type = string
|default = ""
|description = See [[CColorMap]].
|description = See [[CColorMap]].
}}
}}


<!-- [[Category:CEG]] -->
=== 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 ====
 
{{tag
|name = flashSize
|type = float
|default = 0.0
|description = The radius of the groundflash.
}}
 
{{tag
|name = flashAlpha
|type = float
|range = [0, 1]
|default = 0.0
|description = How transparent the groundflash is. Generally the higher the brighter.
}}
 
{{tag
|name = circleGrowth
|type = float
|default = 0.0
|description = A groundflash can have an additional circle that expands outwards. This controls how fast the circle grows.
}}
 
{{tag
|name = circleAlpha
|type = float
|range = [0, 1]
|default = 0.0
|description = How transparent the circle is.
}}
 
{{tag
|name = ttl
|type = int
|default = 0
|description = How long the groundflash lasts.
}}
 
{{tag
|name = color
|type = rgb
|default = {1.0, 1.0, 0.8}
|description = 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 <code>CSmokeProjectile2::Update() & CSmokeProjectile2::Draw()</code>
 
==== 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 ====
{{tag
|name = color
|type = float
|default = 0.5
|description = 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.)
}}
 
{{tag
|name = size
|type = float
|default = 0.0
|description = Size of a particle.
}}
 
{{tag
|name = ageSpeed
|type = float
|default = 0.5
|description = How fast the particle ages. Every frame: <code>age += ageSpeed</code> The particle is deleted at <code>if (age > 1)</code>
}}
 
{{tag
|name = glowFalloff
|type = float
|default = 0.0
|description = How fast the particle fades to monochrom.
}}
 
{{tag
|name = wantedPos
|type = float3
|default = "0,0,0"
|description = In which direction the smoke tends to drift. Less effective in y-coordinate and influenced by random wind.
}}
 
{{tag
|name = speed
|type = float3
|default = "0,0,0"
|description = <code>wantedPos += speed;</code> How fast and in which vector the particles move.
}}
 
{{tag
|name = texture
|type = hardcoded
|default = randomly chosen.
|description = 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 ====
{{tag
|name = color
|type = float
|default = 0.5
|description = Brightness of the particle. 0 is black.
}}
 
{{tag
|name = size
|type = float
|default = 0.0
|description = Size of a particle
}}
 
{{tag
|name = ageSpeed
|type = float
|default = 0.5
|description = How fast the particle ages. Every frame: <code>age += ageSpeed</code> The particle is deleted at <code>if (age > 1)</code>
}}
 
{{tag
|name = speed
|type = float3
|default = "0,0,0"
|description = <code>pos += speed;</code> How fast and in which vector the particles move.
}}
 
{{tag
|name = texture
|type = hardcoded
|default = randomly chosen.
|description = Particles randomly pick one of the smoke textures (bitmaps\smoke) and remain with it until death.
}}
 
 
 
==Examples==
 
<!-- can't use the following until all games use effects/ rather than gamedata/explosions
{{ExampleRepoLinks
|path = effects/
|entity = CEGs
}}
-->
[http://imolarpg.dyndns.org/trac/balatest/browser/trunk/gamedata/explosions 'Balanced Annihilation' CEGs] (TDF format)
 
[http://code.google.com/p/conflictterra/source/browse/#svn%2Fgames%2FCT%2Fgamedata%2Fexplosions 'Conflict Terra' CEGs]
 
[https://github.com/EvolutionRTS/Evolution-RTS/tree/master/Gamedata/explosions 'Evolution RTS' CEGs]
 
[https://github.com/imperialwinter/swiw.sdd/tree/master/gamedata/explosions 'Imperial Winter' CEGs] (TDF format)
 
[http://code.google.com/p/journeywar/source/browse/#svn%2Ftrunk%2Fgamedata%2Fexplosions 'Journeywar' CEGs]
 
[http://sourceforge.net/p/mwspring/code/HEAD/tree/effects/ 'MechCommander: Legacy' CEGs] (TDF format)
 
[https://github.com/spring1944/spring1944/tree/master/effects 'Spring: 1944' CEGs] (TDF format)
 
[http://code.google.com/p/springtutorialgame/source/browse/#svn%2Ftrunk%2FSpringTutorialGame.sdd%2FGamedata%2Fexplosions 'Spring Tutorial Game' CEGs]
 
[http://code.google.com/p/xta-springrts/source/browse/#svn%2Ftrunk%2Fgamedata%2Fexplosions 'XTA' CEGs] (TDF format)
 
[https://github.com/ZeroK-RTS/Zero-K/tree/master/effects 'ZeroK' CEGs]
 
[[Category:CEG]]

Latest revision as of 15:35, 13 May 2020

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 the groundfx 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:

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 spawned CEG 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, and alphaDecay = 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 to sizeGrowth / (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 using count, 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 at if (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 at if (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)

'Conflict Terra' CEGs

'Evolution RTS' CEGs

'Imperial Winter' CEGs (TDF format)

'Journeywar' CEGs

'MechCommander: Legacy' CEGs (TDF format)

'Spring: 1944' CEGs (TDF format)

'Spring Tutorial Game' CEGs

'XTA' CEGs (TDF format)

'ZeroK' CEGs