CEG For Units: Difference between revisions
Calling basic CEGs via COB |
mNo edit summary |
||
| Line 1: | Line 1: | ||
Creating Custom Explosion Generators (CEGs) and using them with Units in Spring, via COB, is quite easy. This tutorial will show you how to do so. | Creating Custom Explosion Generators (CEGs) and using them with Units in Spring, via COB, is quite easy. This tutorial will show you how to do so. | ||
Step 1: Link your CEGs to your Unit. | == Step 1: Link your CEGs to your Unit. == | ||
CEGs need to be linked to a Unit's data to be generated via COB (you can call them directly via LUA, but that's another story). | CEGs need to be linked to a Unit's data to be generated via COB (you can call them directly via LUA, but that's another story). | ||
| Line 14: | Line 15: | ||
This tells Spring that the CEG called MyNiftyExplosionGenerator is attached to this Unit, and allows COB to call it. If you have more than one, then the next one uses a 1 instead of a 0, e.g. ExplosionGenerator1=custom:MyNiftyExplosionGenerator; ... and so forth. | This tells Spring that the CEG called MyNiftyExplosionGenerator is attached to this Unit, and allows COB to call it. If you have more than one, then the next one uses a 1 instead of a 0, e.g. ExplosionGenerator1=custom:MyNiftyExplosionGenerator; ... and so forth. | ||
== Step 2: Calling the CEG via COB == | |||
The easiest way to do this is to use a #DEFINE statement, using the appropriate number for the type of Explosion you want to invoke: | The easiest way to do this is to use a #DEFINE statement, using the appropriate number for the type of Explosion you want to invoke: | ||
Revision as of 01:27, 1 December 2007
Creating Custom Explosion Generators (CEGs) and using them with Units in Spring, via COB, is quite easy. This tutorial will show you how to do so.
Step 1: Link your CEGs to your Unit.
CEGs need to be linked to a Unit's data to be generated via COB (you can call them directly via LUA, but that's another story).
To do so, create a section in your Unit's TDF like this:
[SFXTypes] { ExplosionGenerator0=custom:MyNiftyExplosionGenerator; }
This tells Spring that the CEG called MyNiftyExplosionGenerator is attached to this Unit, and allows COB to call it. If you have more than one, then the next one uses a 1 instead of a 0, e.g. ExplosionGenerator1=custom:MyNiftyExplosionGenerator; ... and so forth.
Step 2: Calling the CEG via COB
The easiest way to do this is to use a #DEFINE statement, using the appropriate number for the type of Explosion you want to invoke:
1024 + X (where X == the number you used in the TDF, i.e. 0 for the first one, etc.).
So, what I typically do is put in lines at the start of the COB, like this: #DEFINE MyNiftyExplosionGenerator 1024+0
This means that, wherever in the COB I call MyNiftyExplosionGenerator, Spring will call the appropriate CEG.
To actually call the CEG, just use the following:
emit-sfx MyNiftyExplosionGenerator from PieceName;
It's just that simple :-) Just make darn sure you've gotten everything right before you use this, or you will cause to Spring to crash!