Dayz Explorer 1.28.160049
Loading...
Searching...
No Matches
dayzplayercfgsounds.c
Go to the documentation of this file.
2{
4 {
5 m_pSoundTableInstances = new map<int, ref StepSoundLookupTable>;
6 m_pSoundTables = new map<int, StepSoundLookupTable>;
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.AddVariable("walk", 1);
45 soundBuilder.AddVariable("run", 0);
46 soundBuilder.AddVariable("sprint", 0);
47 }
48 else if (pMovement == DayZPlayerConstants.MOVEMENTIDX_RUN)
49 {
50 soundBuilder.AddVariable("walk", 0);
51 soundBuilder.AddVariable("run", 1);
52 soundBuilder.AddVariable("sprint", 0);
53 }
54 else if (pMovement == DayZPlayerConstants.MOVEMENTIDX_SPRINT)
55 {
56 soundBuilder.AddVariable("walk", 0);
57 soundBuilder.AddVariable("run", 0);
58 soundBuilder.AddVariable("sprint", 1);
59 }
60 else
61 {
62 soundBuilder.AddVariable("walk", 0);
63 soundBuilder.AddVariable("run", 0);
64 soundBuilder.AddVariable("sprint", 0);
65 }
66
67 if (pBoots == AnimBootsType.None)
68 {
69 soundBuilder.AddVariable("bare", 1);
70 soundBuilder.AddVariable("sneakers", 0);
71 soundBuilder.AddVariable("boots", 0);
72 }
73 else if (pBoots == AnimBootsType.Sneakers)
74 {
75 soundBuilder.AddVariable("bare", 0);
76 soundBuilder.AddVariable("sneakers", 1);
77 soundBuilder.AddVariable("boots", 0);
78 }
79 else if (pBoots == AnimBootsType.Boots)
80 {
81 soundBuilder.AddVariable("bare", 0);
82 soundBuilder.AddVariable("sneakers", 0);
83 soundBuilder.AddVariable("boots", 1);
84 }
85
86 return soundBuilder;
87 }
88
90 {
91 if(m_instance == NULL)
93
94 return m_instance;
95 }
96
97 private static ref DayZPlayerTypeStepSoundLookupTableImpl m_instance;
98 private autoptr map<int, ref StepSoundLookupTable> m_pSoundTableInstances;//unique tables
99 private autoptr map<int, StepSoundLookupTable> m_pSoundTables;//pointers to tables above
100}
101
102
104{
107 m_pSoundTableInstances = new map<int, ref AttachmentSoundLookupTable>;
108 m_pSoundTables = new map<int, AttachmentSoundLookupTable>();
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
159 private static ref DayZPlayerTypeAttachmentSoundLookupTableImpl m_instance;
160 private autoptr map<int, ref AttachmentSoundLookupTable> m_pSoundTableInstances;
161 private autoptr map<int, AttachmentSoundLookupTable> m_pSoundTables;
162}
163
164
165
166
167class DayZPlayerTypeVoiceSoundLookupTableImpl extends DayZPlayerTypeVoiceSoundLookupTable
168{
169 void DayZPlayerTypeVoiceSoundLookupTableImpl()
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
174 m_pSoundTableInstances = new map<int, ref PlayerVoiceLookupTable>;
175 m_pSoundTables = new map<int, PlayerVoiceLookupTable>();
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))
200 {
201 NoiseParams np = new NoiseParams;
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
233 static DayZPlayerTypeVoiceSoundLookupTableImpl GetInstance()
234 {
235 if(m_instance == NULL)
236 m_instance = new DayZPlayerTypeVoiceSoundLookupTableImpl();
237
238 return m_instance;
239 }
240
241 private static ref DayZPlayerTypeVoiceSoundLookupTableImpl m_instance;
242 private autoptr map<int, ref PlayerVoiceLookupTable> m_pSoundTableInstances;
243 private autoptr map<int, PlayerVoiceLookupTable> m_pSoundTables;
244}
245
246
247
248class DayZPlayerTypeSoundTableImpl extends DayZPlayerTypeAnimTable
249{
250 private static ref DayZPlayerTypeSoundTableImpl m_instance;
251 private ref map<int, ref AnimSoundEvent> m_AnimSoundEvents;
252
253 void DayZPlayerTypeSoundTableImpl()
254 {
255 m_AnimSoundEvents = new map<int, ref AnimSoundEvent>();
256
257 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents Sounds ";
258
259 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
260 for(int i = 0; i < soundCount; i++)
261 {
262 string soundName;
263 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
264 string soundPath = soundsCfgPath + soundName + " ";
265 AnimSoundEvent soundEvent = new AnimSoundEvent(soundPath);
266 if(soundEvent.IsValid())
267 m_AnimSoundEvents.Set(soundEvent.m_iID, soundEvent);
268 }
269 }
270
271 override AnimSoundEvent GetSoundEvent(int event_id)
272 {
273 return m_AnimSoundEvents.Get(event_id);
274 }
275
276 static DayZPlayerTypeSoundTableImpl GetInstance()
277 {
278 if(m_instance == null)
279 m_instance = new DayZPlayerTypeSoundTableImpl();
280
281 return m_instance;
282 }
283
285 private ref array<ref AnimSoundEvent> m_animSoundEvents;
286}
287
288/*
289class DayZPlayerTypeSoundVoiceTableImpl extends DayZPlayerTypeAnimTable
290{
291 void DayZPlayerTypeSoundVoiceTableImpl()
292 {
293 m_animSoundEvents = new map<int, ref AnimSoundEvent>;
294
295 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents SoundVoice ";
296
297 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
298 for(int i = 0; i < soundCount; i++)
299 {
300 string soundName;
301 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
302 string soundPath = soundsCfgPath + soundName + " ";
303 AnimSoundEvent soundEvent = new AnimSoundEvent(soundPath);
304 if(soundEvent.IsValid())
305 m_animSoundEvents.Insert(soundEvent.m_iID, soundEvent);
306 }
307 }
308
309 override AnimSoundEvent GetSoundEvent(int event_id)
310 {
311 AnimSoundEvent soundEvent = m_animSoundEvents.Get(event_id);
312 return soundEvent;
313 }
314
315 ref map<int, ref AnimSoundEvent> m_animSoundEvents;
316}
317*/
318
319void DayZPlayerTypeRegisterSounds(DayZPlayerType pType)
320{
321 GetGame().ProfilerStart("DayZPlayerTypeRegisterSounds");
323 pType.RegisterStepEvent("Step", 0.2);
324
325 pType.RegisterSoundEvent("Sound", -1);
326 pType.RegisterSoundEvent("SoundWeapon", 0.2);
327 pType.RegisterSoundEvent("SoundVoice", -1);
328 if(!GetGame().IsDedicatedServer())//attachments don't generate noise, so we can ignore them on server
329 pType.RegisterSoundEvent("SoundAttachment", 0.2);
330
331
332 DayZPlayerTypeVoiceSoundLookupTableImpl voiceTable2 = DayZPlayerTypeVoiceSoundLookupTableImpl.GetInstance();
333 pType.RegisterVoiceSoundLookupTable(voiceTable2);
334
335 if(!GetGame().IsDedicatedServer())//sounds are unnecessary on server
336 {
337 pType.RegisterParticleEvent("Particle", -1);
340 pType.RegisterStepSoundLookupTable(stepTable);
341
343 pType.RegisterAttachmentSoundLookupTable(attachTable);
344
345
346
347 DayZPlayerTypeSoundTableImpl soundTable = DayZPlayerTypeSoundTableImpl.GetInstance();
348 pType.RegisterSoundTable(soundTable);
349
350 //DayZPlayerTypeSoundVoiceTableImpl voiceTable = new DayZPlayerTypeSoundVoiceTableImpl();
351 //pType.RegisterSoundVoiceTable(voiceTable);
352 }
353 GetGame().ProfilerStop("DayZPlayerTypeRegisterSounds");
354}
PlayerSpawnPreset slotName
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
void PlayerVoiceLookupTable()
class SoundLookupTable StepSoundLookupTable()
SoundObjectBuilder GetSoundBuilder(int parameterHash)
AnimBootsType
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:602
class DayZPlayerTypeAttachmentSoundLookupTable GetSoundEvent(int event_id)
Definition dayzplayer.c:180
NoiseParams GetNoiseParams(int eventId)
void DayZPlayerTypeStepSoundLookupTableImpl()
class DayZPlayerTypeStepSoundLookupTableImpl extends DayZPlayerTypeStepSoundLookupTable DayZPlayerTypeAttachmentSoundLookupTableImpl()
proto native CGame GetGame()
class AbstractSoundScene SoundObjectBuilder(SoundParams soundParams)
class NoiseSystem NoiseParams()
Definition noise.c:15