Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2018
66
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.76 KB | None | 0 0
  1. function swol_torchImage::onMount(%db,%pl,%slot)
  2. {
  3. if(%im = %pl.getMountedImage(0))
  4. {
  5. if(%im.armReady)
  6. {
  7. %pl.playThread(1,armReadyBoth);
  8. }
  9. else
  10. {
  11. %pl.playThread(1,armReadyLeft);
  12. }
  13. }
  14. else
  15. {
  16. %pl.playThread(1,armReadyLeft);
  17. }
  18. %pl.lastTorchTime = getSimTime();
  19. }
  20. function swol_torchImage::onIgnite(%db,%pl,%slot)
  21. {
  22. serverPlay3D(swol_torchIgniteSound,%pl.getPosition());
  23. %pl.playThread(3,plant);
  24. %pl.startTorchSched = %db.schedule(150,mountLight,%pl,%slot);
  25. }
  26. function swol_torchImage::mountLight(%db,%pl,%slot)
  27. {
  28. %pl.light = new fxLight()
  29. {
  30. datablock = swol_torchLight;
  31. };
  32. missionCleanup.add(%pl.light);
  33. %pl.light.setTransform(%pl.getPosition());
  34. %pl.light.attachToObject(%pl);
  35. %pl.light.player = %pl;
  36. %pl.playAudio(2,swol_torchLoopSound);
  37. }
  38. function swol_torchImage::putOutTorch(%db,%pl,%slot)
  39. {
  40. if(isObject(%pl.light))
  41. {
  42. %pl.light.delete();
  43. %pl.playAudio(2,swol_torchEndSound);
  44. %pl.schedule(1,mountImage,swol_torchImageEnd,1);
  45. %db.schedule(1800,unMountEnd,%pl,%slot);
  46. %pl.playThread(3,plant);
  47. }
  48. else
  49. {
  50. cancel(%pl.startTorchSched);
  51. }
  52. }
  53. function swol_torchImage::unMountEnd(%db,%pl,%slot)
  54. {
  55. if(%im = %pl.getMountedImage(1))
  56. {
  57. if(%im == nameToId(swol_torchImageEnd))
  58. {
  59. %pl.unMountImage(1);
  60. %pl.playThread(1,root);
  61. if(%im = %pl.getMountedImage(0))
  62. {
  63. if(%im.armReady)
  64. {
  65. %pl.playThread(1,armReadyRight);
  66. }
  67. }
  68. }
  69. }
  70. }
  71. function swol_torchImage::unMountCheck(%db,%pl,%slot)
  72. {
  73. if(!isObject(%pl.getMountedImage(0)))
  74. %pl.playThread(1,armReadyLeft);
  75. }
  76. function swol_torchImageEnd::unMountCheck(%db,%pl,%slot)
  77. {
  78. if(!isObject(%pl.getMountedImage(0)))
  79. %pl.playThread(1,armReadyLeft);
  80. }
  81. function swol_torchImage::onUnMount(%db,%pl,%slot)
  82. {
  83. if(isObject(%pl.light))
  84. {
  85. %pl.light.delete();
  86. %pl.playAudio(2,swol_torchEndSound);
  87. }
  88. else
  89. {
  90. cancel(%pl.startTorchSched);
  91. }
  92. %pl.lastTorchTime = getSimTime();
  93.  
  94. }
  95. package swol_torchLightReplace
  96. {
  97. function player::updateArm(%pl,%image)
  98. {
  99. if(!%leftimage = %pl.getMountedImage(1))
  100. return parent::updateArm(%pl,%image);
  101. if(!%leftimage.isLeftHandLight && !%leftimage.leftHandKeepUp)
  102. return parent::updateArm(%pl,%image);
  103. if(%image.armReady)
  104. {
  105. if(!isObject(%pl.getMountedImage(0)))
  106. %pl.playThread(1,armReadyBoth);
  107. }
  108. }
  109. function WeaponImage::onUnMount(%db,%pl,%slot)
  110. {
  111. if(%slot != 0)
  112. return parent::onUnMount(%db,%pl,%slot);
  113. if(!%leftimage = %pl.getMountedImage(1))
  114. return parent::onUnMount(%db,%pl,%slot);
  115. if(!%leftimage.isLeftHandLight && !%leftimage.leftHandKeepUp)
  116. return parent::onUnMount(%db,%pl,%slot);
  117. %leftimage.schedule(1,unMountCheck,%pl,%slot);
  118. if(%db.showBricks)
  119. {
  120. if(isObject(%cl = %pl.client))
  121. commandToClient(%cl,'ShowBricks',0);
  122. }
  123. }
  124. function player::hideNode(%pl,%node)
  125. {
  126. if(%node $= "lhook" || %node $= "lhand")
  127. {
  128. if(isObject(%im = %pl.getMountedImage(1)))
  129. {
  130. if(%im.isLeftHandLight)
  131. {
  132. %pl.unMountImage(1);
  133. %pl.playThread(2,root);
  134. }
  135. }
  136. }
  137. parent::hideNode(%pl,%node);
  138. }
  139. function serverCmdLight(%cl)
  140. {
  141. if(!isObject(%pl = %cl.player))
  142. return parent::serverCmdLight(%cl);
  143. if(isObject(%im = %pl.getMountedImage(0)))
  144. {
  145. if(isObject(%im.item))
  146. {
  147. if(%im.item $= ND_Item)
  148. return parent::serverCmdLight(%cl);
  149. }
  150. }
  151.  
  152. if(!isObject(%im = %pl.getMountedImage(1)))
  153. {
  154. if(getSimTime()-%pl.lastTorchTime > 2500)
  155. {
  156. if(%pl.isNodeVisible("lhand")+%pl.isNodeVisible("lhook") > 0)
  157. %pl.mountImage(swol_torchImage,1);
  158. }
  159. }
  160. else if(%im == nameToId(swol_torchImage))
  161. {
  162. if(getSimTime()-%pl.lastTorchTime > 1100)
  163. {
  164. swol_torchImage.putOutTorch(%pl,1);
  165. }
  166. }
  167. }
  168. };
  169. activatePackage(swol_torchLightReplace);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement