dayzanimevents.c 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. /*enum AnimSurfaces
  2. {
  3. cp_concrete1,
  4. cp_concrete2,
  5. cp_dirt,
  6. cp_broadleaf_dense1,
  7. cp_broadleaf_dense2,
  8. cp_broadleaf_sparse1,
  9. cp_broadleaf_sparse2,
  10. cp_conifer_common1,
  11. cp_conifer_common2,
  12. cp_conifer_moss1,
  13. cp_conifer_moss2,
  14. cp_grass,
  15. cp_grass_tall,
  16. cp_gravel,
  17. cp_rock,
  18. asphalt_ext,
  19. asphalt_int,
  20. asphalt_destroyed_ext,
  21. asphalt_destroyed_int,
  22. concrete_ext,
  23. concrete_int,
  24. stone_ext,
  25. stone_int,
  26. gravel_large_ext,
  27. gravel_large_int,
  28. gravel_small_ext,
  29. gravel_small_int,
  30. sand_ext,
  31. sand_int,
  32. dirt_ext,
  33. dirt_int,
  34. rubble_large_ext,
  35. rubble_large_int,
  36. rubble_small_ext,
  37. rubble_small_int,
  38. trash_ext,
  39. trash_int,
  40. grass_dry_ext,
  41. grass_dry_int,
  42. metal_thick_ext,
  43. metal_thick_int,
  44. metal_thin_ext,
  45. metal_thin_int,
  46. metal_thin_mesh_ext,
  47. metal_thin_mesh_int,
  48. asphalt_felt_ext,
  49. asphalt_felt_int,
  50. ceramic_tiles_ext,
  51. ceramic_tiles_int,
  52. lino_ext,
  53. lino_int,
  54. textile_carpet_ext,
  55. textile_carpet_int,
  56. wood_parquet_ext,
  57. wood_parquet_int,
  58. wood_planks_ext,
  59. wood_planks_int,
  60. concrete_stairs_ext,
  61. concrete_stairs_int,
  62. metal_stairs_ext,
  63. metal_stairs_int,
  64. wood_planks_stairs_ext,
  65. wood_planks_stairs_int
  66. }*/
  67. enum AnimBootsType
  68. {
  69. None,
  70. Sneakers,
  71. Boots
  72. }
  73. enum AnimUpperBodyType
  74. {
  75. None = 4107064,//string hash, because we can't make compile time constant
  76. NylonJacket = 1228024514,
  77. TShirt = 1690896446,
  78. WoolShirt = 1060939383,
  79. HeavyJacket = 1544363355,
  80. LeatherJacket = 2008520095,
  81. Coat = 3549415,
  82. ChemlonDress = -1491825621,
  83. Ghillie = 602194810,
  84. Chainmail = -563873622,
  85. }
  86. enum AnimBackType
  87. {
  88. None = -1,
  89. Small = 161213437,
  90. Military = 1935514591,
  91. Outdoor = 574855932,
  92. Ghillie = 602194810
  93. }
  94. enum AnimRangedWeaponType
  95. {
  96. None = 5727960,
  97. Rifle = 219116654,
  98. Shotgun = 1836650908
  99. }
  100. class AnimSoundEvent
  101. {
  102. int m_iID;
  103. ref SoundObjectBuilder m_SoundObjectBuilder;
  104. ref SoundParams m_SoundParams;
  105. autoptr NoiseParams m_NoiseParams;
  106. bool m_IsValid = false;
  107. SoundLookupTable m_Table;
  108. void AnimSoundEvent(string soundPath)
  109. {
  110. m_iID = GetGame().ConfigGetInt(soundPath + "id");
  111. #ifndef SERVER
  112. string soundSetName;
  113. if (GetGame().ConfigGetText(soundPath + "soundSet", soundSetName))
  114. {
  115. m_SoundParams = new SoundParams(soundSetName);
  116. if (m_SoundParams.IsValid())
  117. {
  118. m_SoundObjectBuilder = new SoundObjectBuilder(m_SoundParams);
  119. m_IsValid = true;
  120. }
  121. }
  122. string tableName;
  123. if (GetGame().ConfigGetText(soundPath + "soundLookupTable", tableName))
  124. {
  125. m_Table = AnimSoundLookupTableBank.GetInstance().GetActionTable(tableName);
  126. if (m_Table)
  127. {
  128. m_IsValid = true;
  129. //Print("Found lookup table '"+tableName +"' for anim event-----------------------------------------> " + m_iID);
  130. }
  131. }
  132. #endif
  133. if ( GetGame().IsServer() )
  134. {
  135. string noiseName;
  136. if (GetGame().ConfigGetText(soundPath + "noise", noiseName))
  137. {
  138. m_NoiseParams = new NoiseParams();
  139. m_NoiseParams.Load(noiseName);
  140. m_IsValid = true;
  141. }
  142. else
  143. {
  144. //Print("AnimSoundEvent: \"" + soundPath + "\" doesn't have defined \"noise\"");
  145. }
  146. }
  147. }
  148. bool IsValid()
  149. {
  150. return m_IsValid;
  151. }
  152. SoundObjectBuilder GetSoundBuilder()
  153. {
  154. return m_SoundObjectBuilder;
  155. }
  156. SoundObjectBuilder GetSoundBuilderEx(int paramHash = 0)
  157. {
  158. if (m_Table && paramHash)
  159. {
  160. return m_Table.GetSoundBuilder(paramHash);
  161. }
  162. return m_SoundObjectBuilder;
  163. }
  164. SoundObject GetSoundObject(vector position)
  165. {
  166. GetSoundBuilderEx().AddEnvSoundVariables(position);
  167. return GetSoundBuilderEx().BuildSoundObject();
  168. }
  169. }
  170. class AnimSoundVoiceEvent
  171. {
  172. int m_iID;
  173. ref SoundObjectBuilder m_SoundObjectBuilder;
  174. ref SoundParams m_SoundParams;
  175. autoptr NoiseParams m_NoiseParams;
  176. bool m_IsValid = false;
  177. void AnimSoundVoiceEvent(string soundPath)
  178. {
  179. m_iID = GetGame().ConfigGetInt(soundPath + "id");
  180. if ( !GetGame().IsDedicatedServer() )
  181. {
  182. string soundSetName;
  183. GetGame().ConfigGetText(soundPath + "soundSet", soundSetName);
  184. m_SoundParams = new SoundParams(soundSetName);
  185. if ( m_SoundParams.IsValid() )
  186. {
  187. m_SoundObjectBuilder = new SoundObjectBuilder(m_SoundParams);
  188. m_IsValid = true;
  189. }
  190. }
  191. if ( GetGame().IsServer() )
  192. {
  193. string noiseName;
  194. if (GetGame().ConfigGetText(soundPath + "noise", noiseName))
  195. {
  196. m_NoiseParams = new NoiseParams();
  197. m_NoiseParams.Load(noiseName);
  198. m_IsValid = true;
  199. }
  200. else
  201. {
  202. //Print("AnimSoundVoiceEvent: \"" + soundPath + "\" doesn't have defined \"noise\"");
  203. }
  204. }
  205. }
  206. bool IsValid()
  207. {
  208. return m_IsValid;
  209. }
  210. SoundObjectBuilder GetSoundBuilder()
  211. {
  212. return m_SoundObjectBuilder;
  213. }
  214. SoundObject GetSoundObject(vector position)
  215. {
  216. m_SoundObjectBuilder.AddEnvSoundVariables(position);
  217. return m_SoundObjectBuilder.BuildSoundObject();
  218. }
  219. }
  220. class AnimStepEvent
  221. {
  222. int m_iID;
  223. string m_sSoundLookupTableName;
  224. StepSoundLookupTable m_soundLookupTable;
  225. autoptr NoiseParams m_NoiseParams;
  226. void AnimStepEvent(string stepPath)
  227. {
  228. m_iID = GetGame().ConfigGetInt(stepPath + "id");
  229. if ( !GetGame().IsDedicatedServer() )
  230. {
  231. GetGame().ConfigGetText(stepPath + "soundLookupTable", m_sSoundLookupTableName);
  232. m_soundLookupTable = StepSoundLookupTable.Cast( AnimSoundLookupTableBank.GetInstance().GetStepTable(m_sSoundLookupTableName) );
  233. }
  234. if ( GetGame().IsServer() )
  235. {
  236. string noiseName;
  237. if (GetGame().ConfigGetText(stepPath + "noise",noiseName))
  238. {
  239. m_NoiseParams = new NoiseParams();
  240. m_NoiseParams.Load(noiseName);
  241. }
  242. }
  243. }
  244. SoundObjectBuilder GetSoundBuilder(int surfaceHash)
  245. {
  246. return m_soundLookupTable.GetSoundBuilder(surfaceHash);
  247. }
  248. }
  249. class AnimDamageEvent
  250. {
  251. int m_iID;
  252. autoptr AnimDamageParams m_DamageParams;
  253. void AnimDamageEvent(string damagePath)
  254. {
  255. m_iID = GetGame().ConfigGetInt(damagePath + "id");
  256. string damageName;
  257. GetGame().ConfigGetText(damagePath + "damage", damageName);
  258. m_DamageParams = new AnimDamageParams(damageName);
  259. }
  260. }
  261. class AnimDamageParams
  262. {
  263. string m_sName;
  264. string m_sBoneName;
  265. string m_sAmmoName;
  266. float m_fRadius;
  267. float m_fDuration;
  268. bool m_bInvertTeams;
  269. static const string DAMAGE_CFG_CLASS = "CfgDamages ";
  270. void AnimDamageParams(string damageName)
  271. {
  272. m_sName = damageName;
  273. string damagePath = DAMAGE_CFG_CLASS + damageName + " ";
  274. GetGame().ConfigGetText(damagePath + "bone", m_sBoneName);
  275. GetGame().ConfigGetText(damagePath + "ammo", m_sAmmoName);
  276. m_fRadius = GetGame().ConfigGetFloat(damagePath + "radius");
  277. m_fDuration = GetGame().ConfigGetFloat(damagePath + "duration");
  278. m_bInvertTeams = false;
  279. string str_invert_teams_cfg;
  280. GetGame().ConfigGetText(damagePath + "invertTeams", str_invert_teams_cfg);
  281. str_invert_teams_cfg.ToLower();
  282. if (str_invert_teams_cfg == "true")
  283. {
  284. m_bInvertTeams = true;
  285. }
  286. }
  287. }
  288. class AnimEffectParams
  289. {
  290. string m_sName;
  291. static const string EFFECT_CFG_CLASS = "CfgEffects ";
  292. void AnimEffectParams(string effectName)
  293. {
  294. m_sName = effectName;
  295. string effectPath = EFFECT_CFG_CLASS + effectName + " ";
  296. //TODO load params
  297. }
  298. }