Advertisement
Guest User

Untitled

a guest
Feb 17th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 36.06 KB | None | 0 0
  1. -- Specjalizacja dla Ursus C360 --
  2. -- Autor: Rockstar94 --
  3. -- 1.1: 10.07.2015 --
  4. -- 1.2: 29.11.2015 --
  5. -- 1.3: 15.12.2015 -- mmozliwosc wylaczenia modu reki i animacji wejscia --
  6. -- Autor do ls17: misiak1212 --
  7.  
  8.  
  9. C360 = {};
  10.  
  11. function C360.prerequisitesPresent(specializations)
  12. return SpecializationUtil.hasSpecialization(Motorized, specializations);
  13. end;
  14.  
  15. function C360:load(savegame)
  16. self.isSelected = true;
  17.  
  18. self.setHydraulicTime = 30;
  19. self.setHydraulicDirection = SpecializationUtil.callSpecializationsFunction("setHydraulicDirection");
  20.  
  21. local hydraulicsCount = Utils.getNoNil(getXMLInt(self.xmlFile, "vehicle.hydraulics#count"), 0);
  22. self.hydraulics = {};
  23. for i=1, hydraulicsCount do
  24. local hydraulicName = string.format("vehicle.hydraulics.hydraulic%d", i);
  25. self.hydraulics[i] = {};
  26. self.hydraulics[i].node = Utils.indexToObject(self.components, getXMLString(self.xmlFile, hydraulicName .. "#index"));
  27. self.hydraulics[i].punch = Utils.indexToObject(self.components, getXMLString(self.xmlFile, hydraulicName .. "#punch"));
  28. self.hydraulics[i].translationPunch = Utils.indexToObject(self.components, getXMLString(self.xmlFile, hydraulicName .. "#punchFixpoint"));
  29. self.hydraulics[i].fixPoint = Utils.indexToObject(self.components, getXMLString(self.xmlFile, hydraulicName .. "#fixpoint"));
  30. local xUp, yUp, zUp = Utils.getVectorFromString(Utils.getNoNil(getXMLString(self.xmlFile, hydraulicName .. "#upVectors"),"0 1 0"));
  31. self.hydraulics[i].upVectors = {xUp, yUp, zUp};
  32.  
  33. local ax, ay, az;
  34. if self.hydraulics[i].punch ~= nil then
  35. ax, ay, az = getWorldTranslation(self.hydraulics[i].punch);
  36. else
  37. ax, ay, az = getWorldTranslation(self.hydraulics[i].node);
  38. end;
  39. if self.hydraulics[i].translationPunch ~= nil then
  40. local bx, by, bz = getWorldTranslation(self.hydraulics[i].translationPunch);
  41. self.hydraulics[i].punchDistance = Utils.vector3Length(ax-bx, ay-by, az-bz);
  42. end;
  43. end;
  44.  
  45. local rotationPartNodeLeft = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.rotationPartLeft#index"));
  46. if rotationPartNodeLeft ~= nil then
  47. self.rotationPartLeft = {};
  48. self.rotationPartLeft.node = rotationPartNodeLeft;
  49.  
  50. local x, y, z = Utils.getVectorFromString(getXMLString(self.xmlFile, "vehicle.rotationPartLeft#minRot"));
  51. self.rotationPartLeft.minRot = {};
  52. self.rotationPartLeft.minRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
  53. self.rotationPartLeft.minRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
  54. self.rotationPartLeft.minRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
  55.  
  56. x, y, z = Utils.getVectorFromString(getXMLString(self.xmlFile, "vehicle.rotationPartLeft#maxRot"));
  57. self.rotationPartLeft.maxRot = {};
  58. self.rotationPartLeft.maxRot[1] = Utils.degToRad(Utils.getNoNil(x, 0));
  59. self.rotationPartLeft.maxRot[2] = Utils.degToRad(Utils.getNoNil(y, 0));
  60. self.rotationPartLeft.maxRot[3] = Utils.degToRad(Utils.getNoNil(z, 0));
  61.  
  62. self.rotationPartLeft.rotTime = Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.rotationPartLeft#rotTime"), 2)*1000;
  63. self.rotationPartLeft.touchRotLimit = Utils.degToRad(Utils.getNoNil(getXMLString(self.xmlFile, "vehicle.rotationPartLeft#touchRotLimit"), 10));
  64. end;
  65.  
  66. self.Belka = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.Belka#index"));
  67. setVisibility((self.Belka), false);
  68.  
  69. self.Sruba = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.Sruba#index"));
  70. setVisibility((self.Sruba), true);
  71.  
  72. self.Tur = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.Tur#index"));
  73. setVisibility((self.Tur), true);
  74.  
  75. self.PitchArm = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.TractorAnimations.PitchArm#Index"));
  76. self.PitchArmRefNode = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.TractorAnimations.PitchArm#refNode"));
  77.  
  78. self.ScrollParts = Utils.loadScrollers(self.components, self.xmlFile, "vehicle.Paski.Pasek", {}, false);
  79.  
  80. local maska = Utils.indexToObject(self.rootNode, getXMLString(self.xmlFile, "vehicle.maska#index"));
  81. if maska ~= nil then
  82. self.maska = maska;
  83. end;
  84.  
  85. local drzwi_lewe = Utils.indexToObject(self.rootNode, getXMLString(self.xmlFile, "vehicle.drzwi_lewe#index"));
  86. if drzwi_lewe ~= nil then
  87. self.drzwi_lewe = drzwi_lewe;
  88. end;
  89.  
  90. local drzwi_prawe = Utils.indexToObject(self.rootNode, getXMLString(self.xmlFile, "vehicle.drzwi_prawe#index"));
  91. if drzwi_prawe ~= nil then
  92. self.drzwi_prawe = drzwi_prawe;
  93. end;
  94.  
  95. local zaczep = Utils.indexToObject(self.rootNode, getXMLString(self.xmlFile, "vehicle.zaczep#index"));
  96. if zaczep ~= nil then
  97. self.zaczep = zaczep;
  98. end;
  99.  
  100. self.swiatlo_vis = Utils.indexToObject(self.components, getXMLString(self.xmlFile,"vehicle.swiatlo2#index"));
  101. self.swiatlo2 = true;
  102. setVisibility(self.swiatlo_vis, not self.swiatlo2);
  103.  
  104. openSoundFile = Utils.getFilename("Dzwieki/Elementy/maska_otwieranie.wav", self.baseDirectory);
  105. self.openSoundId = createSample("Sample");
  106. loadSample(self.openSoundId, openSoundFile, false);
  107. self.openPlaying = false;
  108.  
  109. clouseSoundFile = Utils.getFilename("Dzwieki/Elementy/maska_otwieranie.wav", self.baseDirectory);
  110. self.clouseSoundId = createSample("Sample");
  111. loadSample(self.clouseSoundId, clouseSoundFile, false);
  112. self.clousePlaying = false;
  113.  
  114. open1SoundFile = Utils.getFilename("Dzwieki/Elementy/zamknij.wav", self.baseDirectory);
  115. self.open1SoundId = createSample("Sample");
  116. loadSample(self.open1SoundId, open1SoundFile, false);
  117. self.open1Playing = false;
  118.  
  119. clouse1SoundFile = Utils.getFilename("Dzwieki/Elementy/otworz.wav", self.baseDirectory);
  120. self.clouse1SoundId = createSample("Sample");
  121. loadSample(self.clouse1SoundId, clouse1SoundFile, false);
  122. self.clouse1Playing = false;
  123.  
  124. open2SoundFile = Utils.getFilename("Dzwieki/Elementy/zamknij.wav", self.baseDirectory);
  125. self.open2SoundId = createSample("Sample");
  126. loadSample(self.open2SoundId, open2SoundFile, false);
  127. self.open2Playing = false;
  128.  
  129. clouse2SoundFile = Utils.getFilename("Dzwieki/Elementy/otworz.wav", self.baseDirectory);
  130. self.clouse2SoundId = createSample("Sample");
  131. loadSample(self.clouse2SoundId, clouse2SoundFile, false);
  132. self.clouse2Playing = false;
  133.  
  134. wycieraczkaSoundFile = Utils.getFilename("Dzwieki/Elementy/wycieraczka.wav", self.baseDirectory);
  135. self.wycieraczkaSoundId = createSample("LizardHor12nSound");
  136. loadSample(self.wycieraczkaSoundId, wycieraczkaSoundFile, false);
  137. self.wycieraczkaPlaying = false;
  138.  
  139. self.deszcz0 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz0#index"));
  140. self.deszcz1 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz1#index"));
  141. self.deszcz2 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz2#index"));
  142. self.deszcz3 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz3#index"));
  143. self.deszcz4 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz4#index"));
  144. self.deszcz5 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz5#index"));
  145. self.deszcz6 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz6#index"));
  146. self.deszcz7 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz7#index"));
  147. self.deszcz8 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz8#index"));
  148. self.deszcz9 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz9#index"));
  149. self.deszcz10 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz10#index"));
  150. self.deszcz11 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz11#index"));
  151. self.deszcz12 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz12#index"));
  152. self.deszcz13 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz13#index"));
  153. self.deszcz14 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.deszcz14#index"));
  154.  
  155. self.isSelectable = true;
  156.  
  157. self.armNode = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.armNode#index"));
  158. setVisibility((self.armNode), true);
  159.  
  160. self.armNode_act = true;
  161.  
  162. self.drzwi_zamkniete = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.drzwi_zamkniete#index"));
  163. setVisibility((self.drzwi_zamkniete), true);
  164.  
  165. self.drzwi_otwarte = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.drzwi_otwarte#index"));
  166. setVisibility((self.drzwi_otwarte), false);
  167.  
  168. self.drzwi_zamkniete_1 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.drzwi_zamkniete_1#index"));
  169. setVisibility((self.drzwi_zamkniete_1), true);
  170.  
  171. self.drzwi_otwarte_1 = Utils.indexToObject(self.components, getXMLString(self.xmlFile, "vehicle.drzwi_otwarte_1#index"));
  172. setVisibility((self.drzwi_otwarte_1), false);
  173. end;
  174.  
  175. function C360:delete()
  176. if self.wycieraczkaPlaying ~= nil then
  177. delete(self.wycieraczkaSoundId)
  178. end;
  179. end;
  180.  
  181. function C360:attachImplement(implement)
  182. local jointType = implement.object.attacherJoint.jointType;
  183. local jointIndex = implement.jointDescIndex;
  184.  
  185. if jointType == Vehicle.JOINTTYPE_IMPLEMENT then
  186. if jointIndex == 1 then
  187. setVisibility((self.Belka), false);
  188. setVisibility((self.Sruba), true);
  189. end;
  190. end;
  191. if jointType == Vehicle.JOINTTYPE_TRAILER then
  192. if jointIndex == 2 then
  193. setVisibility((self.Belka), true);
  194. setVisibility((self.Sruba), false);
  195. end;
  196. elseif jointType == Vehicle.JOINTTYPE_TRAILERLOW then
  197. if jointIndex == 3 then
  198. setVisibility((self.Belka), true);
  199. setVisibility((self.Sruba), false);
  200. end;
  201. end;
  202. if jointType == Vehicle.JOINTTYPE_ATTACHABLEFRONTLOADER then
  203. if jointIndex == 4 then
  204. setVisibility((self.Tur), false);
  205. end;
  206. end;
  207. self.updateJoint = true;
  208. end;
  209.  
  210. function C360:detachImplement(implementIndex)
  211. local implement = self.attachedImplements[implementIndex];
  212. local jointIndex = implement.jointDescIndex;
  213.  
  214. if jointIndex == 1 then
  215. setVisibility((self.Belka), true);
  216. setVisibility((self.Sruba), false);
  217. end;
  218. if jointIndex == 2 then
  219. setVisibility((self.Belka), true);
  220. setVisibility((self.Sruba), false);
  221. end
  222. if jointIndex == 3 then
  223. setVisibility((self.Belka), true);
  224. setVisibility((self.Sruba), false);
  225. end;
  226.  
  227. if jointIndex == 4 then
  228. setVisibility((self.Tur), true);
  229. end;
  230. end;
  231.  
  232. function C360:keyEvent(unicode, sym, modifier, isDown)
  233. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  234. if isDown and sym == Input.KEY_KP_9 then
  235. self.swiatlo2 = not self.swiatlo2;
  236. end;
  237. end;
  238.  
  239. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  240. if isDown and sym == Input.KEY_KP_7 then
  241. self.wycieraczka = not self.wycieraczka;
  242. end;
  243. end;
  244. end;
  245.  
  246. function C360:update(dt)
  247. if self.animationParts[4].clipEndTime then
  248. setVisibility(self.drzwi_otwarte,true);
  249. setVisibility(self.drzwi_zamkniete,false);
  250. --setRigidBodyType(drzwi_otwarte, "NoRigidBody");
  251. else
  252. setVisibility(self.drzwi_otwarte,false);
  253. setVisibility(self.drzwi_zamkniete,true);
  254. --setRigidBodyType(self.drzwi_otwarte, "Dynamic");
  255. end;
  256.  
  257. if self.animationParts[5].clipEndTime then
  258. setVisibility(self.drzwi_otwarte_1,true);
  259. setVisibility(self.drzwi_zamkniete_1,false);
  260. --setRigidBodyType(drzwi_otwarte_1, "NoRigidBody");
  261. else
  262. setVisibility(self.drzwi_otwarte_1,false);
  263. setVisibility(self.drzwi_zamkniete_1,true);
  264. --setRigidBodyType(self.drzwi_otwarte_1, "Dynamic");
  265. end;
  266.  
  267.  
  268. --[[if self.camIndex == 1 then
  269. setVisibility(self.armNode, true);
  270. else
  271. setVisibility(self.armNode, false);
  272. end;]]
  273.  
  274. if self.isMotorStarted then
  275. self:setAnimationTime(26, self.animationParts[26].animDuration);
  276. else
  277. self:setAnimationTime(26, self.animationParts[26].offSet);
  278. end;
  279.  
  280. if g_currentMission.environment.lastRainScale > 0.1 and g_currentMission.environment.timeSinceLastRain < 30 then
  281. setVisibility(self.deszcz0, true);
  282. setVisibility(self.deszcz1, true);
  283. setVisibility(self.deszcz2, true);
  284. setVisibility(self.deszcz3, true);
  285. setVisibility(self.deszcz4, true);
  286. setVisibility(self.deszcz5, true);
  287. setVisibility(self.deszcz6, true);
  288. setVisibility(self.deszcz7, true);
  289. setVisibility(self.deszcz8, true);
  290. setVisibility(self.deszcz9, true);
  291. setVisibility(self.deszcz10, true);
  292. setVisibility(self.deszcz11, true);
  293. setVisibility(self.deszcz12, true);
  294. setVisibility(self.deszcz13, true);
  295. setVisibility(self.deszcz14, true);
  296. else
  297. setVisibility(self.deszcz0, false);
  298. setVisibility(self.deszcz1, false);
  299. setVisibility(self.deszcz2, false);
  300. setVisibility(self.deszcz3, false);
  301. setVisibility(self.deszcz4, false);
  302. setVisibility(self.deszcz5, false);
  303. setVisibility(self.deszcz6, false);
  304. setVisibility(self.deszcz7, false);
  305. setVisibility(self.deszcz8, false);
  306. setVisibility(self.deszcz9, false);
  307. setVisibility(self.deszcz10, false);
  308. setVisibility(self.deszcz11, false);
  309. setVisibility(self.deszcz12, false);
  310. setVisibility(self.deszcz13, false);
  311. setVisibility(self.deszcz14, false);
  312. end;
  313.  
  314. if self.PitchArm ~= nil then
  315. local x, y, z = getRotation(self.PitchArmRefNode);
  316. setRotation(self.PitchArm, x * (-1.5), y, z);
  317. end;
  318.  
  319. if self.setHydraulicTime > 0 then
  320. for k,v in pairs(self.hydraulics) do
  321. self:setHydraulicDirection(k);
  322. end;
  323. self.setHydraulicTime = self.setHydraulicTime - 1;
  324. end;
  325.  
  326. if self:getIsActive() then
  327. self.setHydraulicTime = 30;
  328. end;
  329.  
  330. if self:getIsActive() then
  331. if self.rotationPartLeft ~= nil then
  332. local x, y, z = getRotation(self.rotationPartLeft.node);
  333. x = (self.rotationPartLeft.maxRot[1] - self.rotationPartLeft.minRot[1]) * (self.rotatedTime/-1);
  334. setRotation(self.rotationPartLeft.node, x, y ,z);
  335. end;
  336. end;
  337.  
  338. if self.isMotorStarted then
  339. self:setAnimationTime(1, 1);
  340. self:setAnimationTime(7, 1);
  341. self:setAnimationTime(23, 1);
  342. self:setAnimationTime(24, 1);
  343. self:setAnimationTime(25, 1);
  344. else
  345. self:setAnimationTime(1, 0);
  346. self:setAnimationTime(7, 0);
  347. self:setAnimationTime(23, 0);
  348. self:setAnimationTime(24, 0);
  349. self:setAnimationTime(25, 0);
  350. end;
  351.  
  352. if self.isClient then
  353. Utils.updateScrollers(self.ScrollParts, dt, self.isMotorStarted);
  354. end;
  355.  
  356. local nearestDistance = 1;
  357. local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
  358. local px, py, pz = getWorldTranslation(self.maska);
  359. local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
  360. if distance < nearestDistance then
  361. self.przy_maska = true;
  362. else
  363. self.przy_maska = false;
  364. end;
  365.  
  366. if self.przy_maska then
  367. if InputBinding.hasEvent(InputBinding.maska_c360) then
  368. if self.animationParts[2].clipEndTime then
  369. self:setAnimationTime(2, self.animationParts[2].offSet);
  370. self.sound1 = false;
  371. self.sound2 = true;
  372. elseif self.animationParts[2].clipStartTime then
  373. self:setAnimationTime(2, self.animationParts[2].animDuration);
  374. self.sound1 = true;
  375. self.sound2 = false;
  376. end;
  377. end;
  378. end;
  379.  
  380. if self.przy_maska then
  381. if self.animationParts[2].clipStartTime then
  382. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_maska_c360")), InputBinding.maska_c360);
  383. else
  384. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_maska_c360")), InputBinding.maska_c360);
  385. end;
  386. end;
  387.  
  388. if self.isEntered then
  389. setVisibility(self.swiatlo_vis, not self.swiatlo2);
  390. end;
  391.  
  392.  
  393. if self.isEntered then
  394. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  395. if self.swiatlo2 then
  396. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("wlacz_swiatlo2_c360")), InputBinding.swiatlo2_c360);
  397. else
  398. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("wylacz_swiatlo2_c360")), InputBinding.swiatlo2_c360);
  399. end;
  400. end;
  401. end;
  402.  
  403. if self.sound1 then
  404. if not self.openPlaying then
  405. playSample(self.openSoundId, 1, 3, 3);
  406. self.openPlaying = true;
  407. end;
  408. else
  409. if self.openPlaying then
  410. stopSample(self.openSoundId);
  411. self.openPlaying = false;
  412. end;
  413. end;
  414.  
  415. if self.sound2 then
  416. if not self.clousePlaying then
  417. playSample(self.clouseSoundId, 1, 3, 3);
  418. self.clousePlaying = true;
  419. end;
  420. else
  421. if self.clousePlaying then
  422. stopSample(self.clouseSoundId);
  423. self.clousePlaying = false;
  424. end;
  425. end;
  426.  
  427. if self.sound3 then
  428. if not self.open1Playing then
  429. playSample(self.open1SoundId, 1, 3, 3);
  430. self.open1Playing = true;
  431. end;
  432. else
  433. if self.open1Playing then
  434. stopSample(self.open1SoundId);
  435. self.open1Playing = false;
  436. end;
  437. end;
  438.  
  439. if self.sound4 then
  440. if not self.clouse1Playing then
  441. playSample(self.clouse1SoundId, 1, 3, 3);
  442. self.clouse1Playing = true;
  443. end;
  444. else
  445. if self.clouse1Playing then
  446. stopSample(self.clouse1SoundId);
  447. self.clouse1Playing = false;
  448. end;
  449. end;
  450.  
  451. if self.sound5 then
  452. if not self.open2Playing then
  453. playSample(self.open2SoundId, 1, 3, 3);
  454. self.open2Playing = true;
  455. end;
  456. else
  457. if self.open2Playing then
  458. stopSample(self.open2SoundId);
  459. self.open2Playing = false;
  460. end;
  461. end;
  462.  
  463. if self.sound6 then
  464. if not self.clouse2Playing then
  465. playSample(self.clouse2SoundId, 1, 3, 3);
  466. self.clouse2Playing = true;
  467. end;
  468. else
  469. if self.clouse2Playing then
  470. stopSample(self.clouse2SoundId);
  471. self.clouse2Playing = false;
  472. end;
  473. end;
  474.  
  475. if self.przy_maska then
  476. if Input.isKeyPressed(Input.KEY_n) then
  477. self:setAnimationTime(3,self.animationParts[3].animDuration);
  478. else
  479. self:setAnimationTime(3,self.animationParts[3].offSet);
  480. end;
  481. end;
  482.  
  483. if self.przy_maska then
  484. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("pompka_paliwa_c360")), InputBinding.pompka_c360);
  485. end;
  486.  
  487. local nearestDistance = 1.5;
  488. local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
  489. local px, py, pz = getWorldTranslation(self.drzwi_lewe);
  490. local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
  491. if distance < nearestDistance then
  492. self.przy_drzwi_lewe = true;
  493. else
  494. self.przy_drzwi_lewe = false;
  495. end;
  496.  
  497. if self.przy_drzwi_lewe then
  498. if InputBinding.hasEvent(InputBinding.drzwi_lewe_c360) then
  499. if self.animationParts[4].clipEndTime then
  500. self:setAnimationTime(4, self.animationParts[4].offSet);
  501. self.sound3 = true;
  502. self.sound4 = false;
  503. elseif self.animationParts[4].clipStartTime then
  504. self:setAnimationTime(4, self.animationParts[4].animDuration);
  505. self.sound3 = false;
  506. self.sound4 = true;
  507. end;
  508. end;
  509. end;
  510.  
  511. if self.isEntered then
  512. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  513. if InputBinding.hasEvent(InputBinding.drzwi_lewe_c360) then
  514. if self.animationParts[4].clipEndTime then
  515. self:setAnimationTime(4, self.animationParts[4].offSet);
  516. self.sound3 = true;
  517. self.sound4 = false;
  518. elseif self.animationParts[4].clipStartTime then
  519. self:setAnimationTime(4, self.animationParts[4].animDuration);
  520. self.sound3 = false;
  521. self.sound4 = true;
  522. end;
  523. end;
  524. end;
  525. end;
  526.  
  527. if self.isEntered then
  528. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  529. if self.animationParts[4].clipStartTime then
  530. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_drzwi_lewe_c360")), InputBinding.drzwi_lewe_c360);
  531. else
  532. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_drzwi_lewe_c360")), InputBinding.drzwi_lewe_c360);
  533. end;
  534. end;
  535. end;
  536.  
  537. if self.przy_drzwi_lewe then
  538. if self.animationParts[4].clipStartTime then
  539. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_drzwi_out_c360")), InputBinding.drzwi_lewe_c360);
  540. else
  541. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_drzwi_out_c360")), InputBinding.drzwi_lewe_c360);
  542. end;
  543. end;
  544.  
  545. local nearestDistance = 1.5;
  546. local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
  547. local px, py, pz = getWorldTranslation(self.drzwi_prawe);
  548. local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
  549. if distance < nearestDistance then
  550. self.przy_drzwi_prawe = true;
  551. else
  552. self.przy_drzwi_prawe = false;
  553. end;
  554.  
  555. if self.przy_drzwi_prawe then
  556. if InputBinding.hasEvent(InputBinding.drzwi_prawe_c360) then
  557. if self.animationParts[5].clipEndTime then
  558. self:setAnimationTime(5, self.animationParts[5].offSet);
  559. self.sound5 = true;
  560. self.sound6 = false;
  561. elseif self.animationParts[5].clipStartTime then
  562. self:setAnimationTime(5, self.animationParts[5].animDuration);
  563. self.sound5 = false;
  564. self.sound6 = true;
  565. end;
  566. end;
  567. end;
  568.  
  569. if self.isEntered then
  570. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  571. if InputBinding.hasEvent(InputBinding.drzwi_prawe_c360) then
  572. if self.animationParts[5].clipEndTime then
  573. self:setAnimationTime(5, self.animationParts[5].offSet);
  574. self.sound5 = true;
  575. self.sound6 = false;
  576. elseif self.animationParts[5].clipStartTime then
  577. self:setAnimationTime(5, self.animationParts[5].animDuration);
  578. self.sound5 = false;
  579. self.sound6 = true;
  580. end;
  581. end;
  582. end;
  583. end;
  584.  
  585. if self.isEntered then
  586. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  587. if self.animationParts[5].clipStartTime then
  588. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_drzwi_prawe_c360")), InputBinding.drzwi_prawe_c360);
  589. else
  590. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_drzwi_prawe_c360")), InputBinding.drzwi_prawe_c360);
  591. end;
  592. end;
  593. end;
  594.  
  595. if self.przy_drzwi_prawe then
  596. if self.animationParts[5].clipStartTime then
  597. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_drzwi_out_c360")), InputBinding.drzwi_prawe_c360);
  598. else
  599. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_drzwi_out_c360")), InputBinding.drzwi_prawe_c360);
  600. end;
  601. end;
  602.  
  603. if self.realLightsActive then
  604. self:setAnimationTime(6,self.animationParts[6].animDuration);
  605. else
  606. self:setAnimationTime(6,self.animationParts[6].offSet);
  607. end;
  608.  
  609. if self.isClient then
  610. if self.isEntered then
  611. if not self.brakeLightsVisibility then
  612. if self.animationParts[8].clipEndTime then
  613. self:setAnimationTime(8, self.animationParts[8].offSet);
  614. end;
  615. end;
  616. if self.brakeLightsVisibility then
  617. if self.animationParts[8].clipStartTime then
  618. self:setAnimationTime(8, self.animationParts[8].animDuration);
  619. end;
  620. end;
  621. end;
  622. end;
  623.  
  624. if self.handbrake then
  625. self:setAnimationTime(9,self.animationParts[9].animDuration);
  626. else
  627. self:setAnimationTime(9,self.animationParts[9].offSet);
  628. end;
  629.  
  630. if self.isEntered then
  631. if self.movingDirection > 0 then
  632. if not self.isHired then
  633. if Input.isKeyPressed(Input.KEY_w) or self.lastSpeed*3600 > 1 then
  634. self:setAnimationTime(11,self.animationParts[11].animDuration);
  635. else
  636. self:setAnimationTime(11,self.animationParts[11].offSet);
  637. end;
  638. end;
  639. end;
  640. end;
  641.  
  642. if self.isEntered then
  643. if not self.brakeLightsVisibility then
  644. if not self.isHired then
  645. if self.movingDirection < 0 then
  646. if Input.isKeyPressed(Input.KEY_s) and self.lastSpeed*3600 > 1 then
  647. self:setAnimationTime(12,self.animationParts[12].animDuration);
  648. else
  649. self:setAnimationTime(12,self.animationParts[12].offSet);
  650. end;
  651. end;
  652. end;
  653. end;
  654. end;
  655.  
  656. if self.isEntered then
  657. if not self.brakeLightsVisibility and self.lastSpeed*3600 < 1 then
  658. if Input.isKeyPressed(Input.KEY_w) or Input.isKeyPressed(Input.KEY_s) then
  659. self:setAnimationTime(22,self.animationParts[22].animDuration);
  660. else
  661. self:setAnimationTime(22,self.animationParts[22].offSet);
  662. end;
  663. end;
  664. end;
  665.  
  666. local nearestDistance = 1;
  667. local vx, vy, vz = getWorldTranslation(g_currentMission.player.rootNode);
  668. local px, py, pz = getWorldTranslation(self.zaczep);
  669. local distance = Utils.vector3Length(px-vx, py-vy, pz-vz);
  670. if distance < nearestDistance then
  671. self.przy_zaczep = true;
  672. else
  673. self.przy_zaczep = false;
  674. end;
  675.  
  676. if self.isEntered then
  677. if self.wycieraczka then
  678. self:setAnimationTime(14, 1);
  679. self.sound7 = true;
  680. else
  681. self:setAnimationTime(14, 0);
  682. self.sound7 = false;
  683. end;
  684. end;
  685.  
  686. if self.isEntered then
  687. if self.sound7 then
  688. if not self.wycieraczkaPlaying then
  689. playSample(self.wycieraczkaSoundId, 0, 1, 0);
  690. self.wycieraczkaPlaying = true;
  691. end;
  692. else
  693. if self.wycieraczkaPlaying then
  694. stopSample(self.wycieraczkaSoundId);
  695. self.wycieraczkaPlaying = false;
  696. end;
  697. end;
  698. end;
  699.  
  700. if not self.isEntered then
  701. if self.sound7 then
  702. if self.wycieraczkaPlaying then
  703. stopSample(self.wycieraczkaSoundId);
  704. self.wycieraczkaPlaying = false;
  705. end;
  706. end;
  707. end;
  708.  
  709. if self.isEntered then
  710. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  711. if InputBinding.hasEvent(InputBinding.dach_c360) then
  712. if self.animationParts[15].clipEndTime then
  713. self:setAnimationTime(15, self.animationParts[15].offSet);
  714. elseif self.animationParts[15].clipStartTime then
  715. self:setAnimationTime(15, self.animationParts[15].animDuration);
  716. end;
  717. end;
  718. end;
  719. end;
  720.  
  721. if self.isEntered then
  722. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  723. if self.animationParts[15].clipStartTime then
  724. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_dach_c360")), InputBinding.dach_c360);
  725. else
  726. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_dach_c360")), InputBinding.dach_c360);
  727. end;
  728. end;
  729. end;
  730.  
  731. if self.isEntered then
  732. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  733. if InputBinding.hasEvent(InputBinding.szyba_c360) then
  734. if self.animationParts[16].clipEndTime then
  735. self:setAnimationTime(16, self.animationParts[16].offSet);
  736. elseif self.animationParts[16].clipStartTime then
  737. self:setAnimationTime(16, self.animationParts[16].animDuration);
  738. end;
  739. end;
  740. end;
  741. end;
  742.  
  743. if self.isEntered then
  744. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  745. if self.animationParts[16].clipStartTime then
  746. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("otworz_szyba_c360")), InputBinding.szyba_c360);
  747. else
  748. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("zamknij_szyba_c360")), InputBinding.szyba_c360);
  749. end;
  750. end;
  751. end;
  752.  
  753. if self.isEntered then
  754. if self.lastSpeed*3600 > 12 then
  755. self:setAnimationTime(17,self.animationParts[17].animDuration);
  756. else
  757. self:setAnimationTime(17,self.animationParts[17].offSet);
  758. end;
  759. end;
  760.  
  761. if self.isEntered then
  762. if self.movingDirection > 0 then
  763. if self.lastSpeed*3600 > 1 then
  764. if Input.isKeyPressed(Input.KEY_w) then
  765. self:setAnimationTime(18,self.animationParts[18].animDuration);
  766. else
  767. self:setAnimationTime(18,self.animationParts[18].offSet);
  768. end;
  769. end;
  770. end;
  771. end;
  772.  
  773. if self.isEntered then
  774. if self.movingDirection < 0 then
  775. if self.lastSpeed*3600 > 1 then
  776. if Input.isKeyPressed(Input.KEY_s) then
  777. self:setAnimationTime(18,self.animationParts[18].animDuration);
  778. else
  779. self:setAnimationTime(18,self.animationParts[18].offSet);
  780. end;
  781. end;
  782. end;
  783. end;
  784.  
  785. if self.isEntered then
  786. if Input.isKeyPressed(Input.KEY_b) then
  787. if self.animationParts[20].clipEndTime then
  788. self:setAnimationTime(20, self.animationParts[20].offSet);
  789. elseif self.animationParts[20].clipStartTime then
  790. self:setAnimationTime(20, self.animationParts[20].animDuration);
  791. end;
  792. end;
  793. end;
  794.  
  795. if self.isEntered then
  796. if Input.isKeyPressed(Input.KEY_0) then
  797. self:setAnimationTime(21,self.animationParts[21].animDuration);
  798. else
  799. self:setAnimationTime(21,self.animationParts[21].offSet);
  800. end;
  801. end;
  802.  
  803. if self.isEntered then
  804. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  805. if self.wycieraczka then
  806. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("wycieraczka_stop_c360")), InputBinding.wycieraczka_c360);
  807. else
  808. g_currentMission:addHelpButtonText(string.format(g_i18n:getText("wycieraczka_c360")), InputBinding.wycieraczka_c360);
  809. end;
  810. end;
  811. end;
  812.  
  813. if self.armNode_act then
  814. setVisibility(self.armNode,true);
  815. else
  816. setVisibility(self.armNode,false);
  817. end;
  818.  
  819. if self.isEntered then
  820. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  821. if InputBinding.hasEvent(InputBinding.armNode_1) then
  822. self.armNode_act = not self.armNode_act;
  823. end;
  824. end;
  825. end;
  826. end;
  827.  
  828. function C360:loadFromAttributesAndNodes(savegame, key, resetVehicles)
  829. if not resetVehicles then
  830. local armNode_act = getXMLBool(self.xmlFile, key.."#armNode_act");
  831.  
  832. if armNode_act ~= nil then
  833. self.armNode_act = armNode_act;
  834. end;
  835. end;
  836. return BaseMission.VEHICLE_LOAD_OK;
  837. end;
  838.  
  839. function C360:getSaveAttributesAndNodes(nodeIdent)
  840. if self.armNode_act then
  841. armNode_act = "true";
  842. else
  843. armNode_act = "false";
  844. end;
  845.  
  846. local attributes = string.format('armNode_act="%s"',armNode_act);
  847. return attributes,nodes;
  848. end;
  849.  
  850. function C360:setHydraulicDirection(index)
  851. local hydraulic = self.hydraulics[index];
  852.  
  853. if hydraulic.fixPoint ~= nil then
  854. local ax, ay, az = getWorldTranslation(hydraulic.node);
  855. local bx, by, bz = getWorldTranslation(hydraulic.fixPoint);
  856. local x, y, z = worldDirectionToLocal(getParent(hydraulic.node), bx-ax, by-ay, bz-az);
  857. local xUp, yUp, zUp = unpack(hydraulic.upVectors);
  858. setDirection(hydraulic.node, x, y, z, xUp, yUp, zUp);
  859. if hydraulic.punch ~= nil then
  860. local distance = Utils.vector3Length(ax-bx, ay-by, az-bz);
  861. setTranslation(hydraulic.punch, 0, 0, distance-hydraulic.punchDistance);
  862. end;
  863. end;
  864. end;
  865.  
  866. function C360:setRopePanel(isRopePanel)
  867. end;
  868.  
  869. function C360:mouseEvent(posX, posY, isDown, isUp, button)
  870. end;
  871.  
  872. function C360:validateAttacherJoint(implement, jointDesc, dt)
  873. return true;
  874. end;
  875.  
  876. function C360:draw()
  877. if self.isEntered then
  878. if self:getIsActiveForInput(self.needsSelection) and not self:hasInputConflictWithSelection() then
  879. g_currentMission:addExtraPrintText(g_i18n:getText("funkcje_1"));
  880. if Input.isKeyPressed(Input.KEY_lshift) then
  881. if self.animacja_act then
  882. setTextBold(true);
  883. renderText(0.72, 0.77, 0.015, g_i18n:getText("animacja_2"));
  884. else
  885. setTextBold(true);
  886. renderText(0.72, 0.77, 0.015, g_i18n:getText("animacja_1"));
  887. end;
  888. end;
  889. end;
  890. end;
  891. end;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement