CEG:Calls

From Spring
Revision as of 04:07, 10 April 2011 by Knorke (talk | contribs)
Jump to navigationJump to search

Overview

There are four places where you can call a CEG: weapons, COB unit scripts, Lua unit scripts, synced part of Lua gadgets.

Weapon CEGs

There are three weapon tags that can spawn CEGs:

  • cegtag: Spawns the CEG every frame at the weapon projectile's position and direction.
  • explosionGenerator: Spawns the CEG when the weapon hits its target.
  • bounceExplosionGenerator: For bouncing weapons only. Spawns the CEG when the weapon bounces.

You need to set these tags equal to custom:ExplosionGeneratorName. For example, in a .tdf,

explosionGenerator=custom:ExplosionGeneratorName;

Calling CEGs from unit scripts

Calling a CEG from unit scripts requires two steps. First, in the unit's definition, you need to define the order of the effects:

for a .fbi unitdef use:

[sfxtypes] {
  explosiongenerator0 = custom:ExplosionGeneratorName0;
  explosiongenerator1 = custom:ExplosionGeneratorName1;
  //and so on...
}

for a .lua unitdef use:

sfxtypes = {
  explosiongenerators = {
    "custom:ExplosionGeneratorName0",
    "custom:ExplosionGeneratorName1",
    --and so on...
  },
},

To actually generate the explosion in a COB, you need to emit-sfx 1024 plus the number of the explosion generator in the unit definition (the first one is 0, the next is 1, and so on). The CEG will have the position and direction of the piece you emit it from.

There is another tag, pieceTrailCEGTag, which is used in explode [piece] FALL; to spawn CEG trails behind falling pieces.

CEG_DAMAGE: In a COB script, you can do SET CEG_DAMAGE [value]. Any emit-sfx instructions will then use that value for the "damage" (use the 'd' operator to access this value).

In a Lua unit script you generate the explosion like this: have a look at the CallOuts of unit scripts


Lua CEGs

See Spring.SpawnCEG in Lua_SyncedCtrl.