Adventure Game Studio

AGS Support => Beginners' Technical Questions => Topic started by: WHAM on Thu 29/04/2010 18:56:56

Title: Altering footstep sounds depending on surfaces
Post by: WHAM on Thu 29/04/2010 18:56:56
I tried the search, but found stuff that referenced AGS 2.55 etc, so I fear those might just be a bit outdated.

Is there a surefire way to alter the character's footstep sounds depending on the surface (region? walkable area?) they are currently on?

Does any such way work even when the character walks due to a blocking script, or is that still impossible? (Probably, but I want to be sure)
Title: Re: Altering footstep sounds depending on surfaces
Post by: Ryan Timothy B on Thu 29/04/2010 19:51:48
There are two ways of doing this (I've never done it myself, I'm reading from the manual and my own knowledge).
1: You can create different walking views with the same graphics, just different sounds for the footsteps.
2: You can manually change them depending on what region they're on by using ViewFrame.LinkedAudio.

The easier approach is to use number 1, if you're not that keen on scripting anything.

As for checking and changing the walking view or changing the ViewFrame.LinkedAudo, it should be done in Repeatedly Execute Always where it'll still change during blocking moments.  Look up repeatedly_execute_always in the manual.
Title: Re: Altering footstep sounds depending on surfaces
Post by: Calin Leafshade on Thu 29/04/2010 20:54:06
theres a function to do exactly that by strazer

search is your friend
Title: Re: Altering footstep sounds depending on surfaces
Post by: xenogia on Thu 29/04/2010 21:46:16
Quote from: Calin Leafshade on Thu 29/04/2010 20:54:06
theres a function to do exactly that by strazer

search is your friend

WHAM here it is, but it is only for AGS 2.72.  So it would require some editing to be fully object-orientated without out the need for using the old-style code.

http://www.adventuregamestudio.co.uk/yabb/index.php?topic=21795.0 (http://www.adventuregamestudio.co.uk/yabb/index.php?topic=21795.0)
Title: Re: Altering footstep sounds depending on surfaces
Post by: Calin Leafshade on Thu 29/04/2010 22:11:57
theres a better one than that

ill find it..


EDIT:

BAM!


void SetWalkingSound(this Character*, int Sound, int Frame, int Frame2){
  int i=0, max=0;
  if(Game.GetLoopCountForView(this.NormalView)<8)  max = Game.GetLoopCountForView(this.NormalView);
  else   max = 8;
  while(i<max){
    frame = Game.GetViewFrame(this.NormalView, i, Frame);
    frame.Sound=Sound;
    if(Frame2!=-1){ 
      frame = Game.GetViewFrame(this.NormalView, i, Frame2);
      frame.Sound=Sound; 
    }
    i++;
  }
}

void RemoveAllWalkingSounds(this Character*){
  int i=0, j=0, max;
  if(Game.GetLoopCountForView(this.NormalView)<8)  max = Game.GetLoopCountForView(this.NormalView);
  else  max = 8;
  while(i<max){
    while(j<Game.GetFrameCountForLoop(this.NormalView, i)){
      frame = Game.GetViewFrame(this.NormalView, i, j);
      frame.Sound=0;
      j++;
    }
    j=0;
    i++;
  }
}
Title: Re: Altering footstep sounds depending on surfaces
Post by: Alan v.Drake on Thu 29/04/2010 22:52:12
If the view already has sounds linked to frames, you might try mine. I don't remember if it worked right, though.


function ChangeFootstepSound(this Character*, int newSound){
ViewFrame *frame;
int i=0, j=0;
int loopCount=0, frameCount=0;

loopCount = Game.GetLoopCountForView(this.NormalView);

while (i < loopCount) {
frameCount = Game.GetFrameCountForLoop(this.NormalView, i);
j = 0;
while (j < frameCount) {
frame = Game.GetViewFrame(this.NormalView, i, j);
if (frame.Sound != 0) frame.Sound = newSound;
j++;
}
i++;
}

}
Title: Re: Altering footstep sounds depending on surfaces
Post by: WHAM on Thu 06/05/2010 13:24:31
Thanks people! I'll try making a few test rooms and see which one I can get to work best for me.
Title: Re: Altering footstep sounds depending on surfaces
Post by: Mehrdad on Thu 06/05/2010 15:02:24
OK.
btw: I have a pretty similar question:
how do i write a sound footsteps in random?(sometimes play sound & and sometimes stop sound)