From df204fee0beb3b339c5835a724cd2fa6fee174c5 Mon Sep 17 00:00:00 2001 From: kuangthree Date: Tue, 10 Oct 2023 08:58:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=B1=9E=E6=80=A7=E4=BC=A4?= =?UTF-8?q?=E5=AE=B3=E9=9F=B3=E6=95=88=E9=80=BB=E8=BE=91=E3=80=81=E5=B1=9E?= =?UTF-8?q?=E6=80=A7=E6=9D=80=E9=9F=B3=E6=95=88=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- game/game.js | 130 ++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 107 insertions(+), 23 deletions(-) diff --git a/game/game.js b/game/game.js index 0d9300114..79dfc9331 100644 --- a/game/game.js +++ b/game/game.js @@ -282,6 +282,17 @@ if(lineColor.length) lib.lineColor.set(nature,lineColor); lib.nature.set(nature,order); if(background.length>0) lib.natureBg.set(nature,background); + if(config.audio){ + for(let key in config.audio){ + if(!lib.natureAudio[key]){ + lib.natureAudio[key] = config.audio[key]; + }else{ + for(let key2 in config.audio[key]){ + lib.natureAudio[key][key2] = config.audio[key][key2]; + } + } + } + } let color1,color2; if (typeof config.color=="string"&&/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(config.color)){ @@ -17978,6 +17989,8 @@ cardaudio=false; } if(cardaudio) game.broadcastAll((player,card)=>{ + game.playCardAudio(card,player); + /* if(!lib.config.background_audio||get.type(card)=='equip'&&!lib.config.equip_audio) return; const sex=player.sex=='female'?'female':'male'; var nature=get.natureList(card)[0]; @@ -17992,7 +18005,7 @@ else if(audio.startsWith('ext:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`); else game.playAudio('card',sex,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`); } - else game.playAudio('card',sex,card.name); + else game.playAudio('card',sex,card.name);*/ },player,card); if(event.animate!=false&&event.line!=false){ if(card.name=='wuxie'&&event.getParent()._info_map){ @@ -18802,6 +18815,8 @@ } else if(!event.nopopup) player.tryCardAnimate(card,card.name,'wood'); if(cardaudio&&event.getParent(3).name=='useCard') game.broadcastAll((player,card)=>{ + game.playCardAudio(card,player); + /* if(!lib.config.background_audio) return; const sex=player.sex=='female'?'female':'male',audio=lib.card[card.name].audio; if(typeof audio=='string'){ @@ -18810,7 +18825,7 @@ else if(audio.startsWith('ext:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`); else game.playAudio('card',sex,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`); } - else game.playAudio('card',sex,card.name); + else game.playAudio('card',sex,card.name);*/ },player,card); if(event.skill){ if(player.stat[player.stat.length-1].skill[event.skill]==undefined){ @@ -19548,29 +19563,30 @@ event.trigger('damageBegin4'); "step 4" //moved changeHujia to changeHp - if(['fire','thunder','ice'].contains(event.nature)){ - if(player.hujia>0&&!player.hasSkillTag('nohujia')&&event.nature!='ice'){ - game.broadcastAll(function(num){ - if(lib.config.background_audio) game.playAudio('effect','hujia_damage_'+event.nature+(num>1?'2':'')); - },num); + if(player.hujia>0 && !player.hasSkillTag('nohujia')){ + var damageAudioInfo = lib.natureAudio.hujia_damage[event.nature]; + if(!damageAudioInfo || damageAudioInfo == 'normal'){ + damageAudioInfo = 'effect/hujia_damage'+(num>1?'2':'')+'.mp3'; + }else if(damageAudioInfo == 'default'){ + damageAudioInfo = 'effect/hujia_damage_'+event.nature+(num>1?'2':'')+'.mp3'; + }else{ + damageAudioInfo = damageAudioInfo[num >1 ?2:1]; } - else{ - game.broadcastAll(function(num){ - if(lib.config.background_audio) game.playAudio('effect','damage_'+event.nature+(num>1?'2':'')); - },num); - } - } - else{ - if(player.hujia>0&&!player.hasSkillTag('nohujia')){ - game.broadcastAll(function(num){ - if(lib.config.background_audio) game.playAudio('effect','hujia_damage'+(num>1?'2':'')); - },num); - } - else{ - game.broadcastAll(function(num){ - if(lib.config.background_audio) game.playAudio('effect','damage'+(num>1?'2':'')); - },num); + game.broadcastAll(function(damageAudioInfo){ + if(lib.config.background_audio) game.playAudio(damageAudioInfo); + },damageAudioInfo); + }else{ + var damageAudioInfo = lib.natureAudio.damage[event.nature]; + if(!damageAudioInfo || damageAudioInfo == 'normal'){ + damageAudioInfo = 'effect/damage'+(num>1?'2':'')+'.mp3'; + }else if(damageAudioInfo == 'default'){ + damageAudioInfo = 'effect/damage_'+event.nature+(num>1?'2':'')+'.mp3'; + }else{ + damageAudioInfo = damageAudioInfo[num >1 ?2:1]; } + game.broadcastAll(function(damageAudioInfo){ + if(lib.config.background_audio) game.playAudio(damageAudioInfo); + },damageAudioInfo); } var str=event.unreal?'视为受到了':'受到了'; if(source) str+='来自'+(source==player?'自己':get.translation(source))+'的'; @@ -33940,6 +33956,45 @@ ['stab',10], ['poison',50] ]), + natureAudio:{ + damage:{ + 'fire':'default',//默认,即语音放置在audio/effect下,以damage_fire.mp3 damage_fire2.mp3命名。 + 'thunder':'default', + 'ice':'default', + 'stab':'normal',//正常,即与普通伤害音效相同。 + /* + 'example':{ + 1:'../extension/XXX/damage_example.mp3',//1点伤害。 + 2:'../extension/XXX/damage_example2.mp3',//2点及以上伤害 + } + */ + }, + hujia_damage:{ + 'fire':'default',//默认,即语音放置在audio/effect下,以hujia_damage_fire.mp3 hujia_damage_fire2.mp3命名。 + 'thunder':'default', + 'ice':'normal',//正常,即与普通伤害音效相同。 + /* + 'example':{ + 1:'../extension/XXX/damage_example.mp3',//1点伤害。 + 2:'../extension/XXX/damage_example2.mp3',//2点及以上伤害 + } + */ + }, + sha:{ + 'fire':'default',//默认,即语音放置在audio/card/male与audio/card/female下,命名为sha_fire.mp3 + 'thunder':'default', + 'ice':'default', + 'stab':'default', + 'poison':'normal',//正常,即播放“杀”的音效。 + 'kami':'normal', + /* + 'example':{ + 'male':'../extension/XXXX/sha_example_male.mp3', + 'female':'../extension/XXXX/sha_example_female.mp3' + } + */ + } + }, linked:['fire','thunder','kami','ice'], natureBg:new Map([ ['stab','image/card/cisha.png'] @@ -35405,6 +35460,35 @@ }; ui.window.appendChild(audio); }, + playCardAudio:function(card,sex){ + if(typeof card === 'string'){ + card = {name:card}; + } + if(get.itemtype(sex) === 'player'){ + sex = (sex.sex == 'female'?'female':'male'); + }else if(typeof sex == 'string'){ + sex = (sex == 'female'?'female':'male'); + } + if(!lib.config.background_audio||get.type(card)=='equip'&&!lib.config.equip_audio) return; + var nature=get.natureList(card)[0]; + if(lib.natureAudio[card.name]){ + let shaAudio = lib.natureAudio.sha[nature]; + if(shaAudio === 'default'){ + game.playAudio('card',sex,`${card.name}_${nature}`); + }else if(shaAudio[sex]){ + game.playAudio(shaAudio[sex]); + } + return; + } + const audio=lib.card[card.name].audio; + if(typeof audio=='string'){ + const audioInfo=audio.split(':'); + if(audio.startsWith('db:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,audioInfo[2],`${card.name}_${sex}.${audioInfo[3]||'mp3'}`); + else if(audio.startsWith('ext:')) game.playAudio(`${audioInfo[0]}:${audioInfo[1]}`,`${card.name}_${sex}.${audioInfo[2]||'mp3'}`); + else game.playAudio('card',sex,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`); + } + else game.playAudio('card',sex,card.name); + }, playBackgroundMusic:()=>{ if(lib.config.background_music=='music_off'){ ui.backgroundMusic.src='';