把trySkillAudio的分析地址部分拆分成parseSkillAudio

This commit is contained in:
kuangshen04 2023-10-25 16:06:47 +08:00
parent 26fb07426b
commit 47526cb8b9
1 changed files with 37 additions and 27 deletions

View File

@ -36827,24 +36827,25 @@
}); });
return audio; return audio;
}, },
trySkillAudio:function(skill,player,directaudio,nobroadcast/*,index*/){ /**
if(!nobroadcast) game.broadcast(game.trySkillAudio,skill,player,directaudio,nobroadcast/*,index*/); * 根据skill中的audio,audioname,audioname2和player来获取音频地址列表
var info=get.info(skill); * @param {String} skill 技能名
if(!info) return; * @param {Player|String} player 角色/角色名
if(!lib.config.background_speak) return; * @returns {Array} 分析完的语音地址列表
if(info.direct&&!directaudio) return; */
if(lib.skill.global.includes(skill)&&!lib.skill[skill].forceaudio) return; parseSkillAudio:function(skill,player){
if(typeof player=='string') player={name:player}; if(typeof player=='string') player={name:player};
else player={};
/** /**
* 处理 audioInfo 外的参数 * 处理 audioInfo 外的参数
* @param {String} skill 技能名 * @param {String} skill 技能名
* @param {Object} player 角色 * @param {Object} player 角色
* @param {Array} audioname audioname历史 * @param {Array} audioname audioname历史
* @param {Array} history 判断deadlock * @param {Array} history 判断deadlock
* @param {Number} fixedNum [audioname, number] 中的第二个参数用来限制语音数 * @param {Number} fixedNum [audioname, number] 中的第二个参数用来限制语音数
* @returns {Array} 音频地址数组有需要playSkillAudio的为[skillname]) * @returns {Array} 音频地址数组有需要playSkillAudio的为[skillname])
*/ */
function getAudioList(skill,player,audioname,history,fixedNum){ function getAudioList(skill,player,audioname,history,fixedNum){
let info=lib.skill[skill]; let info=lib.skill[skill];
if(!info) return []; if(!info) return [];
@ -36857,7 +36858,7 @@
history.push(skill); history.push(skill);
let audioInfo=info.audio; let audioInfo=info.audio;
if(info.audioname2&&player){ if(info.audioname2){
if(info.audioname2[player.name]) audioInfo=info.audioname2[player.name]; 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.name1]) audioInfo=info.audioname2[player.name1];
else if(info.audioname2[player.name2]) audioInfo=info.audioname2[player.name2]; else if(info.audioname2[player.name2]) audioInfo=info.audioname2[player.name2];
@ -36875,15 +36876,15 @@
} }
/** /**
* 分析 audioInfo 获取音频地址数组 * 分析 audioInfo 获取音频地址数组
* @param {String} skill 技能名 * @param {String} skill 技能名
* @param {any} audioInfo info.audio * @param {any} audioInfo info.audio
* @param {Array} audioname 要判断的audioname * @param {Array} audioname 要判断的audioname
* @param {Object} player 角色 * @param {Object} player 角色
* @param {Array} history 判断deadlock * @param {Array} history 判断deadlock
* @param {Number} fixedNum [audioname, number] 中的第二个参数用来限制语音数 * @param {Number} fixedNum [audioname, number] 中的第二个参数用来限制语音数
* @returns {Array} 音频地址数组有需要playSkillAudio的为[skillname]) * @returns {Array} 音频地址数组有需要playSkillAudio的为[skillname])
*/ */
function parseAudio(skill,audioInfo,audioname,player,history,fixedNum){ function parseAudio(skill,audioInfo,audioname,player,history,fixedNum){
if(Array.isArray(audioInfo)){ if(Array.isArray(audioInfo)){
if(typeof audioInfo[0]=='string'&&typeof audioInfo[1]=='number'){// [audioname, number] if(typeof audioInfo[0]=='string'&&typeof audioInfo[1]=='number'){// [audioname, number]
@ -36919,8 +36920,17 @@
return audioList; return audioList;
} }
let list=getAudioList(skill,player); return getAudioList(skill,player);
// console.log(skill,lib.skill[skill]&&lib.skill[skill].audio,list); },
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(!list.length) return;
// if(index) index=index%list.length||list.length; // if(index) index=index%list.length||list.length;
// let audio=list[index?index-1:Math.floor(Math.random()*list.length)]; // let audio=list[index?index-1:Math.floor(Math.random()*list.length)];