Jump to content
Official BF Editor Forums

Lightning & Other Weather Effects


[EoD]Junglist
 Share

Recommended Posts

WORK IN PROGRESS - FILES NOT ADDED YET - MORE INFO NEEDS ADDING

This tutorial is to explain how to bring weather effects into your Battlefield 2 map.

In this tutorial we will cover adding lightning effects & thunder claps to your map as well as adding rain & snow to a map.

You should have all ready covered these two tutorials before using this one...

1) Creating A Map For Begginers

2) Creating A Map For Intermediate Users

Getting Started

Before you start make sure you download my pack of ambient effects & sounds!

Download Here

Step 1 - Lightning

Ok, so here all that is basically needed is a couple of tweaks to the init.con & the ambientobjects.con files.

What we want to do is to add a lightning effect to the map allond with a delayed clap of thunder.

Firstly open up your maps init.con file.

Now this is what you are basically going to see:

rem *** Generated by BF2Editor ***
if v_arg1 == BF2Editor

run Heightdata.con
LevelSettings.InitWorld
run Terrain.con BF2Editor
run StaticObjects.con BF2Editor
run Sounds.con
run Sky.con BF2Editor
run Editor/GamePlayObjects.con host
UndergrowthEditable.create
Undergrowth.load Levels\YOUR_MAP_NAME\
run Overgrowth/Overgrowth.con
Overgrowth.editorEnable 1
run AmbientObjects.con BF2Editor
run Water.con

else

run Heightdata.con
run Terrain.con v_arg2
run Sky.con v_arg2
run CompiledRoads.con
run Sounds.con
run tmp.con v_arg1
Undergrowth.load Levels\YOUR_MAP_NAME\
run Overgrowth/Overgrowth.con
run Overgrowth/OvergrowthCollision.con
run AmbientObjects.con
run Water.con

endIf

rem ------------------------------- LevelSettings -------------------------------
rem -----------------------------------------------------------------------------

gameLogic.setTeamName 1 "MEC"
gameLogic.setTeamName 2 "US"

gameLogic.setTeamLanguage 1 "Mec"
gameLogic.setTeamLanguage 2 "English"

gameLogic.setTeamFlag 0 "flag_neutral"
gameLogic.setTeamFlag 1 "flag_mec"
gameLogic.setTeamFlag 2 "flag_us"

gameLogic.setKit 1 0 "MEC_Specops" "mec_light_soldier"
gameLogic.setKit 2 0 "US_Specops" "us_light_soldier"

gameLogic.setKit 1 1 "MEC_Sniper" "mec_light_soldier"
gameLogic.setKit 2 1 "US_Sniper" "us_light_soldier"

gameLogic.setKit 1 2 "MEC_Assault" "mec_heavy_soldier"
gameLogic.setKit 2 2 "US_Assault" "us_heavy_soldier"

gameLogic.setKit 1 3 "MEC_Support" "mec_heavy_soldier"
gameLogic.setKit 2 3 "US_Support" "us_heavy_soldier"

gameLogic.setKit 1 4 "MEC_Engineer" "mec_light_soldier"
gameLogic.setKit 2 4 "US_Engineer" "us_light_soldier"

gameLogic.setKit 1 5 "MEC_Medic" "mec_light_soldier"
gameLogic.setKit 2 5 "US_Medic" "us_light_soldier"

gameLogic.setKit 1 6 "MEC_AT" "mec_heavy_soldier"
gameLogic.setKit 2 6 "US_AT" "us_heavy_soldier"

rem -----------------------------------------------------------------------------

gameLogic.setBeforeSpawnCamera -203/157/-27 -28/-12/0

if v_arg1 == BF2Editor
LevelSettings.CustomTextureSuffix ""
else
texturemanager.customTextureSuffix ""
endIf
rem -----------------------------------------------------------------------------

GameLogic.MaximumLevelViewDistance 140

rem -----------------------------------------------------------------------------

gameLogic.setDefaultNumberOfTicketsEx 16 1 100
gameLogic.setDefaultNumberOfTicketsEx 16 2 110
gameLogic.setDefaultNumberOfTicketsEx 32 1 200
gameLogic.setDefaultNumberOfTicketsEx 32 2 220
gameLogic.setDefaultNumberOfTicketsEx 64 1 300
gameLogic.setDefaultNumberOfTicketsEx 64 2 330
gameLogic.setDefaultNumberOfTicketsEx 128 1 150
gameLogic.setDefaultNumberOfTicketsEx 128 2 250
gameLogic.setDefaultTimeToNextAIWave 0
gameLogic.setTicketLossAtEndPerMin 200
gameLogic.setTicketLossPerMin 1 12
gameLogic.setTicketLossPerMin 2 6

