This will teach you how to add random sky, environment fx, and lighting to your map.These are very useful to make your map feel different between rounds.
First up, the lua part (this is just the code I use).
Put this inside the ScriptPostLoad() function on the line after "function ScriptPostLoad()" :
Code: Select all
WeatherMode = math.random(1,3)
weather()
Code: Select all
function ScriptPostLoad()
WeatherMode = math.random(1,3)
weather()
--snip
end
Then put this function between ScriptPostLoad() and ScriptInit() :
Code: Select all
function weather()
if WeatherMode == 1 then
ReadDataFile("dc:AMI\\sky.lvl", "cloud")
elseif WeatherMode == 2 then
ReadDataFile("dc:AMI\\sky.lvl", "clear")
elseif WeatherMode == 3 then
ReadDataFile("dc:AMI\\sky.lvl", "rainy")
end
end
Code: Select all
function ScriptPostLoad()
--snip
end
function weather()
if WeatherMode == 1 then
ReadDataFile("dc:AMI\\sky.lvl", "cloud")
elseif WeatherMode == 2 then
ReadDataFile("dc:AMI\\sky.lvl", "clear")
elseif WeatherMode == 3 then
ReadDataFile("dc:AMI\\sky.lvl", "rainy")
end
end
function ScriptInit()
--snip
end
The actual stuff:
Now, have a look at your map's sky file in the "world1" folder. Anything in here will be in all weather modes (I tend to just leave a couple of things like fog range).
Now you need to set up the "sky" lvl. If you look at any space map, there's a "sky" folder in the data_ABC\Worlds\ABC folder. You need a "sky" folder in your data_ABC\Worlds\ABC folder. Probably best to just copy that to your map.
The main req file (called spa_sky in the space maps) calls for the different reqs that load the skies (and fx and lighting if you want). It's name is the name of the lvl loaded through your lua (ie mine was simply "sky").
Inside the REQ folder are the REQ files for each different sky. To add fx/lighting loading to them as well (the "config" part is just the sky file), add this after the config part (which calls for the sky file in the "sky" folder)
Code: Select all
REQN
{
"envfx"
"whateverfxnameis"
}
REQN
{
"light"
"whateverworldlightnameis"
}
The sky files in the "sky" folder tell the map what "extra stuff" (ie different skydomes) to load for each sky setting. Don't load any skydomes in your main sky file (one in the "world1" folder).
To get the fx/lighting thing to work, do this:
Go to your worlds REQ file in world1. Find this part:
Code: Select all
REQN
{
"envfx"
"whateverworldfxnameis"
}
Also open up your maps "wld" file with a text editor like Notepad++, and delete the "LightName" line near the top. This will let you load different lighting files (if you're using them).
Anyway hope this helps a few more modders et up random skies etc.