Dynamic Weather

This is a follow up on the weather types, it will change the intensity of the weather.

Open your mapname.csc and add this in the main function.

level.weather_intensity = 0.3;
clientfield::register( "world", "weather_intensity", VERSION_SHIP, 2, "int", &weather_intensity, !CF_HOST_ONLY, !CF_CALLBACK_ZERO_ON_NEW_ENT );

Replace the old while function where the fx got played with this.

while(1)
{
    if(level.weather_intensity == 0)
    {
        wait .1;
        continue;
    }
    PlayFX( localClientNum, SNOW_FX, self.origin );
    wait level.weather_intensity;
}

Now add this function as well.

function weather_intensity( localClientNum, oldVal, newVal, bNewEnt, bInitialSnap, fieldName, bWasTimeJump )
{
    // If value = 0 that will stop the weather
    // Lower the numbers to increase intensity ( Cannot go below 0 )

    switch(newVal)
    {
        case 0:
            level.weather_intensity = 0;
            break;
        case 1:
            level.weather_intensity = 0.3;
            break;
        case 2:
            level.weather_intensity = 0.15;
            break;
        case 3:
            level.weather_intensity = 0.05;
            break;
    }
}

Now we move onto mapname.gsc, add this in the main function.

clientfield::register( "world", "weather_intensity", VERSION_SHIP, 2, "int" );

thread weather_intensity();

And add this function as well.

function weather_intensity()
{
    weather_intensity = 1; // Starting weather type

    while(1)
    {
        wait RandomIntRange(120, 360);
        intensity = RandomInt(4); // Generates a number from 0 - 3

        while(intensity == weather_intensity) // Don't want repeating intensity
        {
            intensity = RandomInt(4);
            WAIT_SERVER_FRAME;
        }

        level clientfield::set("weather_intensity", intensity);
        weather_intensity = intensity;
    }
}