Music while being chased?

Hi, I'm trying to make the chase music stop playing when an enemy stops chasing me.
Making it play is easy; you just need to trigger a common event with the Yep_Event_Chase_Player plugin.
I can do it without this plugin; I would just need a trigger for the common event.
But what I can't figure out is how to make the music stop or fade out when I stop being chased.






Captura de pantalla 2025-11-08 171015.png
Captura de pantalla 2025-11-08 175759.png
You can just add the return common event functionality yourself, I think this works just fine (copy paste in notepad and save as .js file in your plugin folder and add after the Yanfly plugin):

const _myYanflyEdit1_clearChaseSettings = Game_Event.prototype.clearChaseSettings

Game_Event.prototype.clearChaseSettings = function() {
_myYanflyEdit1_clearChaseSettings.call(this);
this._returnCommonEvent = undefined;
};

Game_Event.prototype.endEventChase = function() {
this._chasePlayer = false;
this.setMoveSpeed(this._defaultSpeed);
if (this._alertTimer <= 0) this._alertPlayer = false;
if (this._returnCommonEvent) $gameTemp.reserveCommonEvent(this._returnCommonEvent);
this.startReturnPhase();
};

//
Then put a script in the move route this._returnCommonEvent = X
Thank you so much! It's perfect! Now I can continue; thank you so much!

Original thread: https://forums.rpgmakerweb.com/threads/music-while-being-chased.180929/