Skip to content

Commit 32da054

Browse files
committed
Added support for absolute and relative volume types in Events & Some Refactoring
1 parent 883e1dd commit 32da054

16 files changed

+364
-110
lines changed

src/SoundFX/Events/EventHandlers/ArmorEventHandler.cpp

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "ArmorEventHandler.h"
22
#include "Events/EventHandlerManager.h"
3-
#include "Sound/SoundUtil.h"
3+
#include "Sound/SoundManager.h"
44
#include "Utility.h"
55

66
namespace SoundFX {
@@ -41,7 +41,15 @@ namespace SoundFX {
4141
if (jsonEvent.type == "PickUp") {
4242
if (const float randomValue = GenerateRandomFloat();
4343
randomValue <= jsonEvent.chance) {
44-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
44+
SoundManager::PlaySound(armorEvents.name,
45+
jsonEvent.type,
46+
jsonEvent.soundEffect,
47+
{8029.8643f, -69089.37f, 4815.15f},
48+
100.0f,
49+
1000.0f,
50+
jsonEvent.volume,
51+
jsonEvent.isAbsoluteVolume,
52+
true);
4553
}
4654
return RE::BSEventNotifyControl::kContinue;
4755
}
@@ -80,7 +88,15 @@ namespace SoundFX {
8088
if (jsonEvent.type == "Equip") {
8189
if (const float randomValue = GenerateRandomFloat();
8290
randomValue <= jsonEvent.chance) {
83-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
91+
SoundManager::PlaySound(armorEvents.name,
92+
jsonEvent.type,
93+
jsonEvent.soundEffect,
94+
{8029.8643f, -69089.37f, 4815.15f},
95+
100.0f,
96+
1000.0f,
97+
jsonEvent.volume,
98+
jsonEvent.isAbsoluteVolume,
99+
true);
84100
}
85101
return RE::BSEventNotifyControl::kContinue;
86102
}
@@ -122,7 +138,15 @@ namespace SoundFX {
122138
if (jsonEvent.type == "Unequip") {
123139
if (const float randomValue = GenerateRandomFloat();
124140
randomValue <= jsonEvent.chance) {
125-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
141+
SoundManager::PlaySound(armorEvents.name,
142+
jsonEvent.type,
143+
jsonEvent.soundEffect,
144+
{8029.8643f, -69089.37f, 4815.15f},
145+
100.0f,
146+
1000.0f,
147+
jsonEvent.volume,
148+
jsonEvent.isAbsoluteVolume,
149+
true);
126150
}
127151
return RE::BSEventNotifyControl::kContinue;
128152
}

src/SoundFX/Events/EventHandlers/CellEventHandler.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "CellEventHandler.h"
2-
#include "Sound/SoundUtil.h"
2+
#include "Sound/SoundManager.h"
33
#include "Utility.h"
44

55
namespace SoundFX {
@@ -49,7 +49,15 @@ namespace SoundFX {
4949
if (jsonEvent.type == "Enter") {
5050
if (const float randomValue = GenerateRandomFloat();
5151
randomValue <= jsonEvent.chance) {
52-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
52+
SoundManager::PlaySound(cellEvents.name,
53+
jsonEvent.type,
54+
jsonEvent.soundEffect,
55+
{8029.8643f, -69089.37f, 4815.15f},
56+
100.0f,
57+
1000.0f,
58+
jsonEvent.volume,
59+
jsonEvent.isAbsoluteVolume,
60+
true);
5361
}
5462
return;
5563
}
@@ -90,7 +98,15 @@ namespace SoundFX {
9098
if (jsonEvent.type == "Ambience") {
9199
if (const float randomValue = GenerateRandomFloat();
92100
randomValue <= jsonEvent.chance) {
93-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
101+
SoundManager::PlaySound(cellEvents.name,
102+
jsonEvent.type,
103+
jsonEvent.soundEffect,
104+
{8029.8643f, -69089.37f, 4815.15f},
105+
100.0f,
106+
1000.0f,
107+
jsonEvent.volume,
108+
jsonEvent.isAbsoluteVolume,
109+
true);
94110
}
95111
return;
96112
}

src/SoundFX/Events/EventHandlers/CombatEventHandler.cpp

Lines changed: 55 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "CombatEventHandler.h"
22
#include "Events/EventHandlerManager.h"
3-
#include "Sound/SoundUtil.h"
3+
#include "Sound/SoundManager.h"
44
#include "Utility.h"
55

66
namespace SoundFX {
@@ -53,7 +53,15 @@ namespace SoundFX {
5353
&& event->newState.any(RE::ACTOR_COMBAT_STATE::kCombat)) {
5454
if (const float randomValue = GenerateRandomFloat();
5555
randomValue <= jsonEvent.chance) {
56-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
56+
SoundManager::PlaySound(combatEvents.name,
57+
jsonEvent.type,
58+
jsonEvent.soundEffect,
59+
{8029.8643f, -69089.37f, 4815.15f},
60+
100.0f,
61+
1000.0f,
62+
jsonEvent.volume,
63+
jsonEvent.isAbsoluteVolume,
64+
true);
5765
}
5866
return RE::BSEventNotifyControl::kContinue;
5967
}
@@ -96,7 +104,15 @@ namespace SoundFX {
96104
&& event->newState.any(RE::ACTOR_COMBAT_STATE::kSearching)) {
97105
if (const float randomValue = GenerateRandomFloat();
98106
randomValue <= jsonEvent.chance) {
99-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
107+
SoundManager::PlaySound(combatEvents.name,
108+
jsonEvent.type,
109+
jsonEvent.soundEffect,
110+
{8029.8643f, -69089.37f, 4815.15f},
111+
100.0f,
112+
1000.0f,
113+
jsonEvent.volume,
114+
jsonEvent.isAbsoluteVolume,
115+
true);
100116
}
101117
return RE::BSEventNotifyControl::kContinue;
102118
}
@@ -139,7 +155,15 @@ namespace SoundFX {
139155
&& event->newState == RE::ACTOR_COMBAT_STATE::kNone) {
140156
if (const float randomValue = GenerateRandomFloat();
141157
randomValue <= jsonEvent.chance) {
142-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
158+
SoundManager::PlaySound(combatEvents.name,
159+
jsonEvent.type,
160+
jsonEvent.soundEffect,
161+
{8029.8643f, -69089.37f, 4815.15f},
162+
100.0f,
163+
1000.0f,
164+
jsonEvent.volume,
165+
jsonEvent.isAbsoluteVolume,
166+
true);
143167
}
144168
return RE::BSEventNotifyControl::kContinue;
145169
}
@@ -190,7 +214,15 @@ namespace SoundFX {
190214
&& event->newState == RE::ACTOR_COMBAT_STATE::kNone) {
191215
if (const float randomValue = GenerateRandomFloat();
192216
randomValue <= jsonEvent.chance) {
193-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
217+
SoundManager::PlaySound(combatEvents.name,
218+
jsonEvent.type,
219+
jsonEvent.soundEffect,
220+
{8029.8643f, -69089.37f, 4815.15f},
221+
100.0f,
222+
1000.0f,
223+
jsonEvent.volume,
224+
jsonEvent.isAbsoluteVolume,
225+
true);
194226
}
195227
return RE::BSEventNotifyControl::kContinue;
196228
}
@@ -231,7 +263,15 @@ namespace SoundFX {
231263
if (jsonEvent.type == "Flee") {
232264
if (const float randomValue = GenerateRandomFloat();
233265
randomValue <= jsonEvent.chance) {
234-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
266+
SoundManager::PlaySound(combatEvents.name,
267+
jsonEvent.type,
268+
jsonEvent.soundEffect,
269+
{8029.8643f, -69089.37f, 4815.15f},
270+
100.0f,
271+
1000.0f,
272+
jsonEvent.volume,
273+
jsonEvent.isAbsoluteVolume,
274+
true);
235275
}
236276
return;
237277
}
@@ -275,7 +315,15 @@ namespace SoundFX {
275315
if (const float randomValue = GenerateRandomFloat();
276316
randomValue <= jsonEvent.chance) {
277317
wasInKillMove = true;
278-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
318+
SoundManager::PlaySound(combatEvents.name,
319+
jsonEvent.type,
320+
jsonEvent.soundEffect,
321+
{8029.8643f, -69089.37f, 4815.15f},
322+
100.0f,
323+
1000.0f,
324+
jsonEvent.volume,
325+
jsonEvent.isAbsoluteVolume,
326+
true);
279327
}
280328
}
281329
}

src/SoundFX/Events/EventHandlers/MiscItemEventHandler.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "MiscItemEventHandler.h"
22
#include "Events/EventHandlerManager.h"
3-
#include "Sound/SoundUtil.h"
3+
#include "Sound/SoundManager.h"
44
#include "Utility.h"
55

66
namespace SoundFX {
@@ -35,7 +35,15 @@ namespace SoundFX {
3535
if (jsonEvent.type == "PickUp") {
3636
if (const float randomValue = GenerateRandomFloat();
3737
randomValue <= jsonEvent.chance) {
38-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
38+
SoundManager::PlaySound(miscitemEvents.name,
39+
jsonEvent.type,
40+
jsonEvent.soundEffect,
41+
{8029.8643f, -69089.37f, 4815.15f},
42+
100.0f,
43+
1000.0f,
44+
jsonEvent.volume,
45+
jsonEvent.isAbsoluteVolume,
46+
true);
3947
}
4048
return RE::BSEventNotifyControl::kContinue;
4149
}
@@ -68,7 +76,15 @@ namespace SoundFX {
6876
if (jsonEvent.type == "Drop") {
6977
if (const float randomValue = GenerateRandomFloat();
7078
randomValue <= jsonEvent.chance) {
71-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
79+
SoundManager::PlaySound(miscitemEvents.name,
80+
jsonEvent.type,
81+
jsonEvent.soundEffect,
82+
{8029.8643f, -69089.37f, 4815.15f},
83+
100.0f,
84+
1000.0f,
85+
jsonEvent.volume,
86+
jsonEvent.isAbsoluteVolume,
87+
true);
7288
}
7389
return RE::BSEventNotifyControl::kContinue;
7490
}

src/SoundFX/Events/EventHandlers/NpcInteractionEventHandler.cpp

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include "NpcInteractionEventHandler.h"
2-
#include "Sound/SoundUtil.h"
2+
#include "Sound/SoundManager.h"
33
#include "Utility.h"
44
#include <numbers>
55

@@ -13,14 +13,11 @@ namespace SoundFX {
1313
actionMap["All"] = [](const std::string &soundEffect,
1414
const std::string &editorid,
1515
const std::string &selectedDialogue) {
16-
PlayCustomSoundAsDescriptor(soundEffect);
1716
};
1817
actionMap["EditorID"] = [](const std::string &soundEffect,
1918
const std::string &editorid,
2019
const std::string &selectedDialogue) {
21-
if (editorid == selectedDialogue) {
22-
PlayCustomSoundAsDescriptor(soundEffect);
23-
}
20+
if (editorid == selectedDialogue) { }
2421
};
2522
}
2623

@@ -70,7 +67,15 @@ namespace SoundFX {
7067
if (jsonEvent.type == "DialogOpen") {
7168
if (const float randomValue = GenerateRandomFloat();
7269
randomValue <= jsonEvent.chance) {
73-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
70+
SoundManager::PlaySound(npcInteractionEvents.name,
71+
jsonEvent.type,
72+
jsonEvent.soundEffect,
73+
{8029.8643f, -69089.37f, 4815.15f},
74+
100.0f,
75+
1000.0f,
76+
jsonEvent.volume,
77+
jsonEvent.isAbsoluteVolume,
78+
true);
7479
}
7580
return RE::BSEventNotifyControl::kContinue;
7681
}

src/SoundFX/Events/EventHandlers/QuestEventHandler.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#include "QuestEventHandler.h"
22
#include "Events/EventHandlerManager.h"
3-
#include "Sound/SoundUtil.h"
3+
#include "Sound/SoundManager.h"
44
#include "Utility.h"
55

66
namespace SoundFX {
@@ -60,7 +60,15 @@ namespace SoundFX {
6060
if (jsonEvent.type == "Start" && event->stage == startStage) {
6161
if (const float randomValue = GenerateRandomFloat();
6262
randomValue <= jsonEvent.chance) {
63-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
63+
SoundManager::PlaySound(questEvents.name,
64+
jsonEvent.type,
65+
jsonEvent.soundEffect,
66+
{8029.8643f, -69089.37f, 4815.15f},
67+
100.0f,
68+
1000.0f,
69+
jsonEvent.volume,
70+
jsonEvent.isAbsoluteVolume,
71+
true);
6472
}
6573
return RE::BSEventNotifyControl::kContinue;
6674
}
@@ -92,7 +100,15 @@ namespace SoundFX {
92100
if (jsonEvent.type == "End" && quest->IsCompleted()) {
93101
if (const float randomValue = GenerateRandomFloat();
94102
randomValue <= jsonEvent.chance) {
95-
PlayCustomSoundAsDescriptor(jsonEvent.soundEffect);
103+
SoundManager::PlaySound(questEvents.name,
104+
jsonEvent.type,
105+
jsonEvent.soundEffect,
106+
{8029.8643f, -69089.37f, 4815.15f},
107+
100.0f,
108+
1000.0f,
109+
jsonEvent.volume,
110+
jsonEvent.isAbsoluteVolume,
111+
true);
96112
}
97113
return RE::BSEventNotifyControl::kContinue;
98114
}

0 commit comments

Comments
 (0)