rem -----------------------------------------------------------------------------

rem -----------------------------------------------------------------------------

renderer.globalStaticMeshLodDistanceScale 1
renderer.globalBundleMeshLodDistanceScale 1
renderer.globalSkinnedMeshLodDistanceScale 1

gameLogic.setTeamDropVehicle 1 "jep_vodnik"
gameLogic.setTeamDropVehicle 2 "usjep_hmmwv"

Now what we want to do, is to add to this a few lines of code.

So under the line of code that says:

"gameLogic.setTicketLossPerMin"

You will notice something like this:

rem -----------------------------------------------------------------------------

rem -----------------------------------------------------------------------------

Now, inbetween these lines we can post some code to help with the lightning.

I've explained the ones you really need to play with to suit your need.

weatherManager.stormEnabled 1

weatherManager.lightningMaxInterval 20 - Maximim interval before strike - low value for testing replace 20 with 300

weatherManager.lightningMinInterval 10 - Minimum interval before strike - low value for testing replace 10 with 240

weatherManager.lightningDuration 0.2 - How long lightning effect will appear to the eye

weatherManager.lightningScale 25/1250 - Length & width of effect

weatherManager.lightningColor 0.85/0.95/1/1 - Lightning colour

weatherManager.lightningMinPos -650/0/650 - Affects where the lightning will occure in the sky

weatherManager.lightningMaxPos -400/0/400 - Affects where the lightning will occure in the sky

weatherManager.lightningBlendOutTIme 0.5

weatherManager.lightningPertubation 20

weatherManager.lightningSegments 25

weatherManager.inFadeSegments 5

weatherManager.lightningGroundPenetration 60

weatherManager.doubleStrikeProbability 0.6 - Chance of a double strike happening

weatherManager.doubleStrikeMinDelay 0.3 - Minimum delay between next strike in a doublestrike

weatherManager.doubleStrikeMaxDelay 0.75 - Maximum delay between next strike in a doublestrike

SkyDome.lightingColor 0.7/0.75/0.8

rem -------------- Sound -----

weatherManager.lightningSFXDelay 0.8 - Delay after effect until thunder sounds

weatherManager.lightningSFXName S_Thunder - Effect name that links to your ambientobjects.con file

So, now you know what the important (For now) parts mean, add the following code...

weatherManager.stormEnabled 1
weatherManager.lightningMaxInterval 300
weatherManager.lightningMinInterval 240
weatherManager.lightningDuration 0.2
weatherManager.lightningScale 25/1250
weatherManager.lightningColor 0.85/0.95/1/1
weatherManager.lightningMinPos -650/0/650
weatherManager.lightningMaxPos -400/0/400
weatherManager.lightningBlendOutTIme 0.5
weatherManager.lightningPertubation 20
weatherManager.lightningSegments 25
weatherManager.inFadeSegments 5
weatherManager.lightningGroundPenetration 60

weatherManager.doubleStrikeProbability 0.6
weatherManager.doubleStrikeMinDelay 0.3
weatherManager.doubleStrikeMaxDelay 0.75

SkyDome.lightingColor 0.7/0.75/0.8

rem -------------- Sound -----

weatherManager.lightningSFXDelay 0.8
weatherManager.lightningSFXName S_Thunder

So now you should have a init.con that resembles this one:

rem *** Generated by BF2Editor ***
if v_arg1 == BF2Editor

run Heightdata.con
LevelSettings.InitWorld
run Terrain.con BF2Editor
run StaticObjects.con BF2Editor
run Sounds.con
run Sky.con BF2Editor
run Editor/GamePlayObjects.con host
UndergrowthEditable.create
Undergrowth.load Levels\YOUR_MAP_NAME\
run Overgrowth/Overgrowth.con
Overgrowth.editorEnable 1
run AmbientObjects.con BF2Editor
run Water.con

else

