DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
DayZPlayerCfgSounds.c
Go to the documentation of this file.
2{
4 {
7
8 string stepsCfgPath = "CfgVehicles SurvivorBase AnimEvents Steps ";
9 int stepsCount = GetGame().ConfigGetChildrenCount(stepsCfgPath);
10 for(int i = 0; i < stepsCount; i++)
11 {
12 string stepName;
13 GetGame().ConfigGetChildName(stepsCfgPath, i, stepName);
14 string stepPath = stepsCfgPath + stepName + " ";
15 int id = GetGame().ConfigGetInt(stepPath + "id");
16
17 string tableName;
18 GetGame().ConfigGetText(stepPath + "soundLookupTable", tableName);
19
20
21 StepSoundLookupTable table = m_pSoundTableInstances.Get(tableName.Hash());
22 if(table == NULL)
23 {
24 table = new StepSoundLookupTable();
25 table.LoadTable(tableName);
26 m_pSoundTableInstances.Insert(tableName.Hash(), table);
27 }
28 m_pSoundTables.Insert(id, table);
29 }
30 }
31
32 override SoundObjectBuilder GetSoundBuilder(int eventId, int pMovement, int pSurfaceHash, AnimBootsType pBoots)
33 {
34 SoundLookupTable table = m_pSoundTables.Get(eventId);
35 if(table == NULL)
36 return NULL;
37
38 SoundObjectBuilder soundBuilder = table.GetSoundBuilder(pSurfaceHash);
39 if(soundBuilder == NULL)
40 return NULL;
41
42 if (pMovement == DayZPlayerConstants.MOVEMENTIDX_WALK)
43 {
44 soundBuilder.SetVariable("walk", 1);
45 soundBuilder.SetVariable("run", 0);
46 soundBuilder.SetVariable("sprint", 0);
47 }
48 else if (pMovement == DayZPlayerConstants.MOVEMENTIDX_RUN)
49 {
50 soundBuilder.SetVariable("walk", 0);
51 soundBuilder.SetVariable("run", 1);
52 soundBuilder.SetVariable("sprint", 0);
53 }
54 else if (pMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
55 {
56 soundBuilder.SetVariable("walk", 0);
57 soundBuilder.SetVariable("run", 0);
58 soundBuilder.SetVariable("sprint", 1);
59 }
60 else
61 {
62 soundBuilder.SetVariable("walk", 0);
63 soundBuilder.SetVariable("run", 0);
64 soundBuilder.SetVariable("sprint", 0);
65 }
66
67 if (pBoots == AnimBootsType.None)
68 {
69 soundBuilder.SetVariable("bare", 1);
70 soundBuilder.SetVariable("sneakers", 0);
71 soundBuilder.SetVariable("boots", 0);
72 }
73 else if (pBoots == AnimBootsType.Sneakers)
74 {
75 soundBuilder.SetVariable("bare", 0);
76 soundBuilder.SetVariable("sneakers", 1);
77 soundBuilder.SetVariable("boots", 0);
78 }
79 else if (pBoots == AnimBootsType.Boots)
80 {
81 soundBuilder.SetVariable("bare", 0);
82 soundBuilder.SetVariable("sneakers", 0);
83 soundBuilder.SetVariable("boots", 1);
84 }
85
86 return soundBuilder;
87 }
88
90 {
91 if(m_instance == NULL)
93
94 return m_instance;
95 }
96
99 private autoptr map<int, StepSoundLookupTable> m_pSoundTables;//pointers to tables above
100}
101
102
104{
109
110 string attachCfgPath = "CfgVehicles SurvivorBase AnimEvents Attachments ";
111 int attachCount = GetGame().ConfigGetChildrenCount(attachCfgPath);
112 for(int i = 0; i < attachCount; i++)
113 {
114 string defName;
115 GetGame().ConfigGetChildName(attachCfgPath, i, defName);
116 string defPath = attachCfgPath + defName + " ";
117
118 string slotName;
119 GetGame().ConfigGetText(defPath + "slot", slotName);
120
121 int id = GetGame().ConfigGetInt(defPath + "id");
122
123 string tableName;
124 GetGame().ConfigGetText(defPath + "soundLookupTable", tableName);
125
126 AttachmentSoundLookupTable table = m_pSoundTableInstances.Get(tableName.Hash());
127 if(table == NULL)
128 {
129 table = new AttachmentSoundLookupTable();
130 table.LoadTable(tableName);
131 m_pSoundTableInstances.Insert(tableName.Hash(), table);
132 }
133
134 m_pSoundTables.Insert((slotName + id).Hash(), table);
136 }
137
138 override SoundObjectBuilder GetSoundBuilder(int eventId, string slotName, int attachmentHash)
139 {
140 SoundLookupTable table = m_pSoundTables.Get((slotName + eventId).Hash());
141 if(table == NULL)
142 return NULL;
143
144 SoundObjectBuilder soundBuilder = table.GetSoundBuilder(attachmentHash);
145 if(soundBuilder == NULL)
146 return NULL;
147
148 return soundBuilder;
149 }
150
152 {
153 if(m_instance == NULL)
155
156 return m_instance;
157 }
158
162}
163
164
165
166
168{
170 {
171 // this produces 2 maps:
172 // 1) map where the key is 'ID' of anim event and the value is sound lookup table
173 // 2) map of unique lookup table instances where the table name hash is a key, and a lookup table is the value
176
177 string cfgPath = "CfgVehicles SurvivorBase AnimEvents SoundVoice ";
178 int childCount = GetGame().ConfigGetChildrenCount(cfgPath);
179 //Print("childCount:" + childCount);
180 for(int i = 0; i < childCount; i++)
181 {
182 string defName;
183 GetGame().ConfigGetChildName(cfgPath, i, defName);
184 string defPath = cfgPath + defName + " ";
185
186 int id = GetGame().ConfigGetInt(defPath + "id");
187
188 string tableName;
189 GetGame().ConfigGetText(defPath + "soundLookupTable", tableName);
190
191 PlayerVoiceLookupTable table = m_pSoundTableInstances.Get(tableName.Hash());
192 if(table == NULL)
193 {
194 table = new PlayerVoiceLookupTable();
195 table.LoadTable(tableName);
196 m_pSoundTableInstances.Insert(tableName.Hash(), table);
197
198 string noiseName;
199 if(GetGame().ConfigGetText(defPath + "noise", noiseName))
202 np.Load(noiseName);
203 table.SetNoiseParam(np);
204 }
205 }
206
207 m_pSoundTables.Insert(id, table);
208 }
209 }
210
211 override SoundObjectBuilder GetSoundBuilder(int eventId, int parameterHash)
212 {
213 PlayerVoiceLookupTable table = m_pSoundTables.Get(eventId);
214 if(table == NULL)
215 return NULL;
216
217 SoundObjectBuilder soundBuilder = table.GetSoundBuilder(parameterHash);
218 if(soundBuilder == NULL)
219 return NULL;
220
221 return soundBuilder;
222 }
223
224 override NoiseParams GetNoiseParams(int eventId)
225 {
226 PlayerVoiceLookupTable table = m_pSoundTables.Get(eventId);
227 if(table == NULL)
228 return NULL;
229
230 return table.GetNoiseParam();
231 }
232
234 {
235 if(m_instance == NULL)
237
238 return m_instance;
239 }
240
244}
245
246
247
248class DayZPlayerTypeSoundTableImpl extends DayZPlayerTypeAnimTable
249{
253
254 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents Sounds ";
255
256 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
257 for(int i = 0; i < soundCount; i++)
258 {
259 string soundName;
260 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
261 string soundPath = soundsCfgPath + soundName + " ";
262 AnimSoundEvent soundEvent = new AnimSoundEvent(soundPath);
263 if(soundEvent.IsValid())
264 m_animSoundEvents.Insert(soundEvent);
265 }
266 }
267
268 override AnimSoundEvent GetSoundEvent(int event_id)
269 {
270 for(int i = 0; i < m_animSoundEvents.Count(); i++)
271 {
272 AnimSoundEvent soundEvent = m_animSoundEvents.Get(i);
273 if(soundEvent.m_iID == event_id)
274 {
275 return soundEvent;
276 }
277 }
278
279 return NULL;
280 }
281
283 {
284 if(m_instance == NULL)
286
287 return m_instance;
288 }
289
290 private static ref DayZPlayerTypeSoundTableImpl m_instance;
292}
294/*
295class DayZPlayerTypeSoundVoiceTableImpl extends DayZPlayerTypeAnimTable
296{
297 void DayZPlayerTypeSoundVoiceTableImpl()
298 {
299 m_animSoundEvents = new map<int, ref AnimSoundEvent>;
300
301 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents SoundVoice ";
302
303 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
304 for(int i = 0; i < soundCount; i++)
305 {
306 string soundName;
307 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
308 string soundPath = soundsCfgPath + soundName + " ";
309 AnimSoundEvent soundEvent = new AnimSoundEvent(soundPath);
310 if(soundEvent.IsValid())
311 m_animSoundEvents.Insert(soundEvent.m_iID, soundEvent);
312 }
313 }
314
315 override AnimSoundEvent GetSoundEvent(int event_id)
316 {
317 AnimSoundEvent soundEvent = m_animSoundEvents.Get(event_id);
318 return soundEvent;
319 }
320
321 ref map<int, ref AnimSoundEvent> m_animSoundEvents;
322}
323*/
324
326{
327 GetGame().ProfilerStart("DayZPlayerTypeRegisterSounds");
329 pType.RegisterStepEvent("Step", 0.2);
330
331 pType.RegisterSoundEvent("Sound", -1);
332 pType.RegisterSoundEvent("SoundWeapon", 0.2);
333 pType.RegisterSoundEvent("SoundVoice", -1);
334 if(!GetGame().IsDedicatedServer())//attachments don't generate noise, so we can ignore them on server
335 pType.RegisterSoundEvent("SoundAttachment", 0.2);
336
337
339 pType.RegisterVoiceSoundLookupTable(voiceTable2);
340
341 if(!GetGame().IsDedicatedServer())//sounds are unnecessary on server
342 {
343 pType.RegisterParticleEvent("Particle", -1);
346 pType.RegisterStepSoundLookupTable(stepTable);
347
349 pType.RegisterAttachmentSoundLookupTable(attachTable);
350
351
352
354 pType.RegisterSoundTable(soundTable);
355
356 //DayZPlayerTypeSoundVoiceTableImpl voiceTable = new DayZPlayerTypeSoundVoiceTableImpl();
357 //pType.RegisterSoundVoiceTable(voiceTable);
358 }
359 GetGame().ProfilerStop("DayZPlayerTypeRegisterSounds");
360}
void PlayerVoiceLookupTable()
static private ref AnimSoundObjectBuilderBank m_instance
static AnimSoundObjectBuilderBank GetInstance()
class SoundLookupTable StepSoundLookupTable()
AnimBootsType
class DayZPlayerTypeStepSoundLookupTableImpl extends DayZPlayerTypeStepSoundLookupTable DayZPlayerTypeAttachmentSoundLookupTableImpl()
private autoptr map< int, StepSoundLookupTable > m_pSoundTables
class DayZPlayerTypeVoiceSoundLookupTableImpl extends DayZPlayerTypeVoiceSoundLookupTable DayZPlayerTypeSoundTableImpl()
private ref array< ref AnimSoundEvent > m_animSoundEvents
void DayZPlayerTypeVoiceSoundLookupTableImpl()
void DayZPlayerTypeRegisterSounds(DayZPlayerType pType)
private autoptr map< int, ref StepSoundLookupTable > m_pSoundTableInstances
void DayZPlayerTypeStepSoundLookupTableImpl()
class NoiseSystem NoiseParams()
Definition Noise.c:15
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto native void ProfilerStop(string name)
Use for profiling code from start to stop, they must match have same name, look wiki pages for more i...
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ProfilerStart(string name)
Use for profiling code from start to stop, they must match have same name, look wiki pages for more i...
proto native int ConfigGetInt(string path)
Get int value from config on path.
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
SoundObjectBuilder GetSoundBuilder(int eventId, string slotName, int attachmentHash)
Definition dayzplayer.c:172
private autoptr map< int, StepSoundLookupTable > m_pSoundTables
private autoptr map< int, ref StepSoundLookupTable > m_pSoundTableInstances
static DayZPlayerTypeStepSoundLookupTableImpl GetInstance()
override SoundObjectBuilder GetSoundBuilder(int eventId, int pMovement, int pSurfaceHash, AnimBootsType pBoots)
static private ref DayZPlayerTypeStepSoundLookupTableImpl m_instance
override NoiseParams GetNoiseParams(int eventId)
override SoundObjectBuilder GetSoundBuilder(int eventId, int parameterHash)
static private ref DayZPlayerTypeVoiceSoundLookupTableImpl m_instance
private autoptr map< int, PlayerVoiceLookupTable > m_pSoundTables
private autoptr map< int, ref PlayerVoiceLookupTable > m_pSoundTableInstances
static DayZPlayerTypeVoiceSoundLookupTableImpl GetInstance()
SoundObjectBuilder GetSoundBuilder(int parameterHash)
proto native void SetVariable(string name, float value)
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
private void DayZPlayerType()
Definition dayzplayer.c:512
class DayZPlayerTypeAttachmentSoundLookupTable GetSoundEvent(int event_id)
Definition dayzplayer.c:180
proto native CGame GetGame()
proto native int Hash()
Returns hash of string.