I'm extremely confused about this. I have a function in my global script (called in rep exec always) that handles the footsteps of player characters:
function HandleFootstepsSound()
{
Region*r = Region.GetAtRoomXY(player.x, player.y);
if (r != region[3]) // normal floor
{
if (player == cLadyW) {
frame1 = Game.GetViewFrame(player.NormalView, player.Loop, 4);
frame1.LinkedAudio = aFemaleFootstep;
frame2 = Game.GetViewFrame(player.NormalView, player.Loop, 9);
frame2.LinkedAudio = aFemaleFootstep;
}
else {
frame1 = Game.GetViewFrame(player.NormalView, player.Loop, 1);
frame1.LinkedAudio = aFootstep_wav;
frame2 = Game.GetViewFrame(player.NormalView, player.Loop, 7);
frame2.LinkedAudio = aFootstep_wav;
}
}
else if (r == region[3]) // carpet
(same thing but with carpet footstep sound, yadda yadda)
(frame1 and frame2 are defined in the Global Variables panel as instances of ViewFrame*.)
This works perfectly well (thanks Vincent! ;)). So well, in fact, that when I have a NPC following the player (as cLadyW) in one specific room, the NPC's footsteps can ALSO be heard. But the NPC does not have any sounds associated to any frames!
But if I change the "else" in line 18 above to
else if (player == cCharlie || player == cSamuels)
Then it works as intended and there is no footsteps sound playing when the NPC is walking (it's supposed to be a ghost/incorporeal/imaginary presence).
I don't understand why this function, which is very clearly linked to "player", should affect NPCs. As I already have found a solution, this post is more about the "why is this happening" than "please help me fix this". Please, oh wise AGSers, enlighten me? :)
Quote from: Laura Hunt on Tue 31/12/2019 10:04:16
But if I change the "else" in line 18 above to
else if (player == cCharlie || player == cSamuels)
Then it works as intended and there is no footsteps sound playing when the NPC is walking (it's supposed to be a ghost/incorporeal/imaginary presence).
Update: no it doesn't. For some reason, it worked the first time I tested it, but now I can hear the NPC's footsteps again.
Might it be that the lines...
frame1 = Game.GetViewFrame(player.NormalView, player.Loop, 4);
frame1.LinkedAudio = aFemaleFootstep;
frame2 = Game.GetViewFrame(player.NormalView, player.Loop, 9);
frame2.LinkedAudio = aFemaleFootstep;
... are assigning the sound to the same frame for ALL characters? Isn't it possible to do something like player.frame1.LinkedAudio? :-\
Alright, so I figured it out.
The problem was here: frame1 = Game.GetViewFrame(player.NormalView, player.Loop, 4)
The NPC was using the same normal view as the player, so of course her frames got assigned the same sound :facepalm:
I created a new separate view for the NPC and copied the player's normal loops there, and now... no footsteps. Tada.
Great I'm glad to hear that you managed to solve it in the end. :)