SetFogAmount(int, int, object)

Sets the fog amount in the area.

void SetFogAmount(
    int nFogType,
    int nFogAmount,
    object oArea = OBJECT_INVALID
);

Parameters

nFogType

FOG_TYPE_* specifies whether the Sun, Moon, or both fog types are set.

nFogAmount

Specifies the density that the fog is being set to.

oArea

The area to set the fog amount in. (Default: OBJECT_INVALID - caller's area)


Description

Sets the fog amount in the area.

If no valid area (or object) is specified, it uses the area of caller.

If an object other than an area is specified, will use the area that the object is currently in.



Remarks

The maximum fog amount is 200. Minimum is 0.


Version

1.65

Example

// Increase the nighttime fog amount in an area by 10%

void main()
{
    // Determine the area whose fog amount will be increased.
    object oArea = GetObjectByTag("Area_Tag");
    
    // If a valid area was found, increase its nighttime fog amount by 10%
    if(GetIsObjectValid(oArea))
    {
        // Obtain the current nighttime fog amount.
        int iNightTimeFogAmount = GetFogAmount(FOG_TYPE_MOON, oArea);
      
        // Compute 10% of the current fog density (rounded up).
        int i10PercentFogAmount = FloatToInt((IntToFloat(iNightTimeFogAmount) / 10.0) + 0.5);
      
        // Compute the new fog density.
        int iNewFogAmount = iNightTimeFogAmount + i10PercentFogAmount;
      
        // Max density is 200 so ensure the new amount is within the valid range
        if(iNewFogAmount > 200)
        {
            iNewFogAmount = 200;
        }
      
        // Set the area's nighttime fog amount to the new density if the new
        // density is different than the current density.
        if(iNewFogAmount != iNightTimeFogAmount)
        {
            SetFogAmount(FOG_TYPE_MOON, iNewFogAmount, oArea);
        }         
    }
}

See Also

functions:  GetFogAmount | GetFogColor | SetFogColor
constants:  FOG_TYPE_* | FOG_COLOR_*
categories:  Area Functions


author: Mistress, editor: Kookoo, contributor: Axe Murderer