van_01.c 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334
  1. class Van_01 extends CarScript
  2. {
  3. protected ref UniversalTemperatureSource m_UTSource;
  4. protected ref UniversalTemperatureSourceSettings m_UTSSettings;
  5. protected ref UniversalTemperatureSourceLambdaEngine m_UTSLEngine;
  6. void Van_01()
  7. {
  8. //m_dmgContactCoef = 0.070; //TODO::Set proper value
  9. }
  10. override void EEInit()
  11. {
  12. super.EEInit();
  13. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  14. {
  15. m_UTSSettings = new UniversalTemperatureSourceSettings();
  16. m_UTSSettings.m_ManualUpdate = true;
  17. m_UTSSettings.m_TemperatureItemCap = GameConstants.ITEM_TEMPERATURE_NEUTRAL_ZONE_MIDDLE;
  18. m_UTSSettings.m_TemperatureCap = 0;
  19. m_UTSSettings.m_RangeFull = 0.5;
  20. m_UTSSettings.m_RangeMax = 2;
  21. m_UTSLEngine = new UniversalTemperatureSourceLambdaEngine();
  22. m_UTSource = new UniversalTemperatureSource(this, m_UTSSettings, m_UTSLEngine);
  23. }
  24. }
  25. override void OnEngineStart()
  26. {
  27. super.OnEngineStart();
  28. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  29. {
  30. m_UTSource.SetDefferedActive(true, 20.0);
  31. }
  32. }
  33. override void OnEngineStop()
  34. {
  35. super.OnEngineStop();
  36. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  37. {
  38. m_UTSource.SetDefferedActive(false, 10.0);
  39. }
  40. }
  41. override void EOnPostSimulate(IEntity other, float timeSlice)
  42. {
  43. if (GetGame().IsServer() || !GetGame().IsMultiplayer())
  44. {
  45. if (m_UTSource.IsActive())
  46. {
  47. m_UTSource.Update(m_UTSSettings, m_UTSLEngine);
  48. }
  49. }
  50. }
  51. //-----------------------------------------------------------
  52. override int GetAnimInstance()
  53. {
  54. return VehicleAnimInstances.CIVVAN;
  55. }
  56. //-----------------------------------------------------------
  57. override int GetSeatAnimationType( int posIdx )
  58. {
  59. switch( posIdx )
  60. {
  61. case 0:
  62. return DayZPlayerConstants.VEHICLESEAT_DRIVER;
  63. case 1:
  64. return DayZPlayerConstants.VEHICLESEAT_CODRIVER;
  65. case 2:
  66. return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
  67. case 3:
  68. return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
  69. case 4:
  70. return DayZPlayerConstants.VEHICLESEAT_PASSENGER_L;
  71. }
  72. return 0;
  73. }
  74. //-----------------------------------------------------------
  75. override int GetCarDoorsState( string slotType )
  76. {
  77. CarDoor carDoor;
  78. Class.CastTo( carDoor, FindAttachmentBySlotName( slotType ) );
  79. if ( !carDoor )
  80. return CarDoorState.DOORS_MISSING;
  81. switch( slotType )
  82. {
  83. case "Van_01_Door_1_1":
  84. if ( GetAnimationPhase("DoorsDriver") > 0.5 )
  85. return CarDoorState.DOORS_OPEN;
  86. else
  87. return CarDoorState.DOORS_CLOSED;
  88. break;
  89. case "Van_01_Door_2_1":
  90. if ( GetAnimationPhase("DoorsCoDriver") > 0.5 )
  91. return CarDoorState.DOORS_OPEN;
  92. else
  93. return CarDoorState.DOORS_CLOSED;
  94. break;
  95. case "Van_01_Door_2_2":
  96. if ( GetAnimationPhase("DoorsCargo1") > 0.5 )
  97. return CarDoorState.DOORS_OPEN;
  98. else
  99. return CarDoorState.DOORS_CLOSED;
  100. break;
  101. case "Van_01_Trunk_1":
  102. if ( GetAnimationPhase("DoorsCargo3") > 0.5 )
  103. return CarDoorState.DOORS_OPEN;
  104. else
  105. return CarDoorState.DOORS_CLOSED;
  106. break;
  107. case "Van_01_Trunk_2":
  108. if ( GetAnimationPhase("DoorsCargo2") > 0.5 )
  109. return CarDoorState.DOORS_OPEN;
  110. else
  111. return CarDoorState.DOORS_CLOSED;
  112. break;
  113. }
  114. return CarDoorState.DOORS_MISSING;
  115. }
  116. //-----------------------------------------------------------
  117. override bool CrewCanGetThrough( int posIdx )
  118. {
  119. switch( posIdx )
  120. {
  121. case 0:
  122. if ( GetCarDoorsState( "Van_01_Door_1_1" ) == CarDoorState.DOORS_CLOSED )
  123. return false;
  124. return true;
  125. break;
  126. case 1:
  127. if ( GetCarDoorsState( "Van_01_Door_2_1" ) == CarDoorState.DOORS_CLOSED )
  128. return false;
  129. return true;
  130. break;
  131. case 2:
  132. if ( GetCarDoorsState( "Van_01_Door_2_2" ) == CarDoorState.DOORS_CLOSED )
  133. return false;
  134. return true;
  135. break;
  136. case 3:
  137. if ( GetCarDoorsState( "Van_01_Door_2_2" ) == CarDoorState.DOORS_CLOSED )
  138. return false;
  139. case 4:
  140. if ( GetCarDoorsState( "Van_01_Door_2_2" ) == CarDoorState.DOORS_CLOSED )
  141. return false;
  142. return true;
  143. break;
  144. }
  145. return false;
  146. }
  147. //-----------------------------------------------------------
  148. override float OnSound( CarSoundCtrl ctrl, float oldValue )
  149. {
  150. switch ( ctrl )
  151. {
  152. case CarSoundCtrl.DOORS:
  153. float newValue = 0;
  154. //-----
  155. if ( GetCarDoorsState( "Van_01_Door_1_1" ) == CarDoorState.DOORS_CLOSED )
  156. newValue += 0.25;
  157. //-----
  158. if ( GetCarDoorsState( "Van_01_Door_2_1" ) == CarDoorState.DOORS_CLOSED )
  159. newValue += 0.25;
  160. //-----
  161. if ( GetCarDoorsState( "Van_01_Door_2_2" ) == CarDoorState.DOORS_CLOSED )
  162. newValue += 0.25;
  163. //-----
  164. if ( GetCarDoorsState( "Van_01_Trunk_1" ) == CarDoorState.DOORS_CLOSED )
  165. newValue += 0.125;
  166. //-----
  167. if ( GetCarDoorsState( "Van_01_Trunk_2" ) == CarDoorState.DOORS_CLOSED )
  168. newValue += 0.125;
  169. if ( newValue > 1 )
  170. newValue = 1;
  171. return newValue;
  172. break;
  173. }
  174. return oldValue;
  175. }
  176. //-----------------------------------------------------------
  177. override string GetAnimSourceFromSelection( string selection )
  178. {
  179. switch( selection )
  180. {
  181. case "doors_driver":
  182. return "DoorsDriver";
  183. case "doors_codriver":
  184. return "DoorsCoDriver";
  185. case "doors_cargo1":
  186. return "DoorsCargo1";
  187. case "doors_cargo2":
  188. return "DoorsCargo2";
  189. case "doors_cargo3":
  190. return "DoorsCargo3";
  191. case "doors_hood":
  192. return "DoorsHood";
  193. }
  194. return "";
  195. }
  196. //-----------------------------------------------------------
  197. override string GetDoorConditionPointFromSelection( string selection )
  198. {
  199. switch( selection )
  200. {
  201. case "seat_driver":
  202. return "seat_con_1_1";
  203. break;
  204. case "seat_codriver":
  205. return "seat_con_2_1";
  206. break;
  207. case "seat_cargo1":
  208. case "seat_cargo2":
  209. case "seat_cargo3":
  210. return "seat_con_1_2";
  211. break;
  212. }
  213. return "";
  214. };
  215. //-----------------------------------------------------------
  216. override bool IsVitalTruckBattery()
  217. {
  218. return false;
  219. }
  220. //-----------------------------------------------------------
  221. override bool IsVitalGlowPlug()
  222. {
  223. return false;
  224. }
  225. //-----------------------------------------------------------
  226. override bool CanReachSeatFromSeat( int currentSeat, int nextSeat )
  227. {
  228. switch( currentSeat )
  229. {
  230. case 0:
  231. if ( nextSeat == 1 )
  232. return true;
  233. break;
  234. case 1:
  235. if ( nextSeat == 0 )
  236. return true;
  237. break;
  238. case 2:
  239. if ( nextSeat == 3 )
  240. return true;
  241. break;
  242. case 3:
  243. if ( nextSeat == 2 )
  244. return true;
  245. break;
  246. }
  247. return false;
  248. }
  249. //-----------------------------------------------------------
  250. override bool CanReachDoorsFromSeat( string pDoorsSelection, int pCurrentSeat )
  251. {
  252. switch( pCurrentSeat )
  253. {
  254. case 0:
  255. if (pDoorsSelection == "DoorsDriver")
  256. {
  257. return true;
  258. }
  259. break;
  260. case 1:
  261. if (pDoorsSelection == "DoorsCoDriver")
  262. {
  263. return true;
  264. }
  265. break;
  266. case 2:
  267. if (pDoorsSelection == "DoorsCargo1")
  268. {
  269. return true;
  270. }
  271. break;
  272. case 3:
  273. if (pDoorsSelection == "DoorsCargo2")
  274. {
  275. return true;
  276. }
  277. break;
  278. }
  279. return false;
  280. }
  281. }