Dayz Explorer  1.24.157551 (v105080)
Dayz Code Explorer by Zeroy
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.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 
89  static DayZPlayerTypeStepSoundLookupTableImpl GetInstance()
90  {
91  if(m_instance == NULL)
92  m_instance = new DayZPlayerTypeStepSoundLookupTableImpl();
93 
94  return m_instance;
95  }
96 
97  private static ref DayZPlayerTypeStepSoundLookupTableImpl m_instance;
99  private autoptr map<int, StepSoundLookupTable> m_pSoundTables;//pointers to tables above
100 }
101 
102 
104 {
106  {
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);
135  }
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;
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))
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;
244 }
245 
246 
247 
248 class DayZPlayerTypeSoundTableImpl extends DayZPlayerTypeAnimTable
249 {
251  {
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 
282  static DayZPlayerTypeSoundTableImpl GetInstance()
283  {
284  if(m_instance == NULL)
285  m_instance = new DayZPlayerTypeSoundTableImpl();
286 
287  return m_instance;
288  }
289 
290  private static ref DayZPlayerTypeSoundTableImpl m_instance;
292 }
293 
294 /*
295 class 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 }
PlayerVoiceLookupTable
void PlayerVoiceLookupTable()
Definition: dayzanimeventmaps.c:99
GetGame
proto native CGame GetGame()
DayZPlayerTypeRegisterSounds
void DayZPlayerTypeRegisterSounds(DayZPlayerType pType)
Definition: dayzplayercfgsounds.c:325
DayZPlayerTypeVoiceSoundLookupTable
Definition: dayzplayercfgsounds.c:167
DayZPlayerTypeVoiceSoundLookupTableImpl
void DayZPlayerTypeVoiceSoundLookupTableImpl()
Definition: dayzplayercfgsounds.c:162
DayZPlayerType
private void DayZPlayerType()
Definition: dayzplayer.c:512
m_pSoundTables
private autoptr map< int, StepSoundLookupTable > m_pSoundTables
Definition: dayzplayercfgsounds.c:98
StepSoundLookupTable
class SoundLookupTable StepSoundLookupTable()
Definition: dayzanimeventmaps.c:81
AnimBootsType
AnimBootsType
Definition: dayzanimevents.c:97
DayZPlayerTypeStepSoundLookupTable
Definition: dayzplayer.c:146
DayZPlayerTypeStepSoundLookupTableImpl
void DayZPlayerTypeStepSoundLookupTableImpl()
Definition: dayzplayercfgsounds.c:2
map
map
Definition: controlsxboxnew.c:3
NoiseParams
class ObjectSpawnerHandler NoiseParams
DayZPlayerConstants
DayZPlayerConstants
defined in C++
Definition: dayzplayer.c:601
GetSoundBuilder
override SoundObjectBuilder GetSoundBuilder(int eventId, int pMovement, int pSurfaceHash, AnimBootsType pBoots)
Definition: dayzplayercfgsounds.c:31
DayZPlayerTypeAttachmentSoundLookupTable
Definition: dayzplayer.c:170
GetSoundEvent
override AnimSoundEvent GetSoundEvent(int event_id)
Definition: dayzplayercfgsounds.c:268
slotName
PlayerSpawnPreset slotName
m_animSoundEvents
private ref array< ref AnimSoundEvent > m_animSoundEvents
Definition: dayzplayercfgsounds.c:291
GetNoiseParams
override NoiseParams GetNoiseParams(int eventId)
Definition: dayzplayercfgsounds.c:217
array< ref AnimSoundEvent >
DayZPlayerTypeSoundTableImpl
class DayZPlayerTypeVoiceSoundLookupTableImpl extends DayZPlayerTypeVoiceSoundLookupTable DayZPlayerTypeSoundTableImpl()
Definition: dayzplayercfgsounds.c:250
DayZPlayerTypeAttachmentSoundLookupTableImpl
class DayZPlayerTypeStepSoundLookupTableImpl extends DayZPlayerTypeStepSoundLookupTable DayZPlayerTypeAttachmentSoundLookupTableImpl()
Definition: dayzplayercfgsounds.c:105
SoundObjectBuilder
Definition: sound.c:45
SoundLookupTable
Definition: dayzanimeventmaps.c:2
m_pSoundTableInstances
private autoptr map< int, ref StepSoundLookupTable > m_pSoundTableInstances
Definition: dayzplayercfgsounds.c:97