E2150 - Weather: Difference between revisions

Content added Content deleted
No edit summary
Line 61: Line 61:


== Meteor rain ==
== Meteor rain ==
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.

=== 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

==== 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.

===== 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).