E2150 - Weather: Difference between revisions

From InsideEARTH
Content added Content deleted
No edit summary
Line 17: Line 17:
== Snow ==
== Snow ==
Snow is an effect that can reduce sight range of an object within its range, by 1. Sight range is calculated in 4x4 square areas so it virtually reduces sight range by 4 tiles - same as the night does.
Snow is an effect that can reduce sight range of an object within its range, by 1. Sight range is calculated in 4x4 square areas so it virtually reduces sight range by 4 tiles - same as the night does.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.
== Rain ==
== Rain ==
Rain is an effect that can reduce movement speed of all units in its area. Being in the area of rains effect, doubles the time a unit needs to move by 1 square, which is the same penalty as a unit may get if moving at night with lights off. Thus a unit with lights off, at night and in rain will move 3x slower.
Rain is an effect that can reduce movement speed of all units in its area. Being in the area of rains effect, doubles the time a unit needs to move by 1 square, which is the same penalty as a unit may get if moving at night with lights off. Thus a unit with lights off, at night and in rain will move 3x slower.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.
== Wind ==
== Wind ==
Wind is a global effect that affects the movement speed of all air units. it triples the time an air unit needs to move by 1 square. Thus an air unit without lights, at night, rain and wind, would move 5x slower. Wind has a global range (works on entire level). If it is created by WCC, its direction is determined my the vector between WCC building and click location. Multiple wind effects stack, so two WCCs could create 2 wind effects in opposite direction, which would effectively void the wind effect. The stacked wind speed is capped at 15 m/s. Wind can also move clouds, shifting weather effects, although it is not too significant.
Wind is a global effect that affects the movement speed of all air units. it triples the time an air unit needs to move by 1 square. Thus an air unit without lights, at night, rain and wind, would move 5x slower. Wind has a global range (works on entire level). If it is created by WCC, its direction is determined my the vector between WCC building and click location. Multiple wind effects stack, so two WCCs could create 2 wind effects in opposite direction, which would effectively void the wind effect. The stacked wind speed is capped at 15 m/s. Wind can also move clouds, shifting weather effects, although it is not too significant.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.
== Thunderstorm ==
== Thunderstorm ==
[[File:Rainstorm.png|thumb|Rainstorm over a player's base]]
[[File:Rainstorm.png|thumb|Rainstorm over a player's base]]
Thunderstorm spawns lightnings on the area, that damage and destroy units and buildings. The lightnings are more likely to hit targets that are placed higher, what can make it worth to build structures in the vicinity of higher terrain. Unless spawned with console command, thunderstorms always come with rain effect.
Thunderstorm spawns lightnings on the area, that damage and destroy units and buildings. The lightnings are more likely to hit targets that are placed higher, what can make it worth to build structures in the vicinity of higher terrain. Unless spawned with console command, thunderstorms always come with rain effect.
=== Technical data ===
==== Parameters ====
The effect is parameterized in the following way:
* '''x,y''' - epicenter location
* '''range''' - range of the effect, value gets clamped to 1-127 range
* '''upTime''' - time (in ticks) it takes to get the effect to the full intensity, min 1
* '''constTime''' - time (in ticks) in which the effect operates at full intensity, min 1
* '''downTime''' - time (in ticks) it takes for the effect to fade out, min 1
* '''intensity''' - clamped to 1-10 range
* '''power''' - determines the strength of the spawned lightnings, clamped to 1-10 range
* '''correlationId''' - it is not possible to manually set it, by default it is the incremental id of the event, but in case of rainstorm, the same value is passed to both rain and thunderstorm effects, to allow later cancellation of both related events.


Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.
==== Create conditions ====
* with ''Weather.AddStorm(x, y, range, upTime, constTime, downTime, intensity, power)'' command - it is the only way to spawn Thunderstorm without the rain
* with ''Weather.AddRainStorm(x, y, range, upTime, constTime, downTime, rainIntensity, stormIntensity, stormPower)'' command, that spawns both Rain and Thunderstorm
* with ''Storm(x, y, range, upTime, constTime, downTime, rainIntensity, stormIntensity, stormPower)'' function call from within EarthC scripts
* with '''Weather Control Center'''. This spawns both rain and thunderstorm effects with the following parameters:
** x, y - as selected by the player
** range - 30
** upTime - 300 ticks = 15 seconds
** constTime - 1200 ticks = 60 seconds
** downTime - 300 ticks = 15 seconds
** intensity - 2
** power - 5
** rain intensity is at the maximum value of 10


For technical details, see a [[E2150 - Weather - Technical data|dedicated site]].
==== Single lightning spawn algorithm ====
# Get random location in effect's range
# Get random hit offset range (an area to search for lightning interceptors)
# Alter hit location to make the lightning hit the highest point in the vicinity
# Randomize spawned lightning type, affected by the ''power'' parameter
# Spawn lightning

===== Finding the random "initial location" =====
The game calculates a random distance (''r1'', within 0-''range'') and a random angle ''alpha'' (0-255, where 256 == 2*PI rad). With the use of ''sin'' and ''cos'' functions of ''alpha'', multiplied by the ''r1'' value, the game calculates offset (''x1'', ''y1'') from the epicenter. After applying the offset to the ''x'' and ''y'' parameters, we will get a point (''x2'', ''y2''). This point is the initial hit location. If the location is outside of the level, the lightning won't spawn. There is no difference for the lightning to spawn in the accessible or the inaccessible area of the map (the level "margin"), so casting rainstorm near the edge of the level will result with fewer lightnings spawned and/or fewer lightnings hitting relevant area. You may also notice that '''lightnings are more likely to hit nearby the epicenter''', rather than on the further distances. The target spawn probability for the default WCC range 30, is as below. Values in cells are the spawn chance *10^-2% (the middle square with value 161 means that there is a 1,61% chance that this square will be the hit target).
[[File:HitProbability.png]]

===== Altering hit location by nearby high elements =====
The hit location is altered in the following way: We take a random number ''r2'' within the range of 4-8. The way this number gets randomized isn't that simple - there is a 1/3 chance that the number will be in <4-6> range, and 2/3 chance that the number will be within <6-8> range. This makes value 6 the most probable (33%), followed by 7 and 8 (both 22%), with 4 and 5 being the least probable (both 11%). The game iterates all terrain tiles within a square area bounded by ''x2 - r2'', ''y2 - r2'', ''x2 + r2'', ''y2 + r2'' and searches for the highest spot. This establishes the final hit location.

===== Type of spawned lightning =====
There are multiple kinds of lightnings, that are defined in game parameters, thus their count and properties can be different among game versions and mods. By default there are 5 of them, each subsequent one being stronger than the previous one (this should always be made that way). The way the lightning is being chosen is a little bit complicated. There are 20 "spawn factors" for each of the ''power'' parameter levels. Those values (taken randomly 1-20) are in range of 0-10, with 0 pointing to the weakest lightning, and 10 pointing to the strongest. The index of the lightning (0 to ''numOfLightningTypes - ''1) is calculated as follows: ''spawnFactor * (numOfLightningTypes - 1) / 10''. Below is the table of "Spawn factors":
[[File:SpawnFactors.png]]

Example: We have 5 lightning types in parameters, a thunderstorm with ''power'' = 5 and we randomized (1-20) the 17th factor. From the table above we get value '''3'''. The index of the lightning type is ''3 * (5 - 1) / 10 = 12 / 10 = 1''. This results in spawning the second (first has index = 0) lightning type from the parameters.

Taking above into account, the default WCC's lightning (5 types in parameters, power = 5) has 5% chance of spawning lightning type 3/5, 15% chance of spawning lightning type 2/5, and 80% chance to spawn the weakest lightning of type 1/5.

==== Effect intensity ====
Event intensity scales lineary from 0 to the target ''intensity'' (from event's parameter) during up time, and diminishes in the same way during down time. The intensity is equal to the target intensity during ``const time`` phase. The timeout between lightnings is calculated as follows:
x = 400 / currentIntensity * range
deltaT = Max(1, Rand(0, x-1) + x / 2)

With default WCC settings, at full intensity, a thunderstorm spawns a lightning every 3-8 ticks (0,15s-0,4s).


== Meteor rain ==
== Meteor rain ==
Line 83: Line 39:
Meteors are another destructive weather effect, which similarly to thunderstorm hits multiple targets at the area it happens. Meteors are stronger however, since they don't get intercepted by higher elements, they deal AOE damage and cannot be canceled with Weather Control Center.
Meteors are another destructive weather effect, which similarly to thunderstorm hits multiple targets at the area it happens. Meteors are stronger however, since they don't get intercepted by higher elements, they deal AOE damage and cannot be canceled with Weather Control Center.


Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.
=== Technical data ===
==== Parameters ====
The effect is parameterized in the following way:
* '''x,y''' - epicenter location
* '''range''' - range of the effect, value gets clamped to 1-127 range
* '''upTime''' - time (in ticks) it takes to get the effect to the full intensity, min 1
* '''constTime''' - time (in ticks) in which the effect operates at full intensity, min 1
* '''downTime''' - time (in ticks) it takes for the effect to fade out, min 1
* '''intensity''' - clamped to 1-10 range
* '''power''' - determines the strength of the spawned lightnings, clamped to 1-10 range
* '''alphaAngle''' - the angle at which the meteors strike (horizontally). Any value above 255 gets reduced to the rest of the division by 256. If "-1" is provided, the value gets picked randomly from the 0-255 range
* '''betaAngle''' - the angle at which the meteors strike (vertically). If value is not "-1", it gets clamped to <48, 64> range. If "-1" is provided, the value gets picked randomly from the 48-64 range


For technical details, see a [[E2150 - Weather - Technical data|dedicated site]].
==== Create conditions ====
* with ''Weather.AddMeteorRain(x, y, range, upTime, constTime, downTime, intensity, power, alphaAngle, betaAngle)'' command - it is the only way to spawn meteor rain with custom angle values
* with ''Shower'' cheat, that spawns the meteor rain with following parameters:
** x, y - current camera position
** range - 12
** upTime - 100 ticks = 5 seconds
** constTime - 500 ticks = 25 seconds
** downTime - 100 ticks = 5 seconds
** intensity - 10
** power - 10
** alpha - 32
** beta - 53
* with ''MeteorRain(x, y, range, upTime, constTime, downTime, intensity, power)'' function call from within EarthC scripts. The angles are set to -1, thus are always randomized.
* with '''Weather Control Center'''. This spawns the meteor rain with the following parameters:
** x, y - as selected by the player
** range - 30
** upTime - 300 ticks = 15 seconds
** constTime - 1200 ticks = 60 seconds
** downTime - 300 ticks = 15 seconds
** intensity - 2
** power - 5
** alpha - (-1) (random)
** beta - (-1) (random)

==== Single meteor spawn algorithm ====
# Get random location in effect's range
# Calculate spawn location at 4096 height, with an offset that takes into account the angles
# Randomize spawned meteor type, affected by the ''power'' parameter
# Spawn meteor

===== Finding the random location =====
The procedure is the same as with lightnings - random angle, random distance, calculate offset using trigonometry. The spawn probabilities are the same as in case of thunderstorm, but here, the location isn't altered by nearby high objects, what makes the figure in Thunderstorm section more reliable here.

===== Calculating the spawn location =====
The algorithm takes beta angle and calculates the horizontal offset form the hit location to the spawn point at 4096 height (''4096 / tan(beta)''). Using this distance, the ''alphaAngle'', along with ''sin(alpha) * dist'' and ''cos(alpha) * dist'', the algorithm calculates offset from the hit location

===== Type of spawned meteor =====
Same as with lightning types.

==== Effect intensity ====
Event intensity scales lineary from 0 to the target ''intensity'' (from event's parameter) during up time, and diminishes in the same way during down time. The intensity is equal to the target intensity during ''const time'' phase. The timeout between meteors is calculated as follows (the only difference to lightning is 400 being replaced by 500, which results in meteors spawning a bit less frequently):
x = 500 / currentIntensity * range
deltaT = Max(1, Rand(0, x-1) + x / 2)

With default WCC settings, at full intensity, a meteor rain spawns a meteor every 4-11 ticks (0,2s-0,55s).


== Clearing effects ==
== Clearing effects ==
All weather effects end after a certain period of time. Some effects (rain, thunderstorm and snow) can also be cancelled by either ''Weather.RemoveCloud(x,&nbsp;y)'' console command, or WCC action. The effect cancellation applies to a single effect with the longest remaining time, among those that affect the selected location. In case of rainstorms, cancellation cancels both rain and thunderstorm. The cancellation pushes the event to the "fade out" phase, or in case it is already there, reduces the remaining time by half.
All weather effects end after a certain period of time. Some effects (rain, thunderstorm and snow) can also be cancelled by either ''Weather.RemoveCloud(x,&nbsp;y)'' console command, or WCC action. The effect cancellation applies to a single effect with the longest remaining time, among those that affect the selected location. In case of rainstorms, cancellation cancels both rain and thunderstorm. The cancellation pushes the event to the "fade out" phase, or in case it is already there, reduces the remaining time by half.

Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.

Revision as of 21:33, 8 December 2023

The weather in Earth 2150 is dynamic and can actively influence the gameplay. Various weather effects can happen due to being scripted by gamemode/campaign designers, console commands, or player actions (LC's Weather Control Center). The weather effects available in the game are as follows: snow, rain, wind, thunderstorm and meteor rain. Thunderstorm usually happen along with rains (although it is possible to have a thunderstorm without a rain).

Day and night cycle

The time of the day in game is dynamic and there are days and nights, just like in real life. Those cycles are not just visual feature, as they affect gameplay - the vision at night is limited and it is harder to spot enemy structures/units (unless they have lights turned on), obviously the LC solar power is affected, and additionally, the temperature changes during day and night.

The entire in-game 24h can be divided into 4 phases:

  • dawn (06:40 AM - 09:00 AM)
  • day (09:00 AM - 05:00 PM)
  • twilight (05:00 PM - 07:45 PM)
  • night (07:45 PM - 06:40 AM)

You may notice that the night is longer than the day and the actual ratio is 9:7. The entire 24h period is ~819s of real time ~= 13,65 minutes.

Clouds

Although not visible, the clouds are there and they actually matter. The game calculates clouds on the sky, that come along with weather effects such as rain or snow. Those clouds later affect solar efficiency of LC's solar power plants.

Snow

Snow is an effect that can reduce sight range of an object within its range, by 1. Sight range is calculated in 4x4 square areas so it virtually reduces sight range by 4 tiles - same as the night does.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.

Rain

Rain is an effect that can reduce movement speed of all units in its area. Being in the area of rains effect, doubles the time a unit needs to move by 1 square, which is the same penalty as a unit may get if moving at night with lights off. Thus a unit with lights off, at night and in rain will move 3x slower.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.

Wind

Wind is a global effect that affects the movement speed of all air units. it triples the time an air unit needs to move by 1 square. Thus an air unit without lights, at night, rain and wind, would move 5x slower. Wind has a global range (works on entire level). If it is created by WCC, its direction is determined my the vector between WCC building and click location. Multiple wind effects stack, so two WCCs could create 2 wind effects in opposite direction, which would effectively void the wind effect. The stacked wind speed is capped at 15 m/s. Wind can also move clouds, shifting weather effects, although it is not too significant.

Weather control center needs to be charged at 50% to cast this effect, what takes 7,5 minutes.

Thunderstorm

Rainstorm over a player's base

Thunderstorm spawns lightnings on the area, that damage and destroy units and buildings. The lightnings are more likely to hit targets that are placed higher, what can make it worth to build structures in the vicinity of higher terrain. Unless spawned with console command, thunderstorms always come with rain effect.

Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.

For technical details, see a dedicated site.

Meteor rain

Meteor rain over a player's base

Meteors are another destructive weather effect, which similarly to thunderstorm hits multiple targets at the area it happens. Meteors are stronger however, since they don't get intercepted by higher elements, they deal AOE damage and cannot be canceled with Weather Control Center.

Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.

For technical details, see a dedicated site.

Clearing effects

All weather effects end after a certain period of time. Some effects (rain, thunderstorm and snow) can also be cancelled by either Weather.RemoveCloud(x, y) console command, or WCC action. The effect cancellation applies to a single effect with the longest remaining time, among those that affect the selected location. In case of rainstorms, cancellation cancels both rain and thunderstorm. The cancellation pushes the event to the "fade out" phase, or in case it is already there, reduces the remaining time by half.

Weather control center needs to be charged at 100% to cast this effect, what takes 15 minutes.