Difference between revisions of "Gas"

From RimWorld Wiki
Jump to navigation Jump to search
(→‎Mechanics: Code analysis based details on gas dissipation, diffusion, spawning, and vents.)
Line 7: Line 7:
 
== Mechanics ==
 
== Mechanics ==
  
Gasses have a concentration of 1-100%. This is calculated for each tile that contains gas.  
+
Gasses have a density of 0-100% (which is represented in the engine as 1 byte for a maximum integer value of 255 density). This is calculated for each tile that contains gas, separately for each type of gas. Walls, closed doors, and other blocking structures such as [[Nutrient paste dispenser]]s prevent gas from spawning or diffusing onto their tiles.  
  
Gas slowly dissolves into normal air and will disappear when the concentration reaches 0%. Different weapons have different mechanics when it comes to creating gas.
+
=== Dissipation ===
  
[[Gas]]es can travel through vents.{{Check Tag|Details}}
+
Dissipation causes gas density to be reduced in each tile overtime.
  
====Things that increase the concentration of the gas====
+
On each tick, a random 1/64 of all map tiles are ticked for gas dissipation. Smoke and Rot stink dissipate at an average rate of ~1.57% (4) density per 64 ticks, while Tox gas dissipates at an average rate of ~1.18% density (3) per 64 ticks.  60 ticks is 1 second at 1x speed, for reference.
* Releasing more gas with weapons or traps
 
  
====Things that block gas====
+
=== Diffusion ===
* Walls
 
  
====Things that do not influence the gas concentration or dissolve speed====
+
Diffusion causes gas density to spread from tiles of higher density to lower density. Tox gas and Rot stink gases may diffuse, while Smoke does not. The minimum density for Tox gas and Rot stink to diffuse is ~6.66% (17), below which diffusion ceases.
* Roofs
 
  
==Analysis==
+
On each tick, a random 1/32 of all map tiles are ticked for gas Diffusion. For each tick of diffusion, the tile being ticked will average its gas density with that of an adjacent tile with a lower density of gas.
  
Although gases can spread to neighbouring tiles, (it seems) they can only do this to a certain extent.  
+
Gases can only diffuse to open tiles, without walls, closed doors, or other blocking structures like nutrient paste dispensers.
  
Further testing is needed:
+
=== Spawning ===
* When two/three pawns fire at the same time, will the volume of the cloud be bigger than if only pawn fires?
+
 
* Walls seem to 'absorb' gas. In a narrow and wide corridor the gas dissolves at an equal speed. In the narrow one it barely reaches further.  
+
When gas is spawned, if gas already exists in the tile, any resulting gas density over 100% is pushed out to adjacent tiles, up to 40 tiles away from the source. Multiple sources spawning gas, such as multiple pawns using tox weapons, will fill much more space, much faster, with gas than a single pawn due to this.
* Rot stink might have slightly different mechanics. In earlier tests it seemed to reach a higher concentration in enclosed spaces. This is probably unrelated to the roof, but rather to being in a small area where it can not spread to dissolve equally fast as it was being created by the rotting corpse.  
+
 
* Effect of open doors is not known yet.
+
==== Explosives ====
 +
Explosives that spawn gas such as the projectiles of the [[Toxbomb launcher]], [[Tox grenades]], and [[Smoke launcher]] spawn 100% density of gas on each tile within their explosive radius. Any tiles in their explosive radius that does not allow gas such as a wall causes that gas density to not be spawned. Thus for maximum tox gas spawning into a confined space, an open 3x3 space for all 9 tiles of tox gas generation should be used.
 +
 
 +
==== Packs ====
 +
Packs that release gas such a deployed [[Tox pack]] or [[Smokepop pack]] have a total density (defined as a number of cells filled to 100% density) they release over their duration at their position, spawning gas every 1/30 ticks (2 times a second at 1x speed).
 +
 
 +
==== Rot Stink ====
 +
Rot stink is generated from a rotting corpse on each rare tick (1/250 ticks, or 4.16 seconds at 1x speed), with a density of ~20.4% (52) per unit of of the corpse's body size. Rot stink is generated on the corpse's cell.
 +
 
 +
=== Vents ===
 +
 
 +
Tox gas and rot stink pass through vents, while smoke does not.
 +
 
 +
