Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames

UnrealI.DynamicAmbientSound


00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
//=============================================================================
// DynamicAmbientSound.
//=============================================================================
class DynamicAmbientSound expands Keypoint;

var() bool       bInitiallyOn;      // Initial state
var() sound      Sounds[6];         // What to play (must be at least one sound)
var() float      playProbability;   // The chance of the sound effect playing
var() float      minReCheckTime;   // Try to restart the sound after (min amount)
var() float      maxReCheckTime;   // Try to restart the sound after (max amount)
var() bool       bDontRepeat;       // Never play two of the same sound in a row
var   bool       soundPlaying;      // Is it currently playing it?
var   float      rePlayTime;
var   int        numSounds;     // The number of sounds available
var   int        lastSound;     // Which sound was played most recently?

function BeginPlay () {
    
    local int i;
    
    // Calculate how many sounds the user specified
    numSounds=6;
    for (i=0; i<6; i++) {
        if (Sounds[i] == None) {
            numSounds=i;
            break;
        }
    }

    lastSound=-1;
    if (bInitiallyOn) {
        // Which sound should be played?
        i = Rand(numSounds);
        PlaySound (Sounds[i], , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        lastSound = i;
    }

    rePlayTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(rePlayTime, False);
}


function Timer () {

    local int i;
    
    if (FRand() <= playProbability) {
    
        // Play the sound
        // Which sound should be played?
        i = Rand(numSounds);
        while( i == lastSound && bDontRepeat && numSounds > 1 )
            i = Rand(numSounds);
        
        PlaySound (Sounds[i], , Float(SoundVolume)/128, , Float(SoundRadius)*25);
        lastSound = i;
    }

    rePlayTime = (maxReCheckTime-minReCheckTime)*FRand() + minReCheckTime;
    SetTimer(rePlayTime, False);
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: za 22-4-2006 12:52:32.000 - Creation time: za 22-4-2006 12:53:45.093 - Created with UnCodeX