MZ Have Event Play Repeating SE

Hi all.

Some background: I have an event - a crow. When the crow spots the player, the event tab changes to a page where it starts to fly and pursues the player. All is well to this point.

I want the crow to emit a "flapping" sound while it is pursuing the player, and when the event is deactivated, in other words, when the crow is no longer flying and pursuing the player, the sound should stop.

I generally got it right (by doing a switch and activating a common event) to do this, but if there is more than one crow event, the sound stops for all of them.

Are there any plugins etc that you can suggest or advice? Will appreciate it greatly.
Is there some problem putting playSE in the move routes with the (I assume) move toward player?
You can play a sound effect inside of a moveroute, so instead of setting the crow to approach, you could make a custom moveroute and just use move towards player, then play se. This will loop so long as the crow is following.
Thanks for the answers. I have tried that, but the sound overlaps terribly using that. Perhaps it's just the sound file that I need to trim a bit.
I'd say either:

  1. After the play SE move route command, add a Wait command with a duration about equal to the sound file length.
  2. Install my SFG_Wait and use the WaitForSounds command (currently requires FOSSIL, though I have an MZ-compatible version just pending testing and release) - or if it's in the move route, you can use this.setWaitMode('sound') for the same effect.
  3. Make the flapping sound be a BGS instead of an SE. These loop natively. However, you can only have one, so if you're using BGS for something else on the map, then this becomes difficult.
One way to loop an SE is to use the Event Command to play the SE and then immediately run a script call to overwrite its loop condition (using the SE Battle3 as the example):
JavaScript:
◆Play SE:Battle3 (90, 100, 0)
◆Script:AudioManager._seBuffers.find(a => a._url.includes('Battle3')).play(true);
I am using .find() here in case you have another SE playing that you did not want to loop. You can use .filter() and then run a for-loop to make changes to SEs with the same name but those that start at different times.

The .play() method does take two arguments so setting the first argument to true makes it loop and the second argument is an offset in seconds in terms of the audio's starting place.

At that point, you can stop the SE or run another script call to set the loop to false:
JavaScript:
◆Script:AudioManager._seBuffers.find(a => a._url.includes('Battle3'))._sourceNode.loop = false;
I believe setting it to false will still keep it in memory; it just stops the looping for the SE.

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/have-event-play-repeating-se.181051/