From 26fb07426b9fbb7ccdcc4e322eb7053b5e2d74dd Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Tue, 24 Oct 2023 14:47:27 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E5=AE=8C=E5=96=84trySkillAudio=E6=B3=A8?= =?UTF-8?q?=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 60 ++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 20 deletions(-) diff --git a/game/game.js b/game/game.js index 8c7d2e753..c0c82c041 100644 --- a/game/game.js +++ b/game/game.js @@ -36836,13 +36836,22 @@ if(lib.skill.global.includes(skill)&&!lib.skill[skill].forceaudio) return; if(typeof player=='string') player={name:player}; - function getAudioList(skill,player,history,fixedNum){ + /** + * 处理 audioInfo 外的参数 + * @param {String} skill 技能名 + * @param {Object} player 角色 + * @param {Array} audioname audioname历史 + * @param {Array} history 判断deadlock + * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 + * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) + */ + function getAudioList(skill,player,audioname,history,fixedNum){ let info=lib.skill[skill]; if(!info) return []; if(!history) history=[]; - if(history.includes(skill)){//直接跳出 + if(history.includes(skill)){//判断deadlock console.trace(`${skill} in ${history} forms a deadlock`); - if(info.audio!==false) return [[skill]];//标记为playSkillAudio + if(info.audio!==false) return [[skill]]; return []; } history.push(skill); @@ -36855,50 +36864,61 @@ } if(typeof audioInfo=='function') audioInfo=audioInfo(player); - let audioname=''; - if(Array.isArray(info.audioname)&&player){ - if(info.audioname.includes(player.name)) audioname=`_${player.name}`; - else if(info.audioname.includes(player.name1)) audioname=`_${player.name1}`; - else if(info.audioname.includes(player.name2)) audioname=`_${player.name2}`; - } + if(!audioname) audioname=[]; + if(Array.isArray(info.audioname)) audioname.addArray(info.audioname); let audioList=parseAudio(skill,audioInfo,audioname,player,history,fixedNum); if(fixedNum&&fixedNumtotal.addArray(parseAudio(skill,i,audioname,player,history,fixedNum)),[]); } - + if(!['string','number','boolean'].includes(typeof audioInfo)) return []; if(audioInfo===false) return []; - if(typeof audioInfo=='string'&&lib.skill[audioInfo]) return getAudioList(audioInfo,player,history,fixedNum); - audioInfo=String(audioInfo); + if(typeof audioInfo=='string'&&lib.skill[audioInfo]) return getAudioList(audioInfo,player,audioname,history,fixedNum); let audioList=[]; + audioInfo=String(audioInfo); let list=audioInfo.match(/(?:(.*):|^)(true|\d*)(?::(.*)|$)/); if(list&&list[2]){ - list=list.slice(1);//形如[路径,number/true,格式]的形式 - if(list[1]=='true') audioList.add(`${list[0]||'skill'}/${skill}${audioname}.${list[2]||'mp3'}`); + let _audioname=''; + if(audioname.includes(player.name)) _audioname=`_${player.name}`; + else if(audioname.includes(player.name1)) _audioname=`_${player.name1}`; + else if(audioname.includes(player.name2)) _audioname=`_${player.name2}`; + + list=list.slice(1);//[路径,number/true,格式] + if(list[1]=='true') audioList.add(`${list[0]||'skill'}/${skill}${_audioname}.${list[2]||'mp3'}`); else{ list[1]=parseInt(list[1]); for(let i=1;i<=list[1];i++){ - audioList.add(`${list[0]||'skill'}/${skill}${audioname}${i}.${list[2]||'mp3'}`); + audioList.add(`${list[0]||'skill'}/${skill}${_audioname}${i}.${list[2]||'mp3'}`); } } } else audioList.add(`${/(?:^db:|^ext:|\/)/.test(audioInfo)?'':'skill/'}${audioInfo}`); return audioList; } - + let list=getAudioList(skill,player); // console.log(skill,lib.skill[skill]&&lib.skill[skill].audio,list); if(!list.length) return; From 47526cb8b9a8fd22ee45a0adb3b4634f2b5fae0a Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Wed, 25 Oct 2023 16:06:47 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E6=8A=8AtrySkillAudio=E7=9A=84=E5=88=86?= =?UTF-8?q?=E6=9E=90=E5=9C=B0=E5=9D=80=E9=83=A8=E5=88=86=E6=8B=86=E5=88=86?= =?UTF-8?q?=E6=88=90parseSkillAudio?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 64 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 37 insertions(+), 27 deletions(-) diff --git a/game/game.js b/game/game.js index c0c82c041..b7d698ffb 100644 --- a/game/game.js +++ b/game/game.js @@ -36827,24 +36827,25 @@ }); return audio; }, - trySkillAudio:function(skill,player,directaudio,nobroadcast/*,index*/){ - if(!nobroadcast) game.broadcast(game.trySkillAudio,skill,player,directaudio,nobroadcast/*,index*/); - var info=get.info(skill); - if(!info) return; - if(!lib.config.background_speak) return; - if(info.direct&&!directaudio) return; - if(lib.skill.global.includes(skill)&&!lib.skill[skill].forceaudio) return; + /** + * 根据skill中的audio,audioname,audioname2和player来获取音频地址列表 + * @param {String} skill 技能名 + * @param {Player|String} player 角色/角色名 + * @returns {Array} 分析完的语音地址列表 + */ + parseSkillAudio:function(skill,player){ if(typeof player=='string') player={name:player}; + else player={}; /** - * 处理 audioInfo 外的参数 - * @param {String} skill 技能名 - * @param {Object} player 角色 - * @param {Array} audioname audioname历史 - * @param {Array} history 判断deadlock - * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 - * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) - */ + * 处理 audioInfo 外的参数 + * @param {String} skill 技能名 + * @param {Object} player 角色 + * @param {Array} audioname audioname历史 + * @param {Array} history 判断deadlock + * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 + * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) + */ function getAudioList(skill,player,audioname,history,fixedNum){ let info=lib.skill[skill]; if(!info) return []; @@ -36857,7 +36858,7 @@ history.push(skill); let audioInfo=info.audio; - if(info.audioname2&&player){ + if(info.audioname2){ if(info.audioname2[player.name]) audioInfo=info.audioname2[player.name]; else if(info.audioname2[player.name1]) audioInfo=info.audioname2[player.name1]; else if(info.audioname2[player.name2]) audioInfo=info.audioname2[player.name2]; @@ -36875,15 +36876,15 @@ } /** - * 分析 audioInfo 获取音频地址数组 - * @param {String} skill 技能名 - * @param {any} audioInfo info.audio - * @param {Array} audioname 要判断的audioname - * @param {Object} player 角色 - * @param {Array} history 判断deadlock - * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 - * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) - */ + * 分析 audioInfo 获取音频地址数组 + * @param {String} skill 技能名 + * @param {any} audioInfo info.audio + * @param {Array} audioname 要判断的audioname + * @param {Object} player 角色 + * @param {Array} history 判断deadlock + * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 + * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) + */ function parseAudio(skill,audioInfo,audioname,player,history,fixedNum){ if(Array.isArray(audioInfo)){ if(typeof audioInfo[0]=='string'&&typeof audioInfo[1]=='number'){// [audioname, number] @@ -36919,8 +36920,17 @@ return audioList; } - let list=getAudioList(skill,player); - // console.log(skill,lib.skill[skill]&&lib.skill[skill].audio,list); + return getAudioList(skill,player); + }, + trySkillAudio:function(skill,player,directaudio,nobroadcast/*,index*/){ + if(!nobroadcast) game.broadcast(game.trySkillAudio,skill,player,directaudio,nobroadcast/*,index*/); + var info=get.info(skill); + if(!info) return; + if(!lib.config.background_speak) return; + if(info.direct&&!directaudio) return; + if(lib.skill.global.includes(skill)&&!lib.skill[skill].forceaudio) return; + + let list=game.parseSkillAudio(skill,player); if(!list.length) return; // if(index) index=index%list.length||list.length; // let audio=list[index?index-1:Math.floor(Math.random()*list.length)]; From 8777d8d63e26a87ebd082aab4799cf411b877947 Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Wed, 25 Oct 2023 16:43:20 +0800 Subject: [PATCH 3/4] bug fix --- game/game.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/game/game.js b/game/game.js index b7d698ffb..249a324b7 100644 --- a/game/game.js +++ b/game/game.js @@ -36835,7 +36835,7 @@ */ parseSkillAudio:function(skill,player){ if(typeof player=='string') player={name:player}; - else player={}; + else if(get.itemtype(player)!='player') player={}; /** * 处理 audioInfo 外的参数 From 65990f92d12979c197ed2a522df0d189f6d740aa Mon Sep 17 00:00:00 2001 From: kuangshen04 <2832899707@qq.com> Date: Wed, 25 Oct 2023 18:41:53 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E5=AE=8C=E5=96=84=E6=B3=A8=E9=87=8A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/game/game.js b/game/game.js index 249a324b7..dcd94aed3 100644 --- a/game/game.js +++ b/game/game.js @@ -36831,7 +36831,7 @@ * 根据skill中的audio,audioname,audioname2和player来获取音频地址列表 * @param {String} skill 技能名 * @param {Player|String} player 角色/角色名 - * @returns {Array} 分析完的语音地址列表 + * @returns {Array} 分析完的语音地址列表 */ parseSkillAudio:function(skill,player){ if(typeof player=='string') player={name:player}; @@ -36840,11 +36840,11 @@ /** * 处理 audioInfo 外的参数 * @param {String} skill 技能名 - * @param {Object} player 角色 - * @param {Array} audioname audioname历史 - * @param {Array} history 判断deadlock + * @param {Player|{name:string}} player 角色 + * @param {Array} audioname audioname历史 + * @param {Array} history 判断deadlock * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 - * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) + * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) */ function getAudioList(skill,player,audioname,history,fixedNum){ let info=lib.skill[skill]; @@ -36879,11 +36879,11 @@ * 分析 audioInfo 获取音频地址数组 * @param {String} skill 技能名 * @param {any} audioInfo info.audio - * @param {Array} audioname 要判断的audioname - * @param {Object} player 角色 - * @param {Array} history 判断deadlock + * @param {Array} audioname 要判断的audioname + * @param {Player|{name:string}} player 角色 + * @param {Array} history 判断deadlock * @param {Number} fixedNum [audioname, number] 中的第二个参数,用来限制语音数 - * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) + * @returns {Array} 音频地址数组(有需要playSkillAudio的为[skillname]) */ function parseAudio(skill,audioInfo,audioname,player,history,fixedNum){ if(Array.isArray(audioInfo)){