run Heightdata.con
run Terrain.con v_arg2
run Sky.con v_arg2
run CompiledRoads.con
run Sounds.con
run tmp.con v_arg1
Undergrowth.load Levels\YOUR_MAP_NAME\
run Overgrowth/Overgrowth.con
run Overgrowth/OvergrowthCollision.con
run AmbientObjects.con
run Water.con

endIf

rem ------------------------------- LevelSettings -------------------------------
rem -----------------------------------------------------------------------------

gameLogic.setTeamName 1 "MEC"
gameLogic.setTeamName 2 "US"

gameLogic.setTeamLanguage 1 "Mec"
gameLogic.setTeamLanguage 2 "English"

gameLogic.setTeamFlag 0 "flag_neutral"
gameLogic.setTeamFlag 1 "flag_mec"
gameLogic.setTeamFlag 2 "flag_us"

gameLogic.setKit 1 0 "MEC_Specops" "mec_light_soldier"
gameLogic.setKit 2 0 "US_Specops" "us_light_soldier"

gameLogic.setKit 1 1 "MEC_Sniper" "mec_light_soldier"
gameLogic.setKit 2 1 "US_Sniper" "us_light_soldier"

gameLogic.setKit 1 2 "MEC_Assault" "mec_heavy_soldier"
gameLogic.setKit 2 2 "US_Assault" "us_heavy_soldier"

gameLogic.setKit 1 3 "MEC_Support" "mec_heavy_soldier"
gameLogic.setKit 2 3 "US_Support" "us_heavy_soldier"

gameLogic.setKit 1 4 "MEC_Engineer" "mec_light_soldier"
gameLogic.setKit 2 4 "US_Engineer" "us_light_soldier"

gameLogic.setKit 1 5 "MEC_Medic" "mec_light_soldier"
gameLogic.setKit 2 5 "US_Medic" "us_light_soldier"

gameLogic.setKit 1 6 "MEC_AT" "mec_heavy_soldier"
gameLogic.setKit 2 6 "US_AT" "us_heavy_soldier"

rem -----------------------------------------------------------------------------

gameLogic.setBeforeSpawnCamera -203/157/-27 -28/-12/0

if v_arg1 == BF2Editor
LevelSettings.CustomTextureSuffix ""
else
texturemanager.customTextureSuffix ""
endIf
rem -----------------------------------------------------------------------------

GameLogic.MaximumLevelViewDistance 140

rem -----------------------------------------------------------------------------

gameLogic.setDefaultNumberOfTicketsEx 16 1 100
gameLogic.setDefaultNumberOfTicketsEx 16 2 110
gameLogic.setDefaultNumberOfTicketsEx 32 1 200
gameLogic.setDefaultNumberOfTicketsEx 32 2 220
gameLogic.setDefaultNumberOfTicketsEx 64 1 300
gameLogic.setDefaultNumberOfTicketsEx 64 2 330
gameLogic.setDefaultNumberOfTicketsEx 128 1 150
gameLogic.setDefaultNumberOfTicketsEx 128 2 250
gameLogic.setDefaultTimeToNextAIWave 0
gameLogic.setTicketLossAtEndPerMin 200
gameLogic.setTicketLossPerMin 1 12
gameLogic.setTicketLossPerMin 2 6

rem -----------------------------------------------------------------------------

weatherManager.stormEnabled 1
weatherManager.lightningMaxInterval 20
weatherManager.lightningMinInterval 10
weatherManager.lightningDuration 0.2
weatherManager.lightningScale 25/1250
weatherManager.lightningColor 0.85/0.95/1/1
weatherManager.lightningMinPos -650/0/650
weatherManager.lightningMaxPos -400/0/400
weatherManager.lightningBlendOutTIme 0.5
weatherManager.lightningPertubation 20
weatherManager.lightningSegments 25
weatherManager.inFadeSegments 5
weatherManager.lightningGroundPenetration 60

weatherManager.doubleStrikeProbability 0.6
weatherManager.doubleStrikeMinDelay 0.3
weatherManager.doubleStrikeMaxDelay 0.75

SkyDome.lightingColor 0.7/0.75/0.8

rem -------------- Sound -----

weatherManager.lightningSFXDelay 0.8
weatherManager.lightningSFXName S_Thunder

rem -----------------------------------------------------------------------------

renderer.globalStaticMeshLodDistanceScale 1
renderer.globalBundleMeshLodDistanceScale 1
renderer.globalSkinnedMeshLodDistanceScale 1

