Nerd-Rage Modders

Nerd-Rage Modders

Nerd-Rage Modders
 
HomeHomeFAQSearchMemberlistUsergroupsRegisterLog in

Share | 
 

 Adding Night-time and Progressive Fog - CoD:WW only

Go down 
AuthorMessage
Waffles



Posts : 12
Points : 46
Join date : 2010-03-05

PostSubject: Adding Night-time and Progressive Fog - CoD:WW only   Sat Mar 13, 2010 9:29 pm

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:

Download Link

It has to be in this directory: Drive Letter:\Program Files\Activision\Call of Duty - World at War\raw\xmodel

Here is the code required to add Night and Progressive Fog:

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 = maps\mp\gametypes\_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, which is explained here.

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 = maps\mp\gametypes\_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.
Back to top Go down
View user profile
Firemission

avatar

Posts : 28
Points : 1053
Join date : 2010-03-03
Age : 28
Location : Tunbridge Wells,Kent

PostSubject: Re: Adding Night-time and Progressive Fog - CoD:WW only   Sat Mar 13, 2010 9:31 pm

out done ur self nice 1 mate
Back to top Go down
View user profile http://www.southernits.co.uk/
Fixz
Admin


Posts : 18
Points : 1049
Join date : 2010-03-03
Age : 26
Location : Sweden - Julita

PostSubject: Re: Adding Night-time and Progressive Fog - CoD:WW only   Sun Mar 21, 2010 3:14 pm

A screenshot would be nice Very Happy
Back to top Go down
View user profile http://www.xfire.com/communities/nerdragemodders/
irishstorm
Admin
avatar

Posts : 62
Points : 1229
Join date : 2010-03-03
Age : 26
Location : Ireland

PostSubject: Re: Adding Night-time and Progressive Fog - CoD:WW only   Sun Mar 21, 2010 4:28 pm

Nice!
Back to top Go down
View user profile
Sponsored content




PostSubject: Re: Adding Night-time and Progressive Fog - CoD:WW only   

Back to top Go down
 
Adding Night-time and Progressive Fog - CoD:WW only
Back to top 
Page 1 of 1

Permissions in this forum:You cannot reply to topics in this forum
Nerd-Rage Modders :: User Tutorial's :: Modding Tutorial's-
Jump to: