1. Psychedelia! In this example, the player-character is hit with a tranquilizer dart. Since resources for visually reinforcing the drug's effect were limited, I was asked to accentuate it using sound, and integrate the change into the existing player-character script. This module excerpt smoothly affects the pitch of MOST sounds in the game, (but not music or dialogue) creating an appropriately global effect. Pitch, volume, and reverb are all changed over time: /** Prepares sounds for downpitching when drugged by a dart.*/ group(Sound) data SoundGroup FoleySounds = "sfx/foley"; case (DartPowerup) { DistortFsFX(none, Distort_Radial, 0.05, 20, 0, 1, 5, 1.65, 1); timerDartEffect.StartTimer(numDartEffectTime, false); FoleySounds.SetPitch(-12, 3); FoleySounds.SetVolume(FoleySounds.GetVolume() * 0.667, 1); SetReverbType(5); SetReverbVolume(0.7); } =============================================================== 2. 3-state looping sound In this example, I had to save SRAM by using a single sound to play for three different states of a fixed hazard. A function with a 3-case switch is used to control the sound in one of three ways depending on the state of the object. Volume and pitch commands change the sound smoothly over time as the state changes. (Indicated by arrows added for this demo) function void functionDamageEffectAssign(state whatstate) { switch (whatstate) { case (Alarm) { detectLaserEffect.Reset(); // detectLaserEffect.Stop(); PrintString("red laser"); ToggleGethitSphere(-1, true); -----> SoundLaserON_lp.SetPitch(1, 1); -----> SoundLaserON_lp.SetVolume(SoundLaserON_lp.GetVolume() * 2, 1); painLaserEffect.MoveRelative(self, posOffset, rotOffset); painLaserEffect.StartEffect(0); texLaserFlipper.SetTextureFrame(1, -1); EnableCollision(); if (boolUseOuchState) { timerOuchDelay.StartTimer( numOuchDelay, false ); } else { PrintString("attack disabled"); ToggleAttackSphere(-1, false); } if (resetOnTime) { resetTimer.Stop(); resetTimer.StartTimer(resetTime, false); } } case (On) { // painLaserEffect.Stop(); painLaserEffect.Reset(); PrintString("blue laser"); ToggleAttackSphere(-1, false); ToggleGethitSphere(-1, true); -----> SoundLaserON_lp.SetPitch(0, 1); -----> SoundLaserON_lp.SetVolume(SoundLaserON_lp.GetVolume() * 0.5, 1); detectLaserEffect.MoveRelative(self, posOffset, rotOffset); detectLaserEffect.StartEffect(0); texLaserFlipper.SetTextureFrame(2, -1); EnableCollision(); } case (Off) { if (boolAnimated) SetAnimationToEnd(); ToggleGethitSphere(-1, false); ToggleAttackSphere(-1, false); // detectLaserEffect.Stop(); detectLaserEffect.Reset(); painLaserEffect.Reset(); // painLaserEffect.Stop(); -----> SoundLaserON_lp.SetVolume(0, 0.5); -----> SoundLaserON_lp.Stop(); DisableCollision(); HideCreature(CreatureSelf(), true); } =============================================================== 3. 4-material breakage switch In this example, I made a generic module for playing a different breaking sound depending on the type of material being broken. Level artists tagged an object for material types (or, in some cases, I did), and that type is used in this switch to play the appropriate sound: function void functionPlaySound(string type) { PrintString(type); switch (type) { case ("glass") soundGlass.SpawnSound(); case ("metal") soundMetal.SpawnSound(); case ("plastic") soundPlastic.SpawnSound(); case ("electrical") soundElectrical.SpawnSound(); } } =============================================================== 4. Sound repeater This module causes a sound to be played a defineable number of times, with settable pitch and volume variation. The parameters are passed to the module from the individual sound's definition file. Playing: sequence Start() { if (NumLayers() == 0) branch Stopped; foreach (i = 0..times.Size()-1) { SetVolume(volume + Random(-volumeVar, volumeVar)); SetPitch(pitch + Random(-pitchVar, pitchVar)); PlayLayer(i); wait times[i]; } branch Stopped; } }