C&C Generals: World Builder: Tutorials: Adding Weather Effects

Command & Conquer Generals: Zero Hour: World BuilderTutorial Contributors: Krit and AuroraAlphaHL2

This tutorial explains how to add weather effects to your single-player or multiplayer map for C&C Generals: Zero Hour. Specifically, the tutorial explains how to add snow or rain to your map.

No matter which kind of effect you'd like to add to your map, the first thing to do is to create a text file named map.ini in the folder where your map is located. If you don't know where your map is located, please see this FAQ item: Where are fan maps located?. The map.ini file allows you to create specific settings for your map.

Note: If you are creating a single-player map and wish to add weather effects to it, name this INI file solo.ini instead of map.ini.

Once you have created your map.ini (or solo.ini) file in the proper location, we can add a Weather section to the file. A Weather block allows you to specify custom weather-related settings for your map.


Adding Snow to Your Map

To add snow to your map, paste the following block of code into your INI file (the one described above):

Weather
 SnowEnabled = yes             ; enable/disable snow on the map.
 SnowTexture = ExSnowFlake.tga ; texture used for each snow particle.
 SnowBoxDimensions = 100       ; width/height of box around camera containing snow.
 SnowBoxDensity = 1            ; amount of snow particles per world-unit. Raise to increase particle count.
 SnowFrequencyScaleX = 0.0533  ; speed of side-to-side wave movement.
 SnowFrequencyScaleY = 0.0275  ; speed of side-to-side wave movement. 
 SnowAmplitude = 4.0           ; amount of side-to-side movement. 
 SnowVelocity = 3.0            ; speed at which snow falls
 SnowPointSize = .16           ; scale the size of snow particles.
 SnowMaxPointSize = 10.0       ; maximum pixel size of point sprite particles (min-spec requires <= 64).
 SnowMinPointSize = 0.0        ; minimum pixel size of point sprite particles.

 ;Some video cards can't do hardware accelerated particles.  Set this
 ;setting to "no" in order see what emulation will look like.  Use the
 ;SnowQuadSize setting to make it look similar to PointSprite version.

 SnowPointSprites = yes   ;set to "no" for point-sprite emulation.
 SnowQuadSize = 0.5       ;scale the size of snow particles when using point-sprite emulation.
End

Note that all text following a semicolon (;) on each line is a comment. EA has left some helpful comments in this code which should help explain what each item does. (For reference, this code was copied from the map "Bitter Winter")

Simply pasting the above code into your map.ini or solo.ini file should be enough to add snow to your map. You can also, however, change the settings to your liking to achieve the effect you desire.

Tip: You can change the SnowTexture setting to be either ExSnowFlake.tga or ExSnowFlake1.tga depending on how think or deep you want your snowstorm to look.


Adding Rain to Your Map

The process of adding ran to your map is highly similar to that of adding snow: you basically use a modified version of the snow code, with a different "SnowTexture" setting. Here's an example Weather block that will add rain to your map:

Weather
  SnowEnabled = yes             ;enable/disable snow on the map.
  SnowTexture = EXRainDrop.tga  ;texture used for each snow particle.
  
  SnowBoxDimensions = 100       ;width/height of box around camera containing snow.
  SnowBoxDensity = 1            ;amount of snow particles per world-unit. Raise to increase particle count.
 
  SnowFrequencyScaleX = 1       ;speed of side-to-side wave movement.
  SnowFrequencyScaleY = 1       ;speed of side-to-side wave movement. 
 
  SnowAmplitude = .1            ;amount of side-to-side movement. 
  SnowVelocity = 25.0           ;speed at which snow falls
  SnowPointSize = .3            ;scale the size of snow particles.
 
  ;Some video cards can't do hardware accelerated particles. Set this
  ;setting to "no" in order see what emulation will look like. Use the
  ;SnowQuadSize setting to make it look similar to PointSprite version.;;;

  SnowPointSprites = yes   ;set to "no" for point-sprite emulation.
  SnowQuadSize = .1        ;scale the size of snow particles when using point-sprite emulation.
End

Note that the raindrop texture EXRainDrop.tga is used. (For reference, this code was taken from the "Eastern Everglade" map.ini file.)

If you're adding rain, you'll likely want too have the sound of rain accompanying it, as well as periodic lightning flashes. To do this, you need to add a few scripts to your map.

First, go to the teams list and add a new team called "Rain".

Next we'll begin adding the necessary scripts. The following instructions assume some basic familiarity with World Builder. Alternatively, you can just download World Builder Rain Effects Scripts file and import it into your map in World Builder.

Begin editing the map's scripts by going through the [Edit > Scripts...] menu. Perform the following steps:

  1. Create a folder called "Rain" under the "Rain" main directory and have the "Group is Active" check box ticked.
  2. Create the following scripts:
    • Constantly Raining
      *** IF ***
      True.
      *** THEN ***
      Sound 'RainStereoLoop' play at 60.00% of full volume.
      Sound 'ThunderAmbienceStereo' play at 60.00% of full volume.
      Sound 'ThunderStrikesStereo' play at 60.00% of full volume.
      Play Sound 'RainStereoLoop'.
      Play Sound 'ThunderAmbienceStereo'.
    • Start Lightning
      *** IF ***
      True.
      *** THEN ***
      Set timer 'Lightning' to expire between 10.00 and 20.00 seconds.
      Enable Script 'Time Between Lightning'.
    • Reset Lightning
      *** IF ***
      True.
      *** THEN ***
      Set timer 'Lightning' to expire between 15.00 and 30.00 seconds.
      Enable Script 'Time Between Lightning'.
    • Time Between Lightning
      *** IF ***
      Timer 'Lightning' has expired.
      *** THEN ***
      Set timer 'Flash_Times' to expire between 0 and 4 frames.
      Stop timer 'Flash_Times'
      Set timer 'Between_Flash_Times' to expire between 0 and 6 frames.
      Enable Script 'Reset Lightning'.
    • Lightning
      *** IF ***
      Timer 'Between_Flash_Times' has expired.
      *AND* Counter 'Flash_Times' IS Greater Than 0
      *** THEN ***
      Fade (0-1) from 0.60 to 0.00 adding toward white. Take 1 frames to increase, hold for 2 fames, and decrease 2 frames.
      Set timer 'Between_Flash_Times' to expire between 0 and 5 frames.
      Subtract 1 from counter 'Flash_Times'
      Play Sound 'ThunderStrikesStereo'.
    » All the scripts are to be set as "Script is Active"
    » "Start Lightning", "Reset Lightning" and "Time Between Lightning" are set as "Deactivate upon Success"
    » All check boxes for the [Active in] "Hard", "Medium" and "Easy" are checked


That's it! You should now have snow or rain on your map.

One final tip: you can use a script in World Builder to turn your map's weather effects on or off by overriding the SnowEnabled setting.


Navigation