Login x
User Name:
Password:
Social Links Facebook Twitter YouTube Steam RSS News Feeds
Watch MODSonair

Members Online

»
0 Active | 67 Guests
Online:

LATEST FORUM THREADS

»
New BF2 Mod
BF2 General

Tutorials

»
Night Sky and Progressive Fog
Versions: You must be logged in to view history.

A little tutorial showing you how to add a night sky and progressive fog to your mod/map.

Night Time & Progressive Fog

First, you will need to get the night_sphere xmodel, which is either gained from the CoD:WW Mod Tools download 1.0, or from this link:

http://www.fpsextreme.com/cod5/night_sphere.zip


It has to be in this directory: Drive Letter:Program FilesActivisionCall of Duty - World at Warrawxmodel

Here is the code required to add Night and Progressive Fog. It makes use of the createdvar function, which can be replaced with SetDvar and some if statements.

Code:
init()
{
   level.night_enabled          = createdvar( "scr_nighttime", 0, 0, 1, "int" );
   level.fog                   = createdvar( "scr_fog", 0, 0, 1, "int" );
   level.fog_progressive          = createdvar( "scr_progressive_fog", 1, 0, 1, "int" );
   
   level.fog_max_distance          = createdvar( "scr_fog_maxdistance", 1000, 0, 100000000, "int" );
   level.fog_halfway_distance       = createdvar( "scr_fog_halfdistance", 600, 0, 100000000, "int" );
   level.fog_max_height          = createdvar( "scr_fog_maxheight", 600, 0, 100000000, "int" );
   level.fog_halfway_height       = createdvar( "scr_fog_halfheight", 600, 0, 100000000, "int" );
   
   level.red                   = createdvar( "scr_fog_red", 0, 0, 1, "float" );
   level.green                  = createdvar( "scr_fog_green", 0, 0, 1, "float" );
   level.blue                   = createdvar( "scr_fog_blue", 0, 0, 1, "float" );
   
   level.trans_time             = createdvar( "scr_fog_transition_time", 0, 0, 10, "float" );
   
   level.progressive_time           = createdvar( "scr_fog_progressive_interval", 5, 0, 1200, "int" );
   level.progressive_gap           = createdvar( "scr_fog_progressive_gap", 15, 0, 1200, "int" );
   
   if( level.night_enabled == 1 )
      thread Night();
   
   if( level.fog == 1 )
      thread Fog();
}

Night()
{
   level waittill( "prematch_over" );

   level.mapCenter = mapsmpgametypes_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );

   night = Spawn( "script_model", level.mapCenter );
   night SetModel( "night_sphere" );
}