gameLogic.setTeamDropVehicle 1 "jep_vodnik"
gameLogic.setTeamDropVehicle 2 "usjep_hmmwv"

Save that for now.

Step 2 - Sound

Open up your maps ambientobjects.con file.

Look for the header like this:

rem ************ AmbientSounds ************

Now, we need to add a section under that header like this:

rem [SoundObjectTemplate: S_Thunder]
ObjectTemplate.create Sound S_Thunder
ObjectTemplate.activeSafe Sound S_Thunder
ObjectTemplate.modifiedByUser "jung"
ObjectTemplate.lowSamples 2147483647
ObjectTemplate.mediumSamples 2147483647
ObjectTemplate.soundFilename "levels/YOUR_MAP_NAME/common/sound/levelambients/thunder_1.ogg"
ObjectTemplate.loopCount 0
ObjectTemplate.is3dSound 0
ObjectTemplate.stopType 0
ObjectTemplate.volume 1
ObjectTemplate.pitch 1
ObjectTemplate.pan 0.5
ObjectTemplate.reverbLevel 0
ObjectTemplate.minDistance 300000

Sound.addTrigger S_Thunder

Now look a bit further down the ambientobject.con file and find this line:

if v_arg1 == BF2Editor

Under that, add this:

Object.create S_Thunder
Object.absolutePosition 0.00/200/0.00
Object.rotation 0.000/0.000/0.000
Object.layer 1

Ok, now save!

So, now we need to make a new folder directly in the folder YOUR_MAP_NAME

Add this folder:

common

Inside common add:

sound

Inside sound add:

levelambients

And inside there place the file "thunder_1.ogg" from my download pack (Available at the top of this page).

Step 3 - Sky

Ok, so this would be enough for our map to see some lightning action, but if we want the sky to light up with the lightning we need to look at the sky you are using.

Skies in BF2 can be saved as DXT 5 .dds file.

These files have alpha channels, so the white area is the area that will light up with the lightning effect.

If it's all black, nothing in the sky will light up except the lightning effect.

So if we look at this sky normally:

001.jpg

And at the Alpha Channel:

002.jpg

You can see where the sky will light when the lightning effect happens.

You'll need to understand photoshop and save the sky as 2048 x 512 DXT 5 .dds file.

I'm not the best one to do a tut on how to make an alpha channel like that I'm affraid.

We can use the sky from Operation Harvest located in OperationHarvest/client/common/textures/sky/harvest_sky.dds if you can't make your own.

NOTES

The init.con will remove your weather info if you load the map in the editor so remember to re-add it before you play, or do it at the end of making your map once you pack it all up.

You can get round this by using the tmp.con and weather.con but I'll explain this later on.

So that's pretty much it for the lightning!

Edited by [EoD]Junglist
Link to comment
Share on other sites

There's even code preperation for rain - unfortunately this only does work with the debugger . Harry pioneered in this field:

http://bfeditor.org/forums/index.php?showtopic=5951

Note also that BF2 supports wind . I found those in the debugger:

windManager.globalWindSpeed 10

gives you

windA.jpg

Change the direction with

windManager.globalWindDirection X/Y/Z

windB.jpg

The question remains why some sprites are affected and some are not, though :P I also didn't test yet with the retail EXE.

Edit: windManager does work with the retail EXE ( 1.5 ) , at least in a local game :P Now we only need to find out if the rainManager made it into 1.5 ...

Edit2: No, unfortunately the rainManager doesn't work in 1.5 - too bad :(

Edited by mschoeldgen[Xww2]
Link to comment
Share on other sites

It depends on the 'windAffectionFactor NN' coding in the effect. But despite that all sprites in the above effect have the factor set to similar values not all sprites are affected.

To have global wind in your map , add those lines to your tmp.con:

windManager.globalWindSpeed 10

( where 10 is the speed in meters/second )

and optionally

windManager.globalWindDirection X/Y/Z

where X, Y and Z are the usual 3D coordinates . e.g. 0/-1/0 would make your wind blow right down to the ground .

When running the debugger you can interactively set direction and speed and then take those settings into your tmp.con

Edited by mschoeldgen[Xww2]
Link to comment
Share on other sites

  • Catbox pinned this topic

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

×
×
  • Create New...