Merge pull request #500 from universe-st/PR-Branch-cardaudio

增加属性伤害音效逻辑、属性杀音效逻辑
This commit is contained in:
Spmario233 2023-10-10 21:48:52 +08:00 committed by GitHub
commit 351ed7892e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 107 additions and 23 deletions

View File

@ -282,6 +282,17 @@
if(lineColor.length) lib.lineColor.set(nature,lineColor); if(lineColor.length) lib.lineColor.set(nature,lineColor);
lib.nature.set(nature,order); lib.nature.set(nature,order);
if(background.length>0) lib.natureBg.set(nature,background); 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; let color1,color2;
if (typeof config.color=="string"&&/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(config.color)){ if (typeof config.color=="string"&&/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/.test(config.color)){
@ -17978,6 +17989,8 @@
cardaudio=false; cardaudio=false;
} }
if(cardaudio) game.broadcastAll((player,card)=>{ if(cardaudio) game.broadcastAll((player,card)=>{
game.playCardAudio(card,player);
/*
if(!lib.config.background_audio||get.type(card)=='equip'&&!lib.config.equip_audio) return; if(!lib.config.background_audio||get.type(card)=='equip'&&!lib.config.equip_audio) return;
const sex=player.sex=='female'?'female':'male'; const sex=player.sex=='female'?'female':'male';
var nature=get.natureList(card)[0]; 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 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,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`);
} }
else game.playAudio('card',sex,card.name); else game.playAudio('card',sex,card.name);*/
},player,card); },player,card);
if(event.animate!=false&&event.line!=false){ if(event.animate!=false&&event.line!=false){
if(card.name=='wuxie'&&event.getParent()._info_map){ if(card.name=='wuxie'&&event.getParent()._info_map){
@ -18802,6 +18815,8 @@
} }
else if(!event.nopopup) player.tryCardAnimate(card,card.name,'wood'); else if(!event.nopopup) player.tryCardAnimate(card,card.name,'wood');
if(cardaudio&&event.getParent(3).name=='useCard') game.broadcastAll((player,card)=>{ if(cardaudio&&event.getParent(3).name=='useCard') game.broadcastAll((player,card)=>{
game.playCardAudio(card,player);
/*
if(!lib.config.background_audio) return; if(!lib.config.background_audio) return;
const sex=player.sex=='female'?'female':'male',audio=lib.card[card.name].audio; const sex=player.sex=='female'?'female':'male',audio=lib.card[card.name].audio;
if(typeof audio=='string'){ 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 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,`${audioInfo[0]}.${audioInfo[1]||'mp3'}`);
} }
else game.playAudio('card',sex,card.name); else game.playAudio('card',sex,card.name);*/
},player,card); },player,card);
if(event.skill){ if(event.skill){
if(player.stat[player.stat.length-1].skill[event.skill]==undefined){ if(player.stat[player.stat.length-1].skill[event.skill]==undefined){
@ -19548,29 +19563,30 @@
event.trigger('damageBegin4'); event.trigger('damageBegin4');
"step 4" "step 4"
//moved changeHujia to changeHp //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);
}
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')){ if(player.hujia>0 && !player.hasSkillTag('nohujia')){
game.broadcastAll(function(num){ var damageAudioInfo = lib.natureAudio.hujia_damage[event.nature];
if(lib.config.background_audio) game.playAudio('effect','hujia_damage'+(num>1?'2':'')); if(!damageAudioInfo || damageAudioInfo == 'normal'){
},num); 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(damageAudioInfo){
game.broadcastAll(function(num){ if(lib.config.background_audio) game.playAudio(damageAudioInfo);
if(lib.config.background_audio) game.playAudio('effect','damage'+(num>1?'2':'')); },damageAudioInfo);
},num); }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?'视为受到了':'受到了'; var str=event.unreal?'视为受到了':'受到了';
if(source) str+='来自<span class="bluetext">'+(source==player?'自己':get.translation(source))+'</span>的'; if(source) str+='来自<span class="bluetext">'+(source==player?'自己':get.translation(source))+'</span>的';
@ -33942,6 +33958,45 @@
['stab',10], ['stab',10],
['poison',50] ['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'], linked:['fire','thunder','kami','ice'],
natureBg:new Map([ natureBg:new Map([
['stab','image/card/cisha.png'] ['stab','image/card/cisha.png']
@ -35391,6 +35446,35 @@
}; };
ui.window.appendChild(audio); 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:()=>{ playBackgroundMusic:()=>{
if(lib.config.background_music=='music_off'){ if(lib.config.background_music=='music_off'){
ui.backgroundMusic.src=''; ui.backgroundMusic.src='';