Footstep Sounds connected to an Animation's Frames?

Hi! I'm using Galv's Region Effects, Victor's Character Control, Victor's Multi-Frame Sprites, and GaryCXJk's Free Movement script, as well as many others that hopefully won't be relevant. What I'm trying to do is connect these scripts, so that a region effect happens during a particular frame of a sprite while walking in a particular region.

To be specific, I'm doing footstep sounds, and I want a foot step sound, via Galv's Region Effects, whenever the player is walking (checked by the Character Control script), on two particular frames out of 8 for the walk cycle, in a particular region, to play. This actually already works without being connected to frames, but because I'm using the Free Movement script, the sound currently plays constantly as the player walks, in a semi-hilarious way. That's why I want it to be triggered by the animation's frames, instead of just movement.

I'm no coder. Not even slightly. However, I *asked* a coder, who said this should be pretty easy to do. Hopefully he's right, and someone can come through for me. Thanks for reading, and for any help you can give me.
Bump.
I may not have been around this past month plus some, but I never forgot about this! I took Ruby coding classes online lately and just couldn't get very far. I understand the very very basics, but utilizing them and learning more complex concepts seems beyond reach, sadly. So hopefully someone can help me out with this.
Bump. Still need this so it doesn't sound like my character is shuffling with 8 legs. 😛
Bump.

You know, I've been thinking about this situation a lot.
Spoiler: Venting. Feel free to ignore if you don't care.
I want my game to be unique- set apart from default RM in as many ways as possible. But I can't code. I've tried learning coding, time and time again. Both Ruby and Javascript. I just can't understand it. So every time I get stuck, I either have to run to my coding friends to help, or make a request here. But now? My coding friends are gone. Only one is left, and he's so incredibly busy that it wouldn't be right to bother him. And here? It's hopeless. I wait, and I wait, and I wait. Weeks. Months. No-one comes along. And I understand why; my problems are complicated, and no-one wants to deal with them for free. But unless someone does, my game just sits there, unable to progress in any direction because of scripting problems. Environments? I need a modification to a script to make more progress. Sounds? I need this issue here fixed. Lighting? Custom script and a script modification. AI Pathing? Custom script. Puzzle mechanics? Script bug fix. Menus? Script. Etc. Etc. Etc... I'm very frustrated right now, and I feel very little hope of ever being able to complete my game like this. I have no more money to commission anything, either, because I'm injured, potentially disabled, in a country with no free healthcare and heavy disability requirements. So I'm trapped, through no fault of my own. Anyway, if you read this nonsense, thanks. Have a nice day, even if I usually can't. I'll just keep waiting, I guess.
Honestly If you could provide a test project with all the settings for your game, then you might get someone to try. I'm not going to put the effort in to recreate what you did in the hopes that I got it the same as yours with the graphics and configurations.
That's a very good point. Honestly I'm kind of embarrassed about the state of my project right now, what with everything half thrown together. Either way though, I'll upload it now. I actually forget sometimes that people with coding knowledge need a proper environment to work in, because the people I privately ask for coding help *already* have copies of my project.
That's cool. You should also explain where and how to recreate the issue so that it can be focused on and isolated to understand where the problem is and know that it's fixed when a solution is found.
What map, what action. Although it sounds like it occurs everywhere.
Damn. I forgot to paste the link here. Sorry, I was very busy this evening. Don't worry, I set it up so you can't go anywhere except to the region that makes the noise. Just choose Debug Mode, rather than the very janky Story mode. You'll know what to do next. Hopefully. Enjoy the amusing shuffling noise.

I will be watching this thread with great interest in case you guys succeed. 👋

(That is, in case you feel like sharing this functionality to other people...? 😅 )
It took me about two hours to figure out how you made the sounds work.
I've never used Trihans Region maps. This is doing parallax mapping, something I'm hoping to get into, but probably not until my game is finished.

The easier solution I can come up with is to use a timer.
I have not been able to figure out how to get the animation frame, let alone transfer that data to the from Sprite_Character class to Game_Player class.

Ruby:
class Game_Player < Game_Character
  def galv_region_check
    return if Input.trigger?(:C)
    v = rand(10) - rand(10)
    p = rand(40) - rand(40)
    r_id = $game_map.region_id($game_player.x, $game_player.y)
    return if Region_Effects::EFFECT[r_id] == nil
    sound = Region_Effects::EFFECT[r_id][0]
    vol = Region_Effects::EFFECT[r_id][1]
      pit = Region_Effects::EFFECT[r_id][2]
      eve = Region_Effects::EFFECT[r_id][3]
      com_eve = Region_Effects::EFFECT[r_id][4]
      # using a timer
      @timer = 0 if @timer == nil
      @timer += 1
      RPG::SE.new(sound, vol + v, pit + p).play if @timer == 6
      @timer = 0 if @timer >= 6
      if eve > 0
        $game_map.region_event($game_player.x, $game_player.y, eve, Region_Effects::SPAWN_MAP_ID)
      end
      $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  end
