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

Post Reply
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Random Sky/Fx/Lighting Tutorial (FAQ)

Post by Sky_216 »

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.
RogueKnight
Space Ranger
Posts: 2512
Joined: Sat Nov 22, 2008 1:50 pm
Projects :: Life. Work.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set
Location: Washington, US

Re: Random Sky/Fx/Lighting Tutorial

Post by RogueKnight »

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?
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial

Post by Sky_216 »

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.
RogueKnight
Space Ranger
Posts: 2512
Joined: Sat Nov 22, 2008 1:50 pm
Projects :: Life. Work.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set
Location: Washington, US

Re: Random Sky/Fx/Lighting Tutorial

Post by RogueKnight »

Ah, ok, thanks a bunch Sky!
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Post by YaNkFaN »

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.
User avatar
Sky_216
Droid Pilot Assassin
Droid Pilot Assassin
Posts: 2086
Joined: Mon Feb 13, 2006 3:28 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial

Post by Sky_216 »

@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.
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Post by YaNkFaN »

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.
User avatar
da_great_ghost
Corporal
Corporal
Posts: 141
Joined: Sat Feb 02, 2008 3:40 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: , Location, Location, Location

Re: Random Sky/Fx/Lighting Tutorial

Post by da_great_ghost »

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?
User avatar
Superm9
Second Lance Corporal
Second Lance Corporal
Posts: 104
Joined: Thu Aug 23, 2007 8:41 am
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: Random Sky/Fx/Lighting Tutorial

Post by Superm9 »

Thanks so much Sky! I will attempt to implement that now... :bowdown:
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: Random Sky/Fx/Lighting Tutorial

Post by Frisbeetarian »

da_great_ghost wrote:But is it like custom skydomes where if played online each player has a different type of enviroment?
Yes
User avatar
Fiodis
Master of the Force
Master of the Force
Posts: 4145
Joined: Wed Nov 12, 2008 9:27 pm
Projects :: Rannoch + Tientia + Tools Programming

Re: Random Sky/Fx/Lighting Tutorial

Post by Fiodis »

At last, random skys explained! Thanks for this, Sky.
YaNkFaN
Field Commander
Field Commander
Posts: 943
Joined: Sat Dec 13, 2008 8:17 am

Re: Random Sky/Fx/Lighting Tutorial

Post by YaNkFaN »

.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.
User avatar
sampip
General
General
Posts: 792
Joined: Mon Mar 16, 2009 12:08 pm
Projects :: Something big. And exciting.
Games I'm Playing :: Battlefield 3
xbox live or psn: masowner66
Location: Zebra

Re: Random Sky/Fx/Lighting Tutorial

Post by sampip »

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:
obiboba3po
2008 Most Technically Challenging Avatar
Posts: 2376
Joined: Tue Feb 12, 2008 7:46 pm
Projects :: No Mod project currently.
Games I'm Playing :: League of Legends
xbox live or psn: No gamertag set
Location: NJ, USA

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

Post by obiboba3po »

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