DayZ Scripts
v1.21.156300 ยท Jun 20, 2023
 
Loading...
Searching...
No Matches
DayZAnimEventMaps.c
Go to the documentation of this file.
1//individual sound table consisting of map of parameter hashes as keys and soundbuilder array as values
3{
5 {
7 }
8
9 void InitTable(string tableCategoryName, string parameterName)
10 {
11 m_tableCategoryName = tableCategoryName;
12 m_parameterName = parameterName;
13 }
14
15 void LoadTable(string soundLookupTableName)
16 {
17 string path = "CfgSoundTables " + m_tableCategoryName + " " + soundLookupTableName;
18
19 //load all classes names
20 int soundCount = GetGame().ConfigGetChildrenCount(path);
21
22 for(int i = 0; i < soundCount; i++)
23 {
24 string soundClassName;
25 GetGame().ConfigGetChildName(path, i, soundClassName);
26 string soundClassPath = path + " " + soundClassName + " ";
27
28 string parameter;
29 GetGame().ConfigGetText(soundClassPath + m_parameterName, parameter);
30
31 array<string> soundSetNames = new array<string>;
32 GetGame().ConfigGetTextArray(soundClassPath + "soundSets", soundSetNames);
33
34 //TODO create SoundObject for every entry, save in Game?
36 for(int j = 0; j < soundSetNames.Count(); j++)
37 {
39 SoundObjectBuilder soundObjectBuilder = bank.GetBuilder(soundSetNames.Get(j));
40
41 if(soundObjectBuilder != NULL)
42 soundObjectBuilders.Insert(soundObjectBuilder);
43 }
44
45 if(soundObjectBuilders.Count() > 0)
46 {
47 //Print("SoundLookupTable::LoadTable: path: " + path + " param:" + parameter + " param#:" + parameter.Hash() + " objBuildersCount: " + soundObjectBuilders.Count());
48 m_soundBuilders.Insert(parameter.Hash(), soundObjectBuilders);
49 }
50 }
51 }
52
54 {
55 array<SoundObjectBuilder> soundObjects = m_soundBuilders.Get(parameterHash);
56
57 if(soundObjects == NULL || soundObjects.Count() == 0)
58 {
59 return NULL;
60 }
61 else if (soundObjects.Count() == 1)
62 {
63 return soundObjects.Get(0);
64 }
65 else
66 {
67 int index = Math.RandomInt(0, soundObjects.Count());
68 return soundObjects.Get(index);
69 }
70 }
71
72
73 private string m_tableCategoryName;
74 private string m_parameterName;
76}
77
78
80{
82 {
83 InitTable("CfgStepSoundTables", "surface");
84 }
85}
86
87class AttachmentSoundLookupTable extends SoundLookupTable
88{
90 {
91 InitTable("CfgAttachmentSoundTables", "category");
92 }
94
96{
98
100 {
101 InitTable("CfgVoiceSoundTables", "category");
102 }
103
105 {
106 m_NoiseParams = param;
107 }
108
110 {
111 return m_NoiseParams;
112 }
113}
114
115
117{
119 {
120 InitTable("CfgImpactSoundTables", "surface");
121 }
122}
123
125{
128 InitTable("CfgActionsSoundTables", "category");
129 }
130}
132
134{
136 {
138 }
139
140
142 {
143 if(m_instance == NULL)
145
146 return m_instance;
147 }
148
149
150 SoundObjectBuilder GetBuilder(string soundSetName)
152 int soundSetNameHash = soundSetName.Hash();
154 SoundObjectBuilder builder = m_pBuilders.Get(soundSetNameHash);
155 if(builder == NULL)
156 {
157 SoundParams params = new SoundParams(soundSetName);
158 if(params.IsValid())
159 {
160 builder = new SoundObjectBuilder(params);
161 m_pBuilders.Insert(soundSetNameHash, builder);
162 }
163 else
164 {
165 Print("AnimSoundObjectBuilderBank: Invalid sound set \"" + soundSetName + "\".");
166 return NULL;
167 }
168 }
169 return builder;
170 }
171
174}
175
176
178{
182 }
183
184
187 if(m_instance == NULL)
189
190 return m_instance;
191 }
192
193
196 int tableNameHash = tableName.Hash();
197
198 SoundLookupTable table = m_pTables.Get(tableNameHash);
199 if(table == NULL)
200 {
201 table = new StepSoundLookupTable();
202 table.LoadTable(tableName);
203 m_pTables.Insert(tableNameHash, table);
204 }
205 return table;
206 }
207
209 {
210 int tableNameHash = tableName.Hash();
211
212 SoundLookupTable table = m_pTables.Get(tableNameHash);
213 if(table == NULL)
214 {
215 table = new ImpactSoundLookupTable();
216 table.LoadTable(tableName);
217 m_pTables.Insert(tableNameHash, table);
219 return table;
220 }
221
223 {
224 int tableNameHash = tableName.Hash();
225
226 SoundLookupTable table = m_pTables.Get(tableNameHash);
227 if(table == NULL)
228 {
229 table = new ActionSoundLookupTable();
230 table.LoadTable(tableName);
231 m_pTables.Insert(tableNameHash, table);
232 }
233 return table;
234 }
235
236 private static ref AnimSoundLookupTableBank m_instance;
238}
void PlayerVoiceLookupTable()
SoundLookupTable GetImpactTable(string tableName)
private autoptr map< int, ref SoundLookupTable > m_pTables
static private ref AnimSoundObjectBuilderBank m_instance
void SetNoiseParam(NoiseParams param)
class AnimSoundObjectBuilderBank AnimSoundLookupTableBank()
static AnimSoundObjectBuilderBank GetInstance()
SoundLookupTable GetStepTable(string tableName)
SoundLookupTable GetActionTable(string tableName)
class AttachmentSoundLookupTable extends SoundLookupTable m_NoiseParams
class ImpactSoundLookupTable extends SoundLookupTable ActionSoundLookupTable()
class SoundLookupTable StepSoundLookupTable()
NoiseParams GetNoiseParam()
void ImpactSoundLookupTable()
class NoiseSystem NoiseParams()
Definition Noise.c:15
SoundObjectBuilder GetBuilder(string soundSetName)
static AnimSoundObjectBuilderBank GetInstance()
static private ref AnimSoundObjectBuilderBank m_instance
private autoptr map< int, ref SoundObjectBuilder > m_pBuilders
proto native int ConfigGetChildrenCount(string path)
Get count of subclasses in config class on path.
proto bool ConfigGetText(string path, out string value)
Get string value from config on path.
proto native void ConfigGetTextArray(string path, out TStringArray values)
Get array of strings from config on path.
proto bool ConfigGetChildName(string path, int index, out string name)
Get name of subclass in config class on path.
Definition EnMath.c:7
void LoadTable(string soundLookupTableName)
SoundObjectBuilder GetSoundBuilder(int parameterHash)
void InitTable(string tableCategoryName, string parameterName)
private string m_parameterName
void AttachmentSoundLookupTable()
private string m_tableCategoryName
private ref map< int, ref array< SoundObjectBuilder > > m_soundBuilders
proto native bool IsValid()
Result for an object found in CGame.IsBoxCollidingGeometryProxy.
proto native CGame GetGame()
proto void Print(void var)
Prints content of variable to console/log.
static proto int RandomInt(int min, int max)
Returns a random int number between and min [inclusive] and max [exclusive].
proto native int Hash()
Returns hash of string.