From 7ba2d5e59613ae0c0cf09ce3614db4e529764f15 Mon Sep 17 00:00:00 2001 From: Rintim Date: Sun, 3 Sep 2023 17:33:27 +0800 Subject: [PATCH] support die-audio tag. --- game/game.js | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/game/game.js b/game/game.js index 845465e2a..ab642343a 100644 --- a/game/game.js +++ b/game/game.js @@ -18237,26 +18237,26 @@ game.dead.push(player); _status.dying.remove(player); - if(!lib.config.background_speak) return; - do { - if(!lib.character[player.name]) break; - if(lib.character[player.name][4].some(tag=>/^die:.+$/.test(tag))) { - const tag=lib.character[player.name][4].find(tag=>/^die:.+$/.test(tag)) + if(lib.config.background_speak){ + if(lib.character[player.name]&&lib.character[player.name][4].some(tag=>/^die:.+$/.test(tag))){ + const tag=lib.character[player.name][4].find(tag=>/^die:.+$/.test(tag)); + const reg=new RegExp("^ext:(.+)?/"); const match=tag.match(/^die:(.+)$/); - if (!match) break; - let path=match[1]; - if(/^ext:(.+)/.test(path)) path=path.replace(/^ext:(.+?)\//, (_o,p)=>`../extension/${p}/`); - game.playAudio(path); - return; + if(match){ + let path=match[1]; + if(reg.test(path)) path=path.replace(reg,(_o,p)=>`../extension/${p}/`); + game.playAudio(path); + } } - else if(lib.character[player.name][4].contains('die_audio')){ + else if(lib.character[player.name]&&lib.character[player.name][4].contains('die_audio')){ game.playAudio('die',player.name); - return; } - } while (false); - game.playAudio('die',player.name,function(){ - game.playAudio('die',player.name.slice(player.name.indexOf('_')+1)); - }); + else{ + game.playAudio('die',player.name,function(){ + game.playAudio('die',player.name.slice(player.name.indexOf('_')+1)); + }); + } + } },player); game.addVideo('diex',player);