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

USARBot.SoundSensor


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
class SoundSensor extends Sensor config (USARBot);

function String GetData()
{
    local string Outstring;
    local float Distance,tmpLoudness,tmpDuration;
    local float Loudness,Duration;
    local array<USARVictim> Victims;
    local int i;

    Outstring="";
    Victims = USARDeathMatch(Level.Game).Victims;
    for (i=0;i<Victims.length;i++) {
        // no sound
        if (Victims[i].HelpSound==None) Continue;
        // not in sound radius
        Distance = VSize(Victims[i].Location-Location);
        if (Distance>Victims[i].SoundRadius*100) Continue;
        // get loudness
        Distance = Distance/Victims[i].SoundRadius/50;
        if (Distance<1) 
            tmpLoudness=Victims[i].SoundVolume;
        else            
            tmpLoudness = Victims[i].SoundVolume / (Distance*Distance);
        // get duration
        tmpDuration = GetSoundDuration(Victims[i].HelpSound);
        // find the loudest sound
        if (Loudness<tmpLoudness) {
            Loudness = tmpLoudness;
            Duration = tmpDuration;
        }
    }
    Loudness += RandRange(-Noise,Noise)*Loudness;
    Duration += RandRange(-Noise,Noise)*Duration;
    if (Loudness>0)
        Outstring=super.GetData()@"{Loudness "$converter.FloatString(Loudness)$"} {Duration "$converter.FloatString(Duration)$"}";
        
    return Outstring;
}

function String GetConfData()
{
    local string outstring;
    outstring = Super.GetConfData();
    return outstring;
}

defaultproperties
{
    ItemType="Sound"
    OutputCurve=(Points=((InVal=0,OutVal=0),(InVal=1000,OutVal=1000)))
}

Overview Package Class Source Class tree Glossary
previous class      next class frames      no frames
Class file time: Mo 6.2.2006 22:33:48.000 - Creation time: Mo 16.4.2007 11:20:53.515 - Created with UnCodeX