CEG:Calls: Difference between revisions

From Spring
Jump to navigationJump to search
Abma (talk | contribs)
No edit summary
Knorke (talk | contribs)
No edit summary
Line 1: Line 1:
== Overview ==
== Overview ==
There are three places where you can call a CEG: weapons, COB, and Lua.
There are four places where you can call a CEG: weapons, COB unit scripts, Lua unit scripts, synced part of Lua gadgets.


== Weapon CEGs ==
== Weapon CEGs ==
Line 13: Line 13:
<code><pre>explosionGenerator=custom:ExplosionGeneratorName;</pre></code>
<code><pre>explosionGenerator=custom:ExplosionGeneratorName;</pre></code>


== COB CEGs ==
==Calling CEGs from unit scripts ==


Calling a CEG from COB requires two steps. First, in the unit's definition, you need to put
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:
<code><pre>
<code><pre>
[sfxtypes] {
[sfxtypes] {
Line 25: Line 26:
</pre></code>
</pre></code>


for a .fbi, or
for a .lua unitdef use:


<code><pre>
<code><pre>
Line 37: Line 38:
</pre></code>
</pre></code>


To actually generate the explosion, you need to <code>emit-sfx</code> 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.
'''To actually generate the explosion in a COB''', you need to <code>emit-sfx</code> 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, <code>[[pieceTrailCEGTag]]</code>, which is used in <code>explode [piece] FALL;</code> to spawn CEG trails behind falling pieces.
There is another tag, <code>[[pieceTrailCEGTag]]</code>, which is used in <code>explode [piece] FALL;</code> to spawn CEG trails behind falling pieces.


'''CEG_DAMAGE:''' In a COB script, you can do <code>SET CEG_DAMAGE [value]</code>. Any <code>emit-sfx</code> instructions will then use that value for the "damage" (use the 'd' operator to access this value).
'''CEG_DAMAGE:''' In a COB script, you can do <code>SET CEG_DAMAGE [value]</code>. Any <code>emit-sfx</code> 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:'''
[http://springrts.com/wiki/Animation-LuaCallouts#Effects have a look at the CallOuts of unit scripts]


== Lua CEGs ==
== Lua CEGs ==
See [[Lua_SyncedCtrl]].
See Spring.SpawnCEG in [[Lua_SyncedCtrl]].
[[Category:CEG]]
[[Category:CEG]]

Revision as of 04:07, 10 April 2011

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.