Skip to content

Commit

Permalink
Added service voice chance
Browse files Browse the repository at this point in the history
  • Loading branch information
tewlwolow committed Sep 17, 2023
1 parent 06e5c5c commit 7ae544b
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 11 deletions.
29 changes: 18 additions & 11 deletions 00 Core/MWSE/mods/tew/AURA/Service Voices/serviceVoicesMain.lua
Original file line number Diff line number Diff line change
Expand Up @@ -37,21 +37,28 @@ end

local function playServiceVoice(npcId, raceLet, sexLet, serviceFeed)
if #serviceFeed > 0 then
while newVoice == lastVoice or newVoice == nil do
newVoice = serviceFeed[math.random(1, #serviceFeed)]
end
-- Generate a random number between 1 and 100
local randomChance = math.random(1, 100)

-- Check if the random number is less than or equal to the configured chance
if randomChance <= config.serviceChance then
while newVoice == lastVoice or newVoice == nil do
newVoice = serviceFeed[math.random(1, #serviceFeed)]
end

tes3.removeSound { reference = npcId }
tes3.say {
volume = 0.9 * SVvol,
soundPath = string.format("Vo\\%s\\%s\\%s.mp3", raceLet, sexLet, newVoice),
reference = npcId
}
lastVoice = newVoice
debugLog("NPC says a comment for the service.")
tes3.removeSound { reference = npcId }
tes3.say {
volume = 0.9 * SVvol,
soundPath = string.format("Vo\\%s\\%s\\%s.mp3", raceLet, sexLet, newVoice),
reference = npcId
}
lastVoice = newVoice
debugLog("NPC says a comment for the service.")
end
end
end


local function handleServiceGreet(e, voiceData, closeButtonName, playMysticGateSound, playMenuClickSound)
local closeButton = e.element:findChild(tes3ui.registerID(closeButtonName))
if closeButton then
Expand Down
1 change: 1 addition & 0 deletions 00 Core/MWSE/mods/tew/AURA/defaults.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ return {
debugLogOn = false,
volumeSave = {keyCode = tes3.scanCode.v},
tauntChance = 30,
serviceChance = 100,
serviceTravel = true,
serviceRepair = true,
serviceSpells = true,
Expand Down
1 change: 1 addition & 0 deletions 00 Core/MWSE/mods/tew/AURA/i18n/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ this.messages = {
enableEnchantment = "Enable voice comments on enchanting service?",
enableTravel = "Enable voice comments on travel service?",
enableBarter = "Enable voice comments on barter service?",
serviceChance = "Changes % chance for a service comment to play.",

PC = "PC",
PCDesc = "Plays sounds related to the player character.",
Expand Down
1 change: 1 addition & 0 deletions 00 Core/MWSE/mods/tew/AURA/i18n/fr.lua
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ this.messages = {
enableEnchantment = "Activer les commentaires audio sur les services d'enchantement ?",
enableTravel = "Activer les commentaires audio sur les services de voyage ?",
enableBarter = "Activer les commentaires audio sur les services de marchandage ?",
serviceChance = "Change le % de chances qu'une commentaire audio sur les services soit lancée.",

PC = "PJ",
PCDesc = "Joue des sons en fonction du statut du PJ.",
Expand Down
8 changes: 8 additions & 0 deletions 00 Core/MWSE/mods/tew/AURA/mcm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -248,6 +248,14 @@ pageSV:createYesNoButton {
label = messages.enableBarter,
variable = registerVariable("serviceBarter"),
}
pageSV:createSlider {
label = string.format("%s %s = %s%%. %s %%", messages.serviceChance, messages.default, defaults.serviceChance, messages.chance),
min = 0,
max = 100,
step = 1,
jump = 10,
variable = registerVariable("serviceChance")
}
pageSV:createSlider {
label = string.format("%s %s = %s%%. %s %%", messages.SVVol, messages.default, defaults.volumes.misc.SVvol, messages.volume),
min = 0,
Expand Down

0 comments on commit 7ae544b

Please sign in to comment.
  翻译: