Particle Effects

From FreeSpace Wiki
Revision as of 18:47, 19 September 2024 by Kestrellius (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
This feature requires FreeSpace Open

Revision information.....

FSO Git Commit: Date: 2024-08-26 SHA: 91a673ac586a57e8f7793f08985b6f17a7fd1aa7
Note: Please update the revision information when the page is updated. If your edit had nothing to do with new code entries then please do not edit the revision information


List of Tables and related code files
* Notes Modular Tables
** Notes tables which only use modular tables
Ai.tbl* /ai/aicode.cpp
Ai_profiles.tbl* /ai/ai_profiles.cpp
Animation.tbl** /model/modelanimation.cpp
Armor.tbl* /ship/ship.cpp
Asteroid.tbl* /asteroid/asteroid.cpp
Autopilot.tbl* /autopilot/autopilot.cpp
Cheats.tbl* /cheats_table/cheats_table.cpp
Colors.tbl* /globalincs/alphacolors.cpp
Curves.tbl* /math/curves.cpp
Controlconfigdefaults.tbl /controlconfig/controlsconfigcommon.cpp
Credits.tbl* /menuui/credits.cpp
Cutscenes.tbl* /cutscene/cutscenes.cpp
Decals.tbl** /decals/decals.cpp
Fireball.tbl* /fireball/fireballs.cpp
Fonts.tbl* /graphics/font.cpp
Game_settings.tbl* /mod_table/mod_table.cpp
Glowpoints.tbl* /model/modelread.cpp
Help.tbl* /gamehelp/contexthelp.cpp
Hud_gauges.tbl* /hud/hudparse.cpp
Icons.tbl* /mission/missionbriefcommon.cpp
Iff_defs.tbl* /iff_defs/iff_defs.cpp
Keywords.tbl* Not In Codebase
Lighting_Profiles.tbl* /lighting/lighting_profiles.cpp
Lightning.tbl* /nebula/neblightning.cpp
Mainhall.tbl* /menuui/mainhallmenu.cpp
Medals.tbl* /stats/medals.cpp
Messages.tbl* /mission/missionmessage.cpp
Mflash.tbl* /weapon/muzzleflash.cpp
Music.tbl* /gamesnd/eventmusic.cpp
Nebula.tbl* /nebula/neb.cpp
Objecttypes.tbl* /ship/ship.cpp
Options.tbl* Not In Codebase
Particle effects(-part.tbm)** /particle/effects...
Post_processing.tbl /graphics/gropenglpostprocessing.cpp
Rank.tbl* /stats/scoring.cpp
Scpui.tbl* Not In Codebase
Scripting.tbl* /parse/scripting.cpp
Ships.tbl* /ship/ship.cpp
Sexps.tbl** /parse/sexp/sexp_lookup.cpp
Sounds.tbl* /gamesnd/gamesnd.cpp
Species_defs.tbl* /species_defs/species_defs.cpp
Species.tbl* /menuui/techmenu.cpp
Ssm.tbl* /hud/hudartillery.cpp
Stars.tbl* /starfield/starfield.cpp
Strings.tbl* /localization/localize.cpp
Tips.tbl* /menuui/playermenu.cpp
Traitor.tbl* /stats/scoring.cpp
Tstrings.tbl* /localization/localize.cpp
Virtual_pofs.tbl* /model/modelreplace.cpp
Weapon_expl.tbl* /weapon/weapons.cpp
Weapons.tbl* /weapon/weapons.cpp

Particle Effects is a SCP feature which allows to define custom particle effects that can be assigned to various engine properties.

This table is one of the Modular Tables and can be extended with xxx-part.tbm. This table type does not have a main table like the other types. All particle effects must be specified in modular tables. Currently there is no support for the usual +nocreate ability the other modular tables have but that will be added in the future. Parts of this documentation are written with with +nocreate in mind for when that is implemented.

General Info

  • Begins with #Particle Effects
  • Contains zero or more particle effect definitions
  • Ends with #End

Particle effects are created by specifying a name and a type. The type dictates which values are valid and will be described below.

$Effect:

  • Creates a new effect and specifies its name. The name must be at least one character long.
  • Syntax: String

$Type:

  • Sets the type of this effect. See Effect Types for possible values.
  • Syntax: String

+Filename:

  • Sets the filename of the animation that should be used.
  • Required if +nocreate wasn't used
  • Syntax: String, filename
FS2 Open, 21.0:
  • Allows for setting list of filenames the animation should use. If multiple animations are listed it picks randomly from the list for each spawned animation.
  • Syntax: String or String List, filename(s)

+Size:

  • Sets the size of the created particles. This is a random range; see Parsed random range.
  • Required if +nocreate wasn't used, but only one between +Size and +Parent Size Factor may be used.
  • Syntax: See Parsed random range
FS2 Open, 24.0:

+Parent Size Factor:

  • Sets the size to be a factor of the current size of the particle that spawned it. Only works when spawned as a trail particle effect of another particle. This is a random range; see Parsed random range.
  • Required if +nocreate wasn't used, but only one between +Size and +Parent Size Factor may be used.
  • Syntax: See Parsed random range

+Length:

+Lifetime:

  • Sets the life time of the particles. This is a random range; see Parsed random range, or the string <none> in which case the runtime of the animation is used. Defaults to <none>.
  • This is optional, but only one between +Lifetime and +Parent Lifetime Factor may be used.
  • Syntax: See Parsed random range, or the string <none>
FS2 Open, 24.0:

+Parent Lifetime Factor:

  • Sets the lifetime to be a factor of the remaining lifetime of the particle that spawned it. Only works when spawned as a trail particle effect of another particle. This is a random range; see Parsed random range.
  • This is optional, but only one between +Lifetime and +Parent Lifetime Factor may be used.
  • Syntax: See Parsed random range
FS2 Open, 23.2:

+Size over lifetime curve:

  • Specifies the curve to use for changing the particle's size over time
  • The lifetime of the particle (0-1) is X, the size multiplier is Y.
  • Syntax: String, the name of the curve from Curves.tbl
FS2 Open, 23.2:

+Velocity scalar over lifetime curve:

  • Specifies the curve to use for changing the particle's velocity over time
  • The lifetime of the particle (0-1) is X, the velocity multiplier is Y (negative Y values cause the particle to move backwards, etc).
  • Syntax: String, the name of the curve from Curves.tbl


FS2 Open, 24.2:

+Offset:

  • Offsets the position of the particle source relative to the spawner. Positive Z means "forward".
  • For effects spawned from ships (including primary or secondary muzzle effects) and weapons (including hit effects), all three dimensions will work correctly.
  • For effects spawned from particles (as with +Trail effects) or from beams, the X and Y axes will not behave in a sensible fashion! You use them at your own risk.
  • For turret muzzle effects, the X and Y axes will have no effect; only the Z axis will work.
  • Syntax: Vector, three floats, x, y and z values respectively

+Remain local to parent:

  • If this is true, the effect will be 'parented' to its spawner, and will move with it, inheriting all changes to the spawner's position and orientation. Very useful for some types of muzzle effect.
  • Defaults to false.
  • Syntax: Boolean

Effect Types

There are multiple different types of effects. They are specified by passing the given name to $Type.

Single

This effect type creates exactly one particle per processing step.


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See Parsed random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a Parsed random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See Parsed random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
FS2 Open, 24.2:

Batches of particles spawned at different points during a frame will be spawned at the correct positions along a moving spawner entity's trajectory, with millisecond precision, rather than all 'clumping' at the spawner's final position for that frame. This works for particles spawned from objects (like ships and weapons), and ones spawned from other particles (as with a $Trail effect), but does not currently work for particles spawned from beams.

  • This is optional
  • Syntax: number. Must be greater than 0.

Composite

A composite effects contains multiple other effects which are all displayed at the same time. This is useful if you want to create complex effects that require more than one individual particle effect. The amount of child effects is not limited. This type currently does not support +nocreate.

+Child effect:

  • This specifies a child effect that should be added to the composite effect. The effect is specified using #Inline effect creation.

Cone

This effects creates multiple particles which are sent in a direction determined by a cone around a specific direction. The particles are created in a normal distribution around the direction vector. That means that more particle are created along the direction vector than far away from it. The velocity of a particle is scaled based on the angle it is away from the direction vector. This may be changed in the future to allow different effects.

+Deviation:

  • Sets the standard deviation from the direction vector. Must not be 0 (though 0.1 is acceptable).
  • Required if +nocreate is not present
  • Syntax: float, in degrees

+Velocity:

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.

+Direction:

  • Sets the direction the cone will be centered around. Can be one of:
    • Incoming: The direction vector is the direction of the particle source, e.g. for a weapon this would be the orientation it is currently facing.
    • Normal: The normal vector of the particle source. This data may not exist for all sources. The debug log file will contain the warning message "Effect '<EffectName>' tried to use normal direction for source without a normal!" if an effect tries to use the normal vector without it existing.
    • Reflected: The reflected vector from incoming and normal vector. This is a good way of simulating armor deflecting a shot. This direction requires the normal for work properly so the same warning message as above may appear in your log if the source has no normal vector assigned to it.
    • Reverse: The reverse of the incoming vector
  • Optional
  • Syntax: String, one of the strings specified above


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See Parsed random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a Parsed random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See Parsed random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
FS2 Open, 24.2:

Batches of particles spawned at different points during a frame will be spawned at the correct positions along a moving spawner entity's trajectory, with millisecond precision, rather than all 'clumping' at the spawner's final position for that frame. This works for particles spawned from objects (like ships and weapons), and ones spawned from other particles (as with a +Trail effect), but does not currently work for particles spawned from beams.

  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:

Sphere

This effect creates particles which are randomly sent in all directions.

+Velocity:

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See Parsed random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a Parsed random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See Parsed random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
FS2 Open, 24.2:

Batches of particles spawned at different points during a frame will be spawned at the correct positions along a moving spawner entity's trajectory, with millisecond precision, rather than all 'clumping' at the spawner's final position for that frame. This works for particles spawned from objects (like ships and weapons), and ones spawned from other particles (as with a +Trail effect), but does not currently work for particles spawned from beams.

  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:


FS2 Open, 21.4:

Volume

This effect creates particles within a spherical (or ellipsoidal) volume.

+Velocity:

  • Sets the velocity of the created particles. This is a Parsed random range. This value will be scaled based the particle's starting distance from the center of the volume.
  • Required if +nocreate is not present
  • Syntax: See Parsed random range

+Number:

+Chance:

FS2 Open, 22.2:
  • Sets a chance to spawn for each particle specified by +Number
  • Syntax: float between 1.0 and 0.0. 1.0 is a 100% chance, and 0.0 is a 0% chance.

+Volume radius:

  • Sets the radius of the spherical volume.
  • Required if +nocreate is not present
  • Syntax: Float, meters

+Bias:

  • Causes the particles to spawn more frequently near the edges or near the center. Values greater than 1 bias the particles toward the center, less than 1 biases them towards the edge.
  • This is optional.
  • Syntax: Float

+Stretch:

  • 'Stretches' or squashes the spherical volume into an ellipsoid. Values greater than 1 stretch it, less than 1 squashes it.
  • This is optional.
  • Syntax: Float


FS2 Open, 22.0:

+Parent Velocity Factor:

  • Allows the particles to inherit the velocity of an attached object, like a weapon/ship/particle if applicable, or the last velocity of the associated weapon in the case of a weapon's $Impact Effect.
  • 0 is none of the velocity, 1 is 100% of the velocity, but the value can exceed those in either direction if desired.
  • Syntax: See Parsed random range
  • Default: 0

+Duration:

  • Sets for how long this effect will be active. The duration can be once, always or a random range. If the effect should run only once then you can use the string Onetime. If the effect should always be active you can specify the string Always. Otherwise a non-negative random range is expected.
  • This is optional
  • Syntax: Onetime, Always, or a Parsed random range.

+Delay:

  • Specifies after how much time after the effect is triggered the effect starts creating particles. This is not a valid option if the duration is Onetime.
  • This is optional
  • Syntax: See Parsed random range, or the string <none>

+Effects per second:

  • Specifies how many times per second this effect is triggered. If this is not specified then the effect is triggered every frame. "Triggering" an effect means that one instance of the effect with the properties from above is created. If this is specified then the amount of triggers per second is always the same regardless of the FPS the game is running at. Values higher than the FPS (e.g. 120 if the game is running at 60 FPS) are handled correctly and will trigger the effect multiple times per frame if necessary.
FS2 Open, 24.2:

Batches of particles spawned at different points during a frame will be spawned at the correct positions along a moving spawner entity's trajectory, with millisecond precision, rather than all 'clumping' at the spawner's final position for that frame. This works for particles spawned from objects (like ships and weapons), and ones spawned from other particles (as with a +Trail effect), but does not currently work for particles spawned from beams.

  • This is optional
  • Syntax: number. Must be greater than 0.

+Trail effect:

Inline effect creation

At some places in this table a particle effect may be created within another particle effect. This is used for composite effects and particle trails. If inline creation is valid for an option then you may either specify a name of a previously defined effect or use $New Effect which will create a new, unnamed effect. If a name is specified then that effect must be already defined. In order to ensure that the effect is always defined no matter in which order the effect tables are parsed the effect should be defined in the same table. Some options using this construct require a specific type of effect. That will be noted in the documentation of the option.

If $New Effect is used then a new unnamed effect is created. If the surrounding option has not forced an effect type then you can specify it using the standard syntax described above. All options are the same as if the effect would have been parsed in the normal way. +nocreate is not valid within this element.

Example

#Particle Effects

$Effect: MassDriverImpact
$Type: Cone
	+Filename: exp05
	+Size: (5 7)
	+Lifetime: (0.6)
	+Deviation: 5
	+Velocity: CURVE CurvePolyDown5.0 (500 700)
	+Number: NORMAL (20 30)
	+Direction: Reflected
	+Trail effect: $New Effect
		$Type: Single
			+Filename: exp20
			+Size: CURVE CurveCircDown
			+Lifetime: (1)
			+Duration: Always


$Effect: ApocalypseIgnition
$Type: Single
	+Filename: exp20
	+Size: (10 20)

$Effect: Small_Explosion
$Type: Single
	+Filename: ("exp20" "exp05")
	+Size: (10 20)
	
$Effect: ApocalypseHomed
$Type: Composite
	+Child effect: $New Effect
		$Type: Single
			+Filename: exp05
			+Size: (5 7)
			+Duration: (2 10)
	+Child effect: $New Effect
		$Type: Single
			+Filename: exp06b
			+Size: (5 7)
			+Duration: (2 10)
			+Delay: (8 15)
			+Effects per second: 20

#End