DayZ 1.24
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
22 if (table == NULL)
23 {
25 table.LoadTable(tableName);
27 }
28 m_pSoundTables.Insert(id, table);
29 }
30 }
31
33 {
35 if (table == NULL)
36 return NULL;
37
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
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
139 {
141 if (table == NULL)
142 return NULL;
143
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
166{
168 {
169 // this produces 2 maps:
170 // 1) map where the key is 'ID' of anim event and the value is sound lookup table
171 // 2) map of unique lookup table instances where the table name hash is a key, and a lookup table is the value
174
175 string cfgPath = "CfgVehicles SurvivorBase AnimEvents SoundVoice ";
176 int childCount = GetGame().ConfigGetChildrenCount(cfgPath);
177 //Print("childCount:" + childCount);
178 for (int i = 0; i < childCount; i++)
179 {
180 string defName;
181 GetGame().ConfigGetChildName(cfgPath, i, defName);
182 string defPath = cfgPath + defName + " ";
183
184 int id = GetGame().ConfigGetInt(defPath + "id");
185
186 string tableName;
187 GetGame().ConfigGetText(defPath + "soundLookupTable", tableName);
188
190 if (table == NULL)
191 {
193 table.LoadTable(tableName);
194 m_pSoundTableInstances.Insert(tableName.Hash(), table);
195
196 string noiseName;
197 if (GetGame().ConfigGetText(defPath + "noise", noiseName))
198 {
201 table.SetNoiseParam(np);
203 }
204
205 m_pSoundTables.Insert(id, table);
206 }
207 }
208
210 {
212 if (table == NULL)
213 return NULL;
214
216 if (soundBuilder == NULL)
217 return NULL;
218
219 return soundBuilder;
220 }
221
223 {
225 if (table == NULL)
226 return NULL;
227
228 return table.GetNoiseParam();
229 }
230
238
242}
243
244
246{
250
251 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents Sounds ";
252
253 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
254 for (int i = 0; i < soundCount; i++)
255 {
256 string soundName;
257 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
258 string soundPath = soundsCfgPath + soundName + " ";
260 if (soundEvent.IsValid())
262 }
263 }
264
266 {
267 for (int i = 0; i < m_animSoundEvents.Count(); i++)
268 {
270 if (soundEvent.m_iID == event_id)
271 return soundEvent;
272 }
273
274 return NULL;
275 }
276
278 {
279 if (m_instance == NULL)
281
282 return m_instance;
283 }
284
287}
288
289/*
290 class DayZPlayerTypeSoundVoiceTableImpl extends DayZPlayerTypeAnimTable
291 {
292 void DayZPlayerTypeSoundVoiceTableImpl()
293 {
294 m_animSoundEvents = new map<int, ref AnimSoundEvent>;
295
296 string soundsCfgPath = "CfgVehicles SurvivorBase AnimEvents SoundVoice ";
297
298 int soundCount = GetGame().ConfigGetChildrenCount(soundsCfgPath);
299 for(int i = 0; i < soundCount; i++)
300 {
301 string soundName;
302 GetGame().ConfigGetChildName(soundsCfgPath, i, soundName);
303 string soundPath = soundsCfgPath + soundName + " ";
304 AnimSoundEvent soundEvent = new AnimSoundEvent(soundPath);
305 if(soundEvent.IsValid())
306 m_animSoundEvents.Insert(soundEvent.m_iID, soundEvent);
307 }
308 }
309
310 override AnimSoundEvent GetSoundEvent(int event_id)
311 {
312 AnimSoundEvent soundEvent = m_animSoundEvents.Get(event_id);
313 return soundEvent;
314 }
315
316 ref map<int, ref AnimSoundEvent> m_animSoundEvents;
317 }
318*/
319
321{
322 GetGame().ProfilerStart("DayZPlayerTypeRegisterSounds");
324 pType.RegisterStepEvent("Step", 0.2);
325
326 pType.RegisterSoundEvent("Sound", -1);
327 pType.RegisterSoundEvent("SoundWeapon", 0.2);
328 pType.RegisterSoundEvent("SoundVoice", -1);
329 if (!GetGame().IsDedicatedServer()) //attachments don't generate noise, so we can ignore them on server
330 pType.RegisterSoundEvent("SoundAttachment", 0.2);
331
332
334 pType.RegisterVoiceSoundLookupTable(voiceTable2);
335
336 if (!GetGame().IsDedicatedServer()) //sounds are unnecessary on server
337 {
338 pType.RegisterParticleEvent("Particle", -1);
341 pType.RegisterStepSoundLookupTable(stepTable);
342
344 pType.RegisterAttachmentSoundLookupTable(attachTable);
345
346
348 pType.RegisterSoundTable(soundTable);
349
350 //DayZPlayerTypeSoundVoiceTableImpl voiceTable = new DayZPlayerTypeSoundVoiceTableImpl();
351 //pType.RegisterSoundVoiceTable(voiceTable);
352 }
353 GetGame().ProfilerStop("DayZPlayerTypeRegisterSounds");
354}
PlayerSpawnPreset slotName
void PlayerVoiceLookupTable()
static AnimSoundObjectBuilderBank GetInstance()
static ref AnimSoundObjectBuilderBank m_instance
class SoundLookupTable StepSoundLookupTable()
AnimBootsType
autoptr map< int, StepSoundLookupTable > m_pSoundTables
void DayZPlayerTypeStepSoundLookupTableImpl()
class DayZPlayerTypeStepSoundLookupTableImpl extends DayZPlayerTypeStepSoundLookupTable DayZPlayerTypeAttachmentSoundLookupTableImpl()
class DayZPlayerTypeVoiceSoundLookupTableImpl extends DayZPlayerTypeVoiceSoundLookupTable DayZPlayerTypeSoundTableImpl()
ref array< ref AnimSoundEvent > m_animSoundEvents
autoptr map< int, ref StepSoundLookupTable > m_pSoundTableInstances
void DayZPlayerTypeRegisterSounds(DayZPlayerType pType)
void DayZPlayerTypeVoiceSoundLookupTableImpl()
class NoiseSystem NoiseParams()
Definition Noise.c:15
SoundObjectBuilder GetSoundBuilder(int eventId, string slotName, int attachmentHash)
Definition dayzplayer.c:172
autoptr map< int, ref StepSoundLookupTable > m_pSoundTableInstances
static DayZPlayerTypeStepSoundLookupTableImpl GetInstance()
static ref DayZPlayerTypeStepSoundLookupTableImpl m_instance
autoptr map< int, StepSoundLookupTable > m_pSoundTables
override SoundObjectBuilder GetSoundBuilder(int eventId, int pMovement, int pSurfaceHash, AnimBootsType pBoots)
autoptr map< int, ref PlayerVoiceLookupTable > m_pSoundTableInstances
override SoundObjectBuilder GetSoundBuilder(int eventId, int parameterHash)
static ref DayZPlayerTypeVoiceSoundLookupTableImpl m_instance
static DayZPlayerTypeVoiceSoundLookupTableImpl GetInstance()
override NoiseParams GetNoiseParams(int eventId)
autoptr map< int, PlayerVoiceLookupTable > m_pSoundTables
void DayZPlayerType()
Definition dayzplayer.c:507
DayZPlayerConstants
defined in C++
Definition dayzplayer.c:597
class DayZPlayerTypeAttachmentSoundLookupTable GetSoundEvent(int event_id)
Definition dayzplayer.c:180
proto native CGame GetGame()