////-------------------------------- // Project : Dynamic weather script // Map : // // Author : Joshua Wilson // Created : August 1st, 2006 // Edited : August 3rd, 2006 ////-------------------------------- //////////////// //// Functions //============== void init(); void constant(); void weatherCycle(); void callLightning(); //////////////// // Variables //============== //---- allows for the changing of variables on a 'map by map' basis // without the need to change the values in the script // float worldFog = 20000; float clearFog = 20000; float denseFog = 9000; float rainFog = 4500; float stormFog = 1500; vector clearColor; vector fogColor; vector rainColor; vector stormColor; vector workingColor; float workingColorx = 0.75; float workingColory = 0.75; float workingColorz = 0.75; float fvariable = 100; float cvariable = 0.01; float floopDelay = 0.006; float cloopDelay = 0.05; float weatherType; //////////////// // Includes //============== #include "maps/global_scripts/global_common.scr" #include "maps/global_scripts/global_math.scr" #include "maps/global_scripts/global_debugUtils.scr" //////////////// // Functions defined //============== //============================ // init // //============== void init() { clearColor = vectorsetx( clearColor, 0.75 ); clearColor = vectorsety( clearColor, 0.75 ); clearColor = vectorsetz( clearColor, 0.75 ); fogColor = vectorsetx( fogColor, 0.65 ); fogColor = vectorsety( fogColor, 0.65 ); fogColor = vectorsetz( fogColor, 0.65 ); rainColor = vectorsetx( rainColor, 0.45 ); rainColor = vectorsety( rainColor, 0.45 ); rainColor = vectorsetz( rainColor, 0.45 ); stormColor = vectorsetx( stormColor, 0.25 ); stormColor = vectorsety( stormColor, 0.25 ); stormColor = vectorsetz( stormColor, 0.25 ); $world.farplane( clearFog ); $world.farplane_color( clearColor ); $world.farplane_cull( 0 ); wait( 0.1 ); thread weatherCycle(); } //============================ // constant // //============== void constant() { } //============================ // weatherCycle // //============== void weatherCycle() { while( 1 ) { weatherType = randomint( 4 ) + 1; //---- clear weather // if( weatherType == 1 ) { centerprint( "Clear"); $world.weather( "rain", 0 ); float i; for( i = 0.75; workingColorx > i; workingColorx -= cvariable, workingColory -= cvariable, workingColorz -= cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } for( i = 0.75; workingColorx < i; workingColorx += cvariable, workingColory += cvariable, workingColorz += cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } while( worldFog != clearFog ) { if( worldFog > clearFog ) { worldFog -= fvariable; } else if( worldFog < clearFog ) { worldFog += fvariable; } $world.farplane( worldFog ); wait( floopDelay ); } } //---- foggy weather // else if( weatherType == 2 ) { centerprint( "Fog" ); $world.weather( "rain", 0 ); float i; for( i = 0.65; workingColorx > i; workingColorx -= cvariable, workingColory -= cvariable, workingColorz -= cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } for( i = 0.65; workingColorx < i; workingColorx += cvariable, workingColory += cvariable, workingColorz += cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } while( worldFog != denseFog ) { if( worldFog > denseFog ) { worldFog -= fvariable; } else if( worldFog < denseFog ) { worldFog += fvariable; } $world.farplane( worldFog ); wait( floopDelay ); } } //---- rainy weather // else if( weatherType == 3 ) { centerprint( "Rain"); $world.weather( "rain", 200 ); float i; for( i = 0.45; workingColorx > i; workingColorx -= cvariable, workingColory -= cvariable, workingColorz -= cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } for( i = 0.45; workingColorx < i; workingColorx += cvariable, workingColory += cvariable, workingColorz += cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } //---- randomizes whether or not "rain" causes a fog change // float r; r = randomint( 2 ) + 1; while( worldFog != rainFog && r == 1 ) { if( worldFog > rainFog ) { worldFog -= fvariable; } else if( worldFog < rainFog ) { worldFog += fvariable; } $world.farplane( worldFog ); wait( floopDelay ); } } //---- stormy weather // else if( weatherType == 4 ) { centerprint( "Storm"); $world.weather( "rain", 400 ); float i; for( i = 0.25; workingColorx > i; workingColorx -= cvariable, workingColory -= cvariable, workingColorz -= cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } for( i = 0.25; workingColorx < i; workingColorx += cvariable, workingColory += cvariable, workingColorz += cvariable ) { workingColor = vectorsetx( workingColor, workingColorx ); workingColor = vectorsety( workingColor, workingColory ); workingColor = vectorsetz( workingColor, workingColorz ); $world.farplane_color( workingColor ); wait( cloopDelay ); } while( worldFog != stormFog ) { if( worldFog > stormFog ) { worldFog -= fvariable; } else if( worldFog < stormFog ) { worldFog += fvariable; } $world.farplane( worldFog ); wait( floopDelay ); } } float i; i = randomint( 3 ) + 1; float changeInterval; if( i == 1 ) { changeInterval = 12; } else if( i == 2 ) { changeInterval = 18; } else if( i == 3 ) { changeInterval = 24; } wait( changeInterval ); } } //============================ // callLightning - creates lightning to be used during "stormy" weather // //============== void callLightning() { }