Fog()
{
   level waittill( "prematch_over" );
   
   if( level.fog_progressive != 1 )
         SetVolFog( level.fog_max_distance, level.fog_halfway_distance, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
   else
      thread FogLoop();
}

FogLoop()
{
   level endon( "game_ended" );

   level.maxed = true;
   level.mined = false;
   
   fog = level.fog_max_distance;
   half_fog = level.fog_halfway_distance;
   
   while(1)
   {
      if( level.maxed )
      {
         fog = fog - level.progressive_gap;
         half_fog = half_fog - level.progressive_gap;
         
         SetVolFog( fog, half_fog, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
         
         if( fog <= level.fog_halfway_distance )
         {
            level.maxed = false;
            level.mined = true;
            //iPrintLnBold( "^3Fog is now increasing" );
         }
      }
      
      if( level.mined )
      {
         fog = fog + level.progressive_gap;
         half_fog = half_fog + level.progressive_gap;
         
         SetVolFog( fog, half_fog, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
         
         if( fog >= level.fog_max_distance )
         {
            level.maxed = true;
            level.mined = false;
            //iPrintLnBold( "^3Fog is now decreasing" );
         }
      }
      
      wait level.progressive_time;
   }
}


Code:

   level.night_enabled          = createdvar( "scr_nighttime", 0, 0, 1, "int" );
   level.fog                   = createdvar( "scr_fog", 0, 0, 1, "int" );
   level.fog_progressive          = createdvar( "scr_progressive_fog", 1, 0, 1, "int" );
   
   level.fog_max_distance          = createdvar( "scr_fog_maxdistance", 1000, 0, 100000000, "int" );
   level.fog_halfway_distance       = createdvar( "scr_fog_halfdistance", 600, 0, 100000000, "int" );
   level.fog_max_height          = createdvar( "scr_fog_maxheight", 600, 0, 100000000, "int" );
   level.fog_halfway_height       = createdvar( "scr_fog_halfheight", 600, 0, 100000000, "int" );
   
   level.red                   = createdvar( "scr_fog_red", 0, 0, 1, "float" );
   level.green                  = createdvar( "scr_fog_green", 0, 0, 1, "float" );
   level.blue                   = createdvar( "scr_fog_blue", 0, 0, 1, "float" );
   
   level.trans_time             = createdvar( "scr_fog_transition_time", 0, 0, 10, "float" );
   
   level.progressive_time           = createdvar( "scr_fog_progressive_interval", 5, 0, 1200, "int" );
   level.progressive_gap           = createdvar( "scr_fog_progressive_gap", 15, 0, 1200, "int" );



These lines are used to define variables, using the createdvar function.

Code:

   if( level.night_enabled == 1 )
      thread Night();
   
   if( level.fog == 1 )
      thread Fog();


These IF statements check if the variables equal 1, and if they do then it threads the functions.

Code:
Night()
{
   level waittill( "prematch_over" );

   level.mapCenter = mapsmpgametypes_spawnlogic::findBoxCenter( level.spawnMins, level.spawnMaxs );

   night = Spawn( "script_model", level.mapCenter );
   night SetModel( "night_sphere" );
}



This function waits intil the prematch period is over, and then uses the map centre to spawn the "night_sphere" xmodel. This will cause a massive xmodel to form in front of the skybox, which blocks fog, making it useful for emulating nighttime.

To add the xmodel, this line need to be present in your mods/map's main .csv file:

Code:
xmodel,night_sphere

Code:
Fog()
{
   level waittill( "prematch_over" );
   
   if( level.fog_progressive != 1 )
         SetVolFog( level.fog_max_distance, level.fog_halfway_distance, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
   else
      thread FogLoop();
}



This function waits intil the prematch period is over. Then checks if progressive fog is on, if not sets standard fog. If so then it threads the loop needed for progressive fog.

Code:
FogLoop()
{
   level endon( "game_ended" );

   level.maxed = true;
   level.mined = false;
   
   fog = level.fog_max_distance;
   half_fog = level.fog_halfway_distance;
   
   while(1)
   {
      if( level.maxed )
      {
         fog = fog - level.progressive_gap;
         half_fog = half_fog - level.progressive_gap;
         
         SetVolFog( fog, half_fog, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
         
         if( fog <= level.fog_halfway_distance )
         {
            level.maxed = false;
            level.mined = true;
            //iPrintLnBold( "^3Fog is now increasing" );
         }
      }
      
      if( level.mined )
      {
         fog = fog + level.progressive_gap;
         half_fog = half_fog + level.progressive_gap;
         
         SetVolFog( fog, half_fog, level.fog_max_height, level.fog_halfway_height, level.red, level.green, level.blue, level.trans_time );
         
         if( fog >= level.fog_max_distance )
         {
            level.maxed = true;
            level.mined = false;
            //iPrintLnBold( "^3Fog is now decreasing" );
         }
      }
      
      wait level.progressive_time;
   }
}


This script essentially uses the values set for max fog distance and halfway distance to emulate the effect of fog getting thicker and thinner. When the fog has reached the max distance, it will start decreasing, and vice versa.

Latest Syndicated News

»
Codutility.com up and runn...
Nice, and there still using the logo and template for the screenshots, which...
Codutility.com up and runn...
dundy writes...Quote:Call of Duty modding and mapping is barly alive only a ...
Codutility.com up and runn...
Mystic writes...Quote:It seems to me the like the site is completely dead? ...
Codutility.com up and runn...
It seems to me the like the site is completely dead?

Partners & Friends

»