Particle effects

Particle effects

Resources to get you going on your new project, or to help you over some emergent problems during your development cycle.

Moderator: Moderators

Post Reply
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Particle effects

Post by Erik »

Havent found much info around here about it, can someone link as simple tutorial for creating particle effects such as smoke clouds and trails?
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Particle effects

Post by Master-Athmos »

Have a look at the CEG Wiki pages and maybe download some mods/games and look up how they did things. I don't think there's much more than that available right now...
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Particle effects

Post by Erik »

Thats not really understandablem, theres absolutley no differentiation between very important things and totally unecessary stuff. Also stealing stuff from another mod just does not work when you have no clue what is supposed to do what.
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Particle effects

Post by Master-Athmos »

Well the bottom line is that there is a gamedata/explosions directory where you can put in the textfiles where you define your explosions, particle effects or what you want to do. Once again you can either dump them in like in very long file by listing just one after another or you make several files so it's more clean for you and you find things faster...

The syntax pretty much goes like this: Every effect gets a name in the first place:

Code: Select all

[ceg_name] {
bla bla bla - enter stuff describing the effect here
} 
The very first line you'll usually want to put there is:

Code: Select all

 useDefaultExplosions = 0;
That simply disables some default and hardcoded cloud & particle spawning & stuff like that which were responsible for the effects before the CEG system got introduced...

The next part is about making something actually happen which you usually want to do by giving certain parts of your script names again:

Code: Select all

[ceg_name] {

 useDefaultExplosions = 0;
 [spawner_name_0] {
bla bla bla
 }

 [spawner_name_1] { //each spawner follows that format
bla bla bla
 }

 [groundflash] {    //groundflash is a special name; it always generates a groundflash
    flashsize=16;
    flashalpha=1;
    circlegrowth=1;
    circlealpha=0;
    ttl=8;
    color=1,1,1;
 }

} 
So you see you are free to give those parts any name you want except for "groundflash" as that's a hardcoded name. At this example you also see a bit how the entire CEG thing is going to work as there are certain tags for that groundflash effect having a certain meaning. In the case of the groundflash class you can look up the meanings HERE (scroll down a bit)...

So for every non-groundflash effect you want to have you're able to choose from a certain set of particle spawner made for several purposes. You can look up their names and the tags they provide HERE...

So now let's do something like that:

Code: Select all

[MYOWNCEG] {

 useDefaultExplosions = 0;
  [LARGEFLASH]
   {
	class = CBitmapMuzzleFlame;
      
	[properties]
      	{
         	dir = dir;
         	colorMap=1.0 0.3 0.1 0.01 0.3 0.15 0.1 0.01 0 0 0 0.01; 
          	size=6;
          	length=45;
          	sizeGrowth=-1;
          	ttl=15;
          	frontOffset=0;
          	sideTexture=muzzleside;
          	frontTexture=muzzlefront;
      	}
   water=1;
   air=1;
   underwater=1;
   ground=1;
   count=1;
   }
}
In order not to make it too long I've deleted the part about the groundflash. In this case we've done a muzzleflame spawned e.g. when a tank fires...

I guess I don't have to explain much here as the tags are explained in the Wiki. The only thing I should mention are the two textures "muzzleside" and "muzzlefront". Those two names in fact are not really the names of the textures (their ending like .tga would be missing anyway) but names you give them. For every texture you're going to use for effects like that you've to define a name for it in the resources.lua or resources.tdf (you're free too choose which syntax you want to use). I'll attach two examples for those - one being from the mod CA, one from MA so you can look up how they're written...

Well in the end that's pretty much it. Well maybe except for one minor CEG-Call: The CExpGenSpawner. While you also can read it up in the Wiki this one is no real spawner in the usual sense but it will call an effect you've defined and then give it like the proper position or delay you want and stuff like that...

Code: Select all

[MYOWNCEG] {

 useDefaultExplosions = 0; // btw - it's the same as usedefaultexplosions=0;

	[residuals_blue]
	{
	    class=CExpGenSpawner;
		[properties]
		{
		pos=-75 r150, 1, -75 r150; 
		delay=10 r200;		
		explosionGenerator=custom:LASER_RESIDUALS_LBLUE; 
		}
	air=1;
	water=1;
	ground=1;
	count=10;
	}

}

[LASER_RESIDUALS_LBLUE]
{
		[groundflash]
	{
		flashsize=66;
		flashalpha=0.6;
		circlegrowth=0;
		circlealpha=1;
		ttl=12;
		color=0.5,0.5,1;
	}
}
So as you can see we now actually have two different CEG effects: One is called "MYOWNCEG" and one is called "LASER_RESIDUALS_LBLUE" (again it's up to you to come up with names that make sense). Our "MYOWNCEG" effect now doesn't really contain a real effect of its own but just spawns that other effect giving some parameters like a delay and so on...

I hope this was helpful for you...
Attachments
resources.zip
TDF and Lua example for the resources file
(3.31 KiB) Downloaded 31 times
User avatar
Erik
Posts: 283
Joined: 20 Aug 2009, 20:49

Re: Particle effects

Post by Erik »

And how to get them ingame attached to a unit\event?
Master-Athmos
Posts: 916
Joined: 27 Jun 2009, 01:32

Re: Particle effects

Post by Master-Athmos »

Well e.g. weapons have a tag where you tell which CEG to use when the weapon hits something. How to call it from the unit script is described HERE. You just put a sfxtypes list of all the CEGs a unit should have in the unit definition which you can call in the unit script via the emit-fx 1024 + effect number call (again the Lua command has pretty much the same name)...

So as COB example for a muzzleflash for a tank you e.g. could put this as the very first things into the FireWeapon function of a unit:

Code: Select all

emit-sfx 1024 from firepoint;
This would emit the "explosiongenerator0" you defined in the unit definition (as it's 1024 + 0 ) from the object piece called "firepoint" (in this example this of course was put at the end of the tank's barrel)...
8611
XTA Developer
Posts: 242
Joined: 29 Dec 2014, 08:22

Re: Particle effects

Post by 8611 »

all covered by https://springrts.com/wiki/CEG and its subpages
Post Reply

Return to “Game Development Tutorials & Resources”