Random Sky/Fx/Lighting Tutorial (FAQ)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Droid Pilot Assassin
User avatar
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am

Random Sky/Fx/Lighting Tutorial (FAQ)

Postby Sky_216 » Wed May 06, 2009 9:44 am

For fairly experienced modders only.


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()

like this:
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

like this:
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


Obviously these are just examples.



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"
}


This calls your fx/lighting files from the "world1" folder. Make several fx files and you can load different ones thru this (ie "AMI", "AMI_Rain"). Copy and rename LGT files and you can load different ones through this (ie "AMI", "AMIgrey")

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"
}


And delete it. Without doing this you can't load different fx files.

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.

Space Ranger
User avatar
Posts: 2559
Joined: Sat Nov 22, 2008 1:50 pm
Location: Washington, US
Projects :: Life. Work.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial

Postby RogueKnight » Wed May 06, 2009 9:46 am

Yes! I am soooo using this in my new "secret" project!

Thanks a lot Sky!

EDIT: You wouldn't happen to know how to add random heros/units too?

Droid Pilot Assassin
User avatar
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am

Re: Random Sky/Fx/Lighting Tutorial

Postby Sky_216 » Wed May 06, 2009 9:49 am

DarthRogueKnight wrote:Yes! I am soooo using this in my new "secret" project!

Thanks a lot Sky!

EDIT: You wouldn't happen to know how to add random heros/units too?


Download and look at Mav's scripts for adding DT era - they include a seperate script to add random heroes/units.

Space Ranger
User avatar
Posts: 2559
Joined: Sat Nov 22, 2008 1:50 pm
Location: Washington, US
Projects :: Life. Work.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial

Postby RogueKnight » Wed May 06, 2009 9:50 am

Ah, ok, thanks a bunch Sky!

Field Commander
User avatar
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Postby YaNkFaN » Wed May 06, 2009 10:10 am

great work sky I currently am working on trying to implement random ground textures or changed ones via loading custom sides but to no effect if I get it working I will post it here. And admins this should definitly be put in the everything you need to know thread.

Droid Pilot Assassin
User avatar
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am

Re: Random Sky/Fx/Lighting Tutorial

Postby Sky_216 » Wed May 06, 2009 10:25 am

@YaNk: you could try to do the following:
Do what I said above with lighting - but for .ter rather than .lgt ie edit in ZE, save, rename the one you just saved, edit again, save again so you have multiple copies.

Then add this bit to lighting + fx + config:

REQN
{
"terrain"
"whateverterrainnameis"
}

And remove the TerrainName line from your .wld file.

No guarantees this'll work but it's worth a try if the sides thing is playing up.

Field Commander
User avatar
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Postby YaNkFaN » Wed May 06, 2009 10:36 am

that may work but would require 2 .ter files so i guess copying them would do the trick but right now it's about actually loading the textures into the game via sides I have the custom side but the game isn't recognizing them or knowing what to do with them. I guess I'll try that when i get home see if it works.

Corporal
User avatar
Posts: 141
Joined: Sat Feb 02, 2008 3:40 am
Location: , Location, Location, Location

Re: Random Sky/Fx/Lighting Tutorial

Postby da_great_ghost » Wed May 06, 2009 11:32 am

So basically this allows you to have random weather/time of day in a map? Purely awesome! But is it like custom skydomes where if played online each player has a different type of enviroment?

Second Lance Corporal
User avatar
Posts: 104
Joined: Thu Aug 23, 2007 8:41 am

Re: Random Sky/Fx/Lighting Tutorial

Postby Superm9 » Wed May 06, 2009 3:39 pm

Thanks so much Sky! I will attempt to implement that now... :bowdown:

Jedi
User avatar
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Random Sky/Fx/Lighting Tutorial

Postby Frisbeetarian » Wed May 06, 2009 4:05 pm

da_great_ghost wrote:But is it like custom skydomes where if played online each player has a different type of enviroment?

Yes

Master of the Force
User avatar
Posts: 4192
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Random Sky/Fx/Lighting Tutorial

Postby Fiodis » Wed May 06, 2009 4:42 pm

At last, random skys explained! Thanks for this, Sky.

Field Commander
User avatar
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Postby YaNkFaN » Wed May 06, 2009 6:25 pm

.ter files can be edited by hexeditor this theoretically means you can make two that read different textures and load them randomly (assuming sky's way works going to try that out now) I don't reccomend making more than 2 random terrains due to the fact that
a) they are each about 28mb each
b) lighting can supplement for small changes needed in textures and lighting is about a 2kb file.

General
User avatar
Posts: 794
Joined: Mon Mar 16, 2009 12:08 pm
Location: Zebra
Projects :: Something big. And exciting.
Games I'm Playing :: Battlefield 3
xbox live or psn: masowner66

Re: Random Sky/Fx/Lighting Tutorial

Postby sampip » Thu May 07, 2009 4:21 am

Whoop! Thanks! I will definitely use this in my new map.
EDIT: NVM those errrors, It's working, and better than that, I fixed it myself (there's a first). That just proves that trying to add random sky for 45 minutes pays off :lol: Now for lighting and fx... :runaway:

2008 Most Technically Challenging Avatar
User avatar
Posts: 2376
Joined: Tue Feb 12, 2008 7:46 pm
Location: NJ, USA
Projects :: No Mod project currently.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial (FAQ)

Postby obiboba3po » Wed May 27, 2009 5:06 pm

sky this is a great find and something original and fun to do in maps. thanks :)

Return to SWBF2 Modding

Who is online

Users browsing this forum: No registered users and 1 guest