From 40dfb97076f95e5170d2d7d07822d198376f2cc5 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sun, 5 May 2024 01:34:28 +0800 Subject: [PATCH 1/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0game.parseDieTextMap?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/game/index.js | 55 +++++++++++++++++++++++++++++ noname/library/element/character.js | 14 ++++++++ noname/library/element/content.js | 34 ++++-------------- 3 files changed, 75 insertions(+), 28 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index 13c0d8608..8b804ee30 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1580,6 +1580,61 @@ export class Game { return getAudioList(skill, { audioname: [], history: [] }, skillInfo); } + /** + * 获取角色死亡时能播放的所有阵亡语音 + * @param { string | Player } player 角色名 + * @returns { any[] } 语音地址列表 + */ + parseDieTextMap(player){ + let name, rawName; + if (typeof player === "string") { + name = player; + rawName = name; + } + else if (get.itemtype(player) === "player") { + // @ts-ignore + name = player.skin.name || player.name; + rawName = player.name; + } + const info = get.character(name), datas = []; + let dieAudios; + if(info && info.dieAudios.length > 0){ + dieAudios = info.dieAudios; + } + //@mengxinzxz写的屎山 + else if(rawName !== name && lib.characterSubstitute[rawName] && lib.characterSubstitute[rawName].some((i) => i[0] == name)){ + const trashes = lib.characterSubstitute[rawName].find((i) => i[0] == name)[1]; + const newCharacter = get.convertedCharacter(['','',0,[],trashes]); + dieAudios = newCharacter.dieAudios; + } + if(dieAudios && dieAudios.length > 0){ + dieAudios.forEach(item => { + let key, file; + if(item.startsWith("ext:")){ + const audioData = item.split(":"); + key = audioData[2]; + file = item; + } + else { + key = item; + file = `die/${item}.mp3`; + } + const data = {key, file} + if(lib.translate[`#${key}:die`]) data.text = lib.translate[`#${key}:die`]; + datas.push(data); + }); + } + else { + const data = { + key: name, + file: `die/${name}.mp3`, + isDefault: true, + } + if(lib.translate[`#${name}:die`]) data.text = lib.translate[`#${name}:die`]; + datas.push(data); + } + return datas; + } /** * * @param { string } skill diff --git a/noname/library/element/character.js b/noname/library/element/character.js index cd9b9eba8..085de4def 100644 --- a/noname/library/element/character.js +++ b/noname/library/element/character.js @@ -145,6 +145,11 @@ export class Character { * @type { string[] } **/ clans = []; + /** + * 武将牌拥有的全部阵亡语音 + * @type { string[] } + **/ + dieAudios = []; /** * 武将牌“无法享受到的主公/地主红利” * @type { string[] } @@ -191,6 +196,7 @@ export class Character { this.clans = []; this.initFilters = []; this.trashBin = []; + this.dieAudios = []; } /** * @param { any[] } trash @@ -248,6 +254,10 @@ export class Character { clans.push(item.slice(5)); } else if (item.startsWith("InitFilter:")) { this.initFilters = item.slice(11).split(":"); + } else if (item.startsWith("die:")){ + this.dieAudios.push(item.slice(4)); + } else if (item.startsWith("die_audio:")){ + this.dieAudios = item.slice(10).split(":"); } else { keptTrashes.push(item); } @@ -369,6 +379,10 @@ export class Character { if (character.initFilters.length > 0) { trashes.push(`InitFilters:${character.initFilters.join(":")}`); } + if (character.dieAudios.length > 0) { + if (character.dieAudios.length === 1) trashes.push(`die:${character.dieAudios[0]}`) + else trashes.push(`die_audio:${character.dieAudios.join(":")}`); + } return new Proxy(trashes.concat(character.trashBin), { set(target, prop, newValue) { diff --git a/noname/library/element/content.js b/noname/library/element/content.js index 5eb0e0dbb..cdba51a66 100644 --- a/noname/library/element/content.js +++ b/noname/library/element/content.js @@ -8786,38 +8786,16 @@ export const Content = { _status.dying.remove(player); if (lib.config.background_speak) { - const name = player.skin.name || player.name; - const goon = !lib.character[name]; - if (goon) - lib.character[name] = [ - "", - "", - 0, - [], - ((lib.characterSubstitute[player.name] || []).find((i) => i[0] == name) || [ - name, - [], - ])[1], - ]; - if (lib.character[name][4].some((tag) => /^die:.+$/.test(tag))) { - var tag = lib.character[name][4].find((tag) => /^die:.+$/.test(tag)); - var reg = new RegExp("^ext:(.+)?/"); - var match = tag.match(/^die:(.+)$/); - if (match) { - var path = match[1]; - if (reg.test(path)) path = path.replace(reg, (_o, p) => `../extension/${p}/`); - game.playAudio(path); - } - } else if (lib.character[name][4].some((tag) => tag.startsWith("die_audio"))) { - var tag = lib.character[name][4].find((tag) => tag.startsWith("die_audio")); - var list = tag.split(":").slice(1); - game.playAudio("die", list.length ? list.randomGet() : name); - } else { + const audios = game.parseDieTextMap(player).randomGet(); + if (audios.isDefault) { + const name = audios.key; game.playAudio("die", name, function () { game.playAudio("die", name.slice(name.indexOf("_") + 1)); }); } - if (goon) delete lib.character[name]; + else{ + game.playAudio(audios.file); + } } }, player); From bb7074575482e9e5c1ae82475966f2a46d18fd89 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sun, 5 May 2024 01:49:05 +0800 Subject: [PATCH 2/4] minor fix --- noname/game/index.js | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/noname/game/index.js b/noname/game/index.js index 8b804ee30..1ad182e66 100644 --- a/noname/game/index.js +++ b/noname/game/index.js @@ -1611,8 +1611,7 @@ export class Game { dieAudios.forEach(item => { let key, file; if(item.startsWith("ext:")){ - const audioData = item.split(":"); - key = audioData[2]; + key = item.slice(4).split("/")[1]; file = item; } else { From 1ec302fd7e7410f8913120e1fec0aafca721f99e Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sun, 5 May 2024 11:06:07 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E5=A4=9A=E9=87=8D?= =?UTF-8?q?=E9=98=B5=E4=BA=A1=E5=8F=B0=E8=AF=8D=E7=9A=84UI=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- character/clan/voices.js | 4 +++- noname/ui/click/index.js | 26 +++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/character/clan/voices.js b/character/clan/voices.js index dd6a012d4..ec928239a 100644 --- a/character/clan/voices.js +++ b/character/clan/voices.js @@ -94,7 +94,9 @@ export default { "#clanxieshu2": "我有佐国之术,可缚苍龙。", "#clanbaozu_clan_zhonghui1": "不为刀下脍,且做俎上刀。", "#clanbaozu_clan_zhonghui2": "吾族恒大,谁敢欺之?", - "#clan_zhonghui:die": "谋事在人,成事在天……", + "#clan_zhonghui:die": "兵来似欲作恶,当云何?", + "#clan_zhonghui2:die": "伯约误我!", + "#clan_zhonghui3:die": "谋事在人,成事在天……", "#clanjiejian1": "庙胜之策,不临矢石。", "#clanjiejian2": "王者之兵,有征无战。", "#clanhuanghan1": "居天子阶下,故诚惶诚恐。", diff --git a/noname/ui/click/index.js b/noname/ui/click/index.js index 97c59fd88..894037813 100644 --- a/noname/ui/click/index.js +++ b/noname/ui/click/index.js @@ -3633,19 +3633,20 @@ export class Click { htmlParser.innerHTML = get.characterIntro(name); Array.from(htmlParser.childNodes).forEach((value) => introduction.appendChild(value)); //添加技能语音部分 - const dieAudio = lib.translate[`#${name}:die`]; + const dieAudios = game.parseDieTextMap(name).filter(i => "text" in i); const skillAudioMap = new Map(); nameInfo.skills.forEach(skill => { const voiceMap = game.parseSkillText(skill, name, null, true); if(voiceMap.length) skillAudioMap.set(skill, voiceMap); }); - if (dieAudio || skillAudioMap.size > 0){ + if (dieAudios.length || skillAudioMap.size > 0){ introduction.appendChild(document.createElement("hr")); - const skillNameSpan = document.createElement("span"); - skillNameSpan.innerHTML = `技能台词
`; - introduction.appendChild(skillNameSpan); if(skillAudioMap.size > 0){ + const skillNameSpan = document.createElement("span"); + skillNameSpan.innerHTML = `技能台词
`; + introduction.appendChild(skillNameSpan); + skillAudioMap.forEach((texts, skill) => { const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style; skillNameSpanStyle.fontWeight = "bold"; @@ -3658,15 +3659,18 @@ export class Click { }) }); } - if(dieAudio){ + + if(dieAudios.length > 0){ const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style; skillNameSpanStyle.fontWeight = "bold"; - skillNameSpan.innerHTML = `
阵亡台词
`; + skillNameSpan.innerHTML = `
阵亡台词`; introduction.appendChild(skillNameSpan); - - const skillTextSpan = document.createElement("span"); - skillTextSpan.innerHTML = `${dieAudio}`; - introduction.appendChild(skillTextSpan); + + dieAudios.forEach((item, index) => { + const dieTextSpan = document.createElement("span"); + dieTextSpan.innerHTML = `
${dieAudios.length > 1 ? `${index + 1}. ` : ''}${item.text}`; + introduction.appendChild(dieTextSpan); + }) } } const introduction2 = ui.create.div(".characterintro.intro2", uiintro); From a871208475917a742aac8b2dea44e557c027a9a8 Mon Sep 17 00:00:00 2001 From: Spmario233 Date: Sun, 5 May 2024 11:07:28 +0800 Subject: [PATCH 4/4] =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- noname/ui/click/index.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/noname/ui/click/index.js b/noname/ui/click/index.js index 894037813..fec5835d3 100644 --- a/noname/ui/click/index.js +++ b/noname/ui/click/index.js @@ -3639,16 +3639,17 @@ export class Click { const voiceMap = game.parseSkillText(skill, name, null, true); if(voiceMap.length) skillAudioMap.set(skill, voiceMap); }); - if (dieAudios.length || skillAudioMap.size > 0){ + if (dieAudios.length || skillAudioMap.size > 0) { introduction.appendChild(document.createElement("hr")); - if(skillAudioMap.size > 0){ + if (skillAudioMap.size > 0) { const skillNameSpan = document.createElement("span"); skillNameSpan.innerHTML = `技能台词
`; introduction.appendChild(skillNameSpan); skillAudioMap.forEach((texts, skill) => { - const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style; + const skillNameSpan = document.createElement("span"), + skillNameSpanStyle = skillNameSpan.style; skillNameSpanStyle.fontWeight = "bold"; skillNameSpan.innerHTML = `
${get.translation(skill)}
`; introduction.appendChild(skillNameSpan); @@ -3656,21 +3657,22 @@ export class Click { const skillTextSpan = document.createElement("span"); skillTextSpan.innerHTML = `${index + 1}. ${text}
`; introduction.appendChild(skillTextSpan); - }) + }); }); } - if(dieAudios.length > 0){ - const skillNameSpan = document.createElement("span"), skillNameSpanStyle = skillNameSpan.style; + if (dieAudios.length > 0) { + const skillNameSpan = document.createElement("span"), + skillNameSpanStyle = skillNameSpan.style; skillNameSpanStyle.fontWeight = "bold"; skillNameSpan.innerHTML = `
阵亡台词`; introduction.appendChild(skillNameSpan); dieAudios.forEach((item, index) => { const dieTextSpan = document.createElement("span"); - dieTextSpan.innerHTML = `
${dieAudios.length > 1 ? `${index + 1}. ` : ''}${item.text}`; + dieTextSpan.innerHTML = `
${dieAudios.length > 1 ? `${index + 1}. ` : ""}${item.text}`; introduction.appendChild(dieTextSpan); - }) + }); } } const introduction2 = ui.create.div(".characterintro.intro2", uiintro);