Adventure Game Studio

AGS Support => Advanced Technical Forum => Topic started by: deltamatrix on Thu 06/11/2003 15:17:53

Title: Can characters generate ambient sounds as they move?
Post by: deltamatrix on Thu 06/11/2003 15:17:53
Well can they?
Title: Re:Can characters generate ambient sounds as they move?
Post by: SSH on Thu 06/11/2003 15:20:28
You can assign a "footstep" sound to a frame of a view. This doesn't have to be a footstep, though.
Title: Re:Can characters generate ambient sounds as they move?
Post by: a-v-o on Thu 06/11/2003 19:21:16
if you mean that the sound volume depends on how close they are to the player character, then there is no comman, but I used this script to produce the effect:

#define MIN_VOLUME     0
#define MAX_VOLUME   255
#define MAX_DISTANCE 160

int volume = 0;

function room_b() {
 // script for room: Repeatedly execute
 int PC = GetPlayerCharacter ();
 int dx = character [GUARD_CHAR].x - character [PC].x;
 if (dx <  0) { dx = -dx; }
 int distance = MAX_DISTANCE - dx;
 int vol = MIN_VOLUME;
 if (distance > 0)
 {
   vol += distance * (MAX_VOLUME - MIN_VOLUME) / MAX_DISTANCE;
 }
 if (volume != vol)
 {
   volume = vol;
   SetSoundVolume (volume);
 }
 if (IsSoundPlaying () <= 0) { PlaySound (97); }
}