Altering footstep sounds depending on surfaces

Started by WHAM, Thu 29/04/2010 18:56:56

Previous topic - Next topic

WHAM

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)
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Ryan Timothy B

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.

Calin Leafshade

theres a function to do exactly that by strazer

search is your friend

xenogia

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

Calin Leafshade

theres a better one than that

ill find it..


EDIT:

BAM!

Code: ags

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++;
  } 
}

Alan v.Drake

If the view already has sounds linked to frames, you might try mine. I don't remember if it worked right, though.

Code: ags

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++;
	}
	
}

WHAM

Thanks people! I'll try making a few test rooms and see which one I can get to work best for me.
Wrongthinker and anticitizen one. Utterly untrustworthy. Pending removal to memory hole.

Mehrdad

OK.
btw: I have a pretty similar question:
how do i write a sound footsteps in random?(sometimes play sound & and sometimes stop sound)
My official site: http://www.pershaland.com/

SMF spam blocked by CleanTalk