Adding weather effects to a map

Young Alphabet edited this page Jun 13, 2017 · 2 revisions
Clone this wiki locally

How to add weather effects to a map

In this tutorial, we are going to add some cool weather effects to a map of your choice.

First of all, search the map you want the weather effect to be added. Possible locations are here:

Users\-Username-\Documents\OpenRA\maps

Program Files\OpenRA\mods\-mod-\maps

If your map is a .oramap file, open it with e.g. 7zip file manager. Then open the map.yaml.

Scroll down and, if necessary, add the Rules::

MapFormat: 11

RequiresMod: The mod

Title: Your title here

Author: Your name here

Tileset: Your map's tilset

MapSize: Size of your map

Bounds: Bounds of your map

Visibility: Visibility of your map

Categories: Categories of your map

Players: [...]

Actors: [...]

Rules: # You can also use an external .yaml file, but then write it's name down here.

Part 1: the weather effect

For this part we need to add a trait called WeatherOverlay to World. So add following lines to rules:

Snow

Rules:
	World:
		WeatherOverlay:
			ChangingWindLevel: true
			WindLevels: -5, -3, -2, 0, 2, 3, 5
			WindTick: 250, 550
			InstantWindChanges: false
			UseSquares: true
			ParticleSize: 1, 4
			ScatterDirection: -1, 1
			Gravity: 1.00, 2.00
			SwingOffset: 1.0, 1.5
			SwingSpeed: 0.001, 0.025
			SwingAmplitude: 1.0, 1.5
			ParticleColors: ECECEC, E4E4E4, D0D0D0, BCBCBC
			LineTailAlphaValue: 0

Rain

Rules:
	World:
		WeatherOverlay:
			WindTick: 150, 550
			UseSquares: false
			ScatterDirection: 0, 0
			Gravity: 8.00, 12.00
			SwingOffset: 0, 0
			SwingSpeed: 0, 0
			SwingAmplitude: 0, 0
			ParticleColors: 304074, 28386C, 202C60, 182C54
			LineTailAlphaValue: 150
			ParticleSize: 1, 1

A bit confused? We'll explain the meaning of all those Properties:

Property Description
ChangingWindLevel Changes the level of the wind over time when true. if false, the effect will use the first value of WindLevels.
WindLevels The different levels of the wind density (the particles x-axis movement in px/tick).
WindTick The speed of the wind. Min. and max. value needed. !! This works only if ChangingWindLevel is true.
InstantWindChanges A hard or soft fading between the WindLevels.
UseSquares If true, the particles will be drawn as squares.
ParticleSize Size of the particles. Min. and max. value needed.
ScatterDirection Scatter direction on the X-axis. Min. and max. value needed.
Gravity The speed at which the particles are falling to ground. Min. and max. value needed.
SwingOffset The offset value for the swinging particles. Min. and max. value needed.
SwingSpeed This controls how fast particles are swinging. Min. and max. value needed.
SwingAmplitude The range the particles can swing to left or right. Min. and max. value needed.
ParticleColors The colors of the particles.
LineTailAlphaValue Can be used as a kind of a Contrail.

Save the file and start your map.

Looks nice, eh? If you like, change the values. With a bit experimenting, you can create e.g. a big snowstorm or drizzling rain.

Part 2: Lighting effects

Our next part is about how to change time and climate (e.g. evening,desert,...) by adding GlobalLightingPaletteEffect to World. Some examples are listed below:

Night

Rules:
	World:
		GlobalLightingPaletteEffect:
			Red: 0.75
			Green: 0.85
			Blue: 1.5
			Ambient: 0.45

Evening

Rules:
	World:
		GlobalLightingPaletteEffect:
			Red: 1.65
			Green: 1.15
			Blue: 0.95
			Ambient: 0.68

Desert

Rules:
	World:
		GlobalLightingPaletteEffect:
			Red: 1
			Green: 1
			Blue: 1
			Ambient: 1.5

Jungle

Rules:
	World:
		GlobalLightingPaletteEffect:
			Red: 1.45
			Green: 1.55
			Blue: 1.1
			Ambient: 0.75

radioactive :radioactive:

Rules:
	World:
		GlobalLightingPaletteEffect:
			Red: 0.75
			Green: 1.35
			Blue: 0.65
			Ambient: 0.85
Property Description
red The red value.
green The green value.
blue The blue value.
ambient The ambient value.

With the help of these values you'll be able to make your map more "living". Again, it's good to play around with the values a bit to find out what looks good.

Part 3: Audio and flash effects

Still not enough? Here are a few tricks how to make sounds and some flashes!

Rain

Please Notice: you'll need a sound file for this.

For this effect, you need to add two things. First one, we'll add your sound to the music: You can just paste this piece of code below Rules:

Rules:
[...]

Music:
	rain: Rain # Defines the rain
		Hidden: true # Should be hidden so noone can play it via music player.

After that, add following lines to Rules:

Rules:
	World:
		MusicPlaylist:
			BackgroundMusic: rain

Start you map and listen to the rain.


Please notice: the following effects need a .lua script and you an appropiate editor for it. For more information, click here.

Go into your maps folder and create a new text file. Name it like your map + .lua (e.g. mapfullofflowers.lua).

Then open it with an appropiate editor. Paste this code into the file to initiate it:

Tick = function()
	-- Tick function, will be triggered every tick.
end

WorldLoaded = function()
	-- After the world is loaded, this will be triggered.
end

Open the map.yaml again and add following lines to Rules:

Rules:
	World:
		LuaScript:
			Scripts: mapfullofflowers.lua # put your .lua file name here.

Flash :zap:

Paste following code into the .lua file:

Tick = function()
	if (Utils.RandomInteger(1, 200) == 10) then -- if this random number is ten, then...
		local delay = Utils.RandomInteger(1, 10)
		Lighting.Flash("LightningStrike", delay) -- ... the flash appears!
	end
end

If you now run the game, it would crash. The reason is "LightningStrike" isn't defined yet.

Therefore open the map.yaml again and paste following code into Rules:

Rules:
	World:
		FlashPaletteEffect@LIGHTNINGSTRIKE:
			Type: LightningStrike

Thunder

Please Notice: you'll need a sound file for this.

Paste following code into the .lua file:

Tick = function()
	if (Utils.RandomInteger(1, 200) == 10) then -- if this random number is ten, then...
		Media.PlaySound("thunder.aud") -- thunder will be played!
	end
end

Run the game and start the map. Then be quite and listen your thunder!

You might also want to know how to...

... add a new weapon

click here!

... add a new faction

click here!

... create a new unit

click here!


map.yaml? How does this work?!

click here!

Want to learn more about map scripting?

click here!

Resources