end
I'm sorry it took you so long to figure things out. My setup is pretty convoluted, huh? Oh, and the reason you haven't seen the Region Maps script is because I commissioned it personally from Trihan. He's also the person I mentioned in the original post, whom I asked about this. The reason I wish to tie it to frames is so that the sound is synced with the character's foot hitting the ground.

Hmm. I made a thread some time ago asking how to get the animation frame. https://forums.rpgmakerweb.com/index.php?threads/referencing-a-single-frame-of-an-animation.103717/
I never could figure it out, though. Much too complex for me at the time.
Never realized you could get that data from the characterbase class.
Then the answer would be as simple as adding an if statement to the end of the play line.
RPG::SE.new(sound, vol + volume, pit + pitch).play if @pattern == (2 || 6)

However there seems to be two issues preventing this from working properly.
First - the method where the sound is played is checked twice. Making the sounds play back to back then a pause then back to back.
Second - the frames are erratic. I can watch the character move and it looks like it stumbles, making me wonder if the correct frames are being called. Yet when I output the pattern value is shows some frames then all the frames. Just weird.
Code:
0
1
"SE: Samulis_Foot_1"
1
2
3
3
4
5
0
0
"Variable 19 = 1"
0
1
"SE: Samulis_Foot_1"
2
2
3
4
4
5
6
6
7
0
0
1
"SE: Samulis_Foot_1"
1
2

For at first I added a simple check on off and it prevented the double sound for the most part, but the sound only played on frame 2 not 6. My timer solution worked better for flow.

*Nevermind - Got it.
My check for pattern == 2 or 6 wasn't working so I broke it up.

This worked fine in my test.
Ruby:
class Game_Player < Game_Character
  def galv_region_check
    return if Input.trigger?(:C)
    v = rand(10) - rand(10)
    p = rand(40) - rand(40)
    r_id = $game_map.region_id($game_player.x, $game_player.y)
    return if Region_Effects::EFFECT[r_id] == nil
    sound = Region_Effects::EFFECT[r_id][0]
    vol = Region_Effects::EFFECT[r_id][1]
    pit = Region_Effects::EFFECT[r_id][2]
    eve = Region_Effects::EFFECT[r_id][3]
    com_eve = Region_Effects::EFFECT[r_id][4]
    @timer = 0 if @timer == nil
    if (@pattern == 2) && @timer == 0
      @timer = 1
      RPG::SE.new(sound, vol + v, pit + p).play
    elsif (@pattern == 6) && @timer == 0
      @timer = 1
      RPG::SE.new(sound, vol + v, pit + p).play
    else
      @timer = 0
    end
    if eve > 0
      $game_map.region_event($game_player.x, $game_player.y, eve, Region_Effects::SPAWN_MAP_ID)
    end
    $game_temp.reserve_common_event(com_eve) unless com_eve == nil
  end
end
Sorry fixed the double condition just now and the wrong value I left in there since I changed it at one point. @Robert-Developer_of_Bis
It works... almost. I had to change

Ruby:
  RPG::SE.new(sound, vol + volume, pit + pitch).play if @pattern == 2 || 6

to

Ruby:
  RPG::SE.new(sound, vol + v, pit + p).play if @pattern == 2 || 6

so it matched the other line. Otherwise it would just crash. And I see the "stumbling" issue you were mentioning. Weird, as I hadn't seen it before now. It seems to be caused by the blinking mechanic, which switches the sprite out for one with closed eyes.

Perhaps the "AMN - Victor Character Control addon" script doesn't account for the current frame when changing sprites?
I had to change
Yes, you copied it before I realized I didn't set it back to normal. I had changed it, but I guess you didn't see that. I tried to '@' you to let you know. If you don't copy it from above again then you can also remove the if conditions at the end of the play statement.
Ah. So you know, if you @ someone in an edit, it doesn't work. Tested it out with Andar a couple years back. Anyway, about the stumbling issue. If you look closely at the sprite when it happens, the eyes are closed. At least I think so. Hard to catch because it only lasts for 6 frames.

I'd ask AMN herself to have a look at the script, but she's busy with real life at the moment. Like, not even coming here for long periods busy. So any chance you can look into it? Otherwise I'll just make a new thread about it.
I think I found the culprit.
When the image gets changed the pattern is reset to 0. (guessing)
This seems to fix it.
Ruby:
class Game_CharacterBase
  def moving_pose
    return if @pose_lock || @pose_walk
    old = @pattern
    @pose_list.clear
    change_pose(walk_stance) if pose_sufix != walk_stance && !dash?
    change_pose(dash_stance) if pose_sufix != dash_stance && dash?
    @pattern = old
  end
end
That seems to have fixed the issue indeed! Thank you so much, Roninator. I can finally check this issue off of my to-do list!

By the way, I plan for this game to be commercial, so I need to know if using these snippets is okay, as long as I credit you.
yes

Original thread: https://forums.rpgmakerweb.com/threads/footstep-sounds-connected-to-an-animations-frames.141885/