On each rare tick (1/250 ticks, or 4.16 seconds at 1x speed), the gas density of tox gas and rot stink on each side of a vent is averaged and equalized. For example, if one side has 90% and the other 20%, after a rare tick both sides will have 55%.
 +
 
 +
=== Doors ===
 +
 
 +
A closed door acts the same as a wall, preventing spawning and diffusion of gas onto the tile. Open doors act the same as an open tile for spawning and diffusion. Closing a door with existing gas will cause the gas to remain the tile, but no longer diffuse to or from other tiles, or be spawned on that tile. Gas on closed door tiles will dissipate over time as normal.
 +
 
 +
== Testing ==
  
 
[[File:Smokelauncher gas physics comparison.mp4|thumb|left|Gas expanding from a single point to fill a room]]
 
[[File:Smokelauncher gas physics comparison.mp4|thumb|left|Gas expanding from a single point to fill a room]]

Revision as of 11:56, 22 November 2023

Gases are a class object that behaves in a certain way. There are currently three gasses:

Mechanics

Gasses have a density of 0-100% (which is represented in the engine as 1 byte for a maximum integer value of 255 density). This is calculated for each tile that contains gas, separately for each type of gas. Walls, closed doors, and other blocking structures such as Nutrient paste dispensers prevent gas from spawning or diffusing onto their tiles.

Dissipation

Dissipation causes gas density to be reduced in each tile overtime.

On each tick, a random 1/64 of all map tiles are ticked for gas dissipation. Smoke and Rot stink dissipate at an average rate of ~1.57% (4) density per 64 ticks, while Tox gas dissipates at an average rate of ~1.18% density (3) per 64 ticks. 60 ticks is 1 second at 1x speed, for reference.

Diffusion

Diffusion causes gas density to spread from tiles of higher density to lower density. Tox gas and Rot stink gases may diffuse, while Smoke does not. The minimum density for Tox gas and Rot stink to diffuse is ~6.66% (17), below which diffusion ceases.

On each tick, a random 1/32 of all map tiles are ticked for gas Diffusion. For each tick of diffusion, the tile being ticked will average its gas density with that of an adjacent tile with a lower density of gas.

Gases can only diffuse to open tiles, without walls, closed doors, or other blocking structures like nutrient paste dispensers.

Spawning

When gas is spawned, if gas already exists in the tile, any resulting gas density over 100% is pushed out to adjacent tiles, up to 40 tiles away from the source. Multiple sources spawning gas, such as multiple pawns using tox weapons, will fill much more space, much faster, with gas than a single pawn due to this.

Explosives

Explosives that spawn gas such as the projectiles of the Toxbomb launcher, Tox grenades, and Smoke launcher spawn 100% density of gas on each tile within their explosive radius. Any tiles in their explosive radius that does not allow gas such as a wall causes that gas density to not be spawned. Thus for maximum tox gas spawning into a confined space, an open 3x3 space for all 9 tiles of tox gas generation should be used.

Packs

Packs that release gas such a deployed Tox pack or Smokepop pack have a total density (defined as a number of cells filled to 100% density) they release over their duration at their position, spawning gas every 1/30 ticks (2 times a second at 1x speed).

Rot Stink

Rot stink is generated from a rotting corpse on each rare tick (1/250 ticks, or 4.16 seconds at 1x speed), with a density of ~20.4% (52) per unit of of the corpse's body size. Rot stink is generated on the corpse's cell.

Vents

Tox gas and rot stink pass through vents, while smoke does not.

On each rare tick (1/250 ticks, or 4.16 seconds at 1x speed), the gas density of tox gas and rot stink on each side of a vent is averaged and equalized. For example, if one side has 90% and the other 20%, after a rare tick both sides will have 55%.

Doors

A closed door acts the same as a wall, preventing spawning and diffusion of gas onto the tile. Open doors act the same as an open tile for spawning and diffusion. Closing a door with existing gas will cause the gas to remain the tile, but no longer diffuse to or from other tiles, or be spawned on that tile. Gas on closed door tiles will dissipate over time as normal.

Testing

Version history

  • 1.4.3523 - Gas system added. Previously smoke was the only gas and it only existed as a temporary object with a set but refreshable duration.
  • 1.4.3555 - Gases can now travel through vents.