MV Yanfly FootstepSounds glitch?

I've been using the Yanfly FootstepSounds plugin for a while now and have had an odd experience on some maps with it but I can't seem to pinpoint what's causing the issue.

Step1.png

Step2.png


Step3.png



DEMONSTRATION OF ISSUE



Basically for some reason the tiles I highlighted in red play the Region 3 SE instead of the Region 2/18 SE.
Regardless of what Region I change the Region 3 tiles to, the highlighted tiles will always play the SE of the tiles of the Region I changed the Region 3 tiles to... HOWEVER this doesn't always apply for some reason, as most of the Region 2 tiles function correctly even some located near the Region 3 tiles.


This person had a similar issue to me and I don't really see a solution. My entire game is already mapped out with footstep sound regions but only a very limited number of tiles on a couple maps are causing issues...every other one works just fine.

(It MIGHT be tied to 1 tile thick regions as far as I can tell, but it's awkward to replicate.)

Any help would be appreciated, I hope I provided enough information... I don't feel the need to list off other things I am using since this plugin functions properly in almost every other map.
Huh. Looking at the Yanfly plugin script, there are some very odd lines - it has:

Code:
  var x = this.x;
  if (this.x === 6) {
    x += 1;
  } else if (this.x === 4) {
    x -= 1;
  }
  var y = this.y;
  if (this.y === 2) {
    y += 1;
  } else if (this.y === 8) {
    y -= 1;
  }
  var regionId = $gameMap.regionId(x, y)

As I understand it, that means anything around (or maybe moving to?) x co-ordinate 6 or 4, and y co-ordinate 2 or 8, will act like it's one tile away instead. I'm not sure why it does this, but it would explain why you only get issues around those co-ordinates. You could try commenting out those lines in the plugin to see if it fixes things, maybe? So, just replace it with

Code:
  var x = this.x;
//  if (this.x === 6) {
//    x += 1;
//  } else if (this.x === 4) {
//    x -= 1;
//  }
  var y = this.y;
//  if (this.y === 2) {
//    y += 1;
//  } else if (this.y === 8) {
//    y -= 1;
//  }
  var regionId = $gameMap.regionId(x, y)

and see if that helps... (And hopefully doesn't break anything else).
I don't think that is the problem.
If so the OP should have the same issue all around region 3.
The code you posted refers to directions, not coords. I guess it is because when the character is moving it should use the coords in front of it.


Edit* I just saw that part of code. Yeah you are right, they don't make sense.
The code should check direction of the character but instead it checks x and y?

This is what the code should be:
var x = this.x;
if (this._direction === 6) {
x += 1;
} else if (this._direction === 4) {
x -= 1;
}
var y = this.y;
if (this._direction === 2) {
y += 1;
} else if (this._direction === 8) {
y -= 1;
}
I think I remember there's something funky in the original plugin that mixes up calculation of the next coordinates which was already done elsewhere and some mix up with direction values and coordinates.

Here's a fix I made for another project, see if that works!:

Code:
  //Overwrite - fixes bug of playing the wrong sound
  Game_CharacterBase.prototype.playFootstepSound = function(volume, pitch, pan) {
    if (volume <= 0) return;
    if (pitch <= 0) return;
    if (!$dataMap) return;
    if (!$dataMap.regionFootstepSounds) DataManager.processMapFootstepNotetags();
    var x = this.x;
    var y = this.y;
    var regionId = $gameMap.regionId(x, y)
    var terrainTag = $gameMap.terrainTag(x, y);
    if (regionId > 0) {
      var footstepData = $dataMap.regionFootstepSounds[regionId];
    }
    if (!footstepData && terrainTag > 0) {
      var footstepData = $gameMap.tileset().terrainTagFootstepSounds[terrainTag];
    }
    if (!footstepData) footstepData = $dataMap.regionFootstepSounds[0];
    var se = {
      name:   footstepData[0],
      volume: footstepData[1] * volume,
      pitch:  footstepData[2] * pitch,
      pan:    pan.clamp(-100, 100)
    };
    AudioManager.playSe(se);
  };
I agree with you.

I think the direction check is there because the plugin hooks increaseSteps to play sound.
And increaseSteps is executed after the character is about to take a step forward.
That is the reason it uses the tile in font of the character (or the author thinks it should).

But the logic is incorrect because the position of the character will change the moment the step is taken. For example, if the character is at (1,1) and moves downward, its position will be (1,2) before the walk animation plays.
I think I remember there's something funky in the original plugin that mixes up calculation of the next coordinates which was already done elsewhere and some mix up with direction values and coordinates.

Here's a fix I made for another project, see if that works!:

Code:
  //Overwrite - fixes bug of playing the wrong sound
  Game_CharacterBase.prototype.playFootstepSound = function(volume, pitch, pan) {
    if (volume <= 0) return;
    if (pitch <= 0) return;
    if (!$dataMap) return;
    if (!$dataMap.regionFootstepSounds) DataManager.processMapFootstepNotetags();
    var x = this.x;
    var y = this.y;
    var regionId = $gameMap.regionId(x, y)
    var terrainTag = $gameMap.terrainTag(x, y);
    if (regionId > 0) {
      var footstepData = $dataMap.regionFootstepSounds[regionId];
    }
    if (!footstepData && terrainTag > 0) {
      var footstepData = $gameMap.tileset().terrainTagFootstepSounds[terrainTag];
    }
    if (!footstepData) footstepData = $dataMap.regionFootstepSounds[0];
    var se = {
      name:   footstepData[0],
      volume: footstepData[1] * volume,
      pitch:  footstepData[2] * pitch,
      pan:    pan.clamp(-100, 100)
    };
    AudioManager.playSe(se);
  };


Thank you! It worked perfectly. I was putting this problem off for so long since I couldn't find any documented fixes for it.
I think the direction check is there because the plugin hooks increaseSteps to play sound.
even if direction is hooked somehow, this might not work with reverse controls?
as it would be vice versa, if the if condition is removed and works, why was it
there in the first place?
even if direction is hooked somehow, this might not work with reverse controls?
as it would be vice versa, if the if condition is removed and works, why was it
there in the first place?
Yeah, and there are also fix direction characters.
As for why, who knows? Maybe the code was somewhere else, or a moment of thoughts.:hswt:
If you don't use region sounds or your regions don't overlap with the bugged areas you may not find it.

Original thread: https://forums.rpgmakerweb.com/threads/yanfly-footstepsounds-glitch.176071/