Arngrim

bttf controller.vbs

Apr 3rd, 2017
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 55.21 KB | None | 0 0
  1. ' Back to the Future Collectors Edition
  2. ' Based on Back to the Future / IPD No. 126 / Data East June, 1990 / 4 Players
  3. ' VP911 version 1.0 by JPSalas Mars 2011
  4.  
  5.  
  6. Option Explicit
  7. Randomize
  8.  
  9. On Error Resume Next
  10. ExecuteGlobal GetTextFile("controller.vbs")
  11. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  12. On Error Goto 0
  13.  
  14. LoadVPM "01560000", "DE.VBS", 3.26
  15.  
  16. '********************
  17. 'Standard definitions
  18. '********************
  19.  
  20. Const cGameName = "bttf_a27"
  21. Const UseSolenoids = 1
  22. Const UseLamps = 0
  23. Const UseGI = 0
  24. Const UseSync = 0
  25. Const HandleMech = 0
  26.  
  27. ' Standard Sounds
  28. Const SSolenoidOn = "Solenoid"
  29. Const SSolenoidOff = ""
  30. Const SFlipperOn = "FlipperUp"
  31. Const SFlipperOff = "FlipperDown"
  32. Const SCoin = "Coin"
  33.  
  34. Dim bsTrough, bsVuk, bsTR, vLock, x, bump1, bump2, bump3, DTBank
  35.  
  36. '************
  37. ' Table init.
  38. '************
  39.  
  40. Sub Table1_Init
  41. vpmInit Me
  42. With Controller
  43. .GameName = cGameName
  44. If Err Then MsgBox "Can't start Game " & cGameName & vbNewLine & Err.Description:Exit Sub
  45. .SplashInfoLine = "Back to the Future Collectors Edition" & vbNewLine & "VP911 by JPSalas v1.0"
  46. ' DMD position and size, example
  47. '.Games(cGameName).Settings.Value("dmd_pos_x")=500
  48. '.Games(cGameName).Settings.Value("dmd_pos_y")=2
  49. '.Games(cGameName).Settings.Value("dmd_width")=400
  50. '.Games(cGameName).Settings.Value("dmd_height")=90
  51. .Games(cGameName).Settings.Value("rol") = 0 'rotate DMD to the left
  52. .HandleKeyboard = 0
  53. .ShowTitle = 0
  54. .ShowDMDOnly = 1
  55. .ShowFrame = 0
  56. .HandleMechanics = 0
  57. .Hidden = 0
  58. On Error Resume Next
  59. .Run GetPlayerHWnd
  60. If Err Then MsgBox Err.Description
  61. On Error Goto 0
  62. End With
  63.  
  64. ' Nudging
  65. vpmNudge.TiltSwitch = swTilt
  66. vpmNudge.Sensitivity = 1
  67. vpmNudge.TiltObj = Array(bumper1, bumper2, bumper3, LeftSlingshot, RightSlingshot)
  68.  
  69. ' Trough
  70. Set bsTrough = New cvpmBallStack
  71. With bsTrough
  72. .InitSw 0, 13, 12, 11, 0, 0, 0, 0
  73. .InitKick BallRelease, 90, 4
  74. .InitExitSnd SoundFX("ballrel",DOFContactors), SoundFX("Solenoid",DOFContactors)
  75. .Balls = 3
  76. End With
  77.  
  78. ' Vuk
  79. Set bsVuk = New cvpmBallStack
  80. With bsVuk
  81. .InitSw 0, 29, 0, 0, 0, 0, 0, 0
  82. .InitKick sw29a, 160, 16
  83. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  84. End With
  85.  
  86. ' Drop Targets
  87.  
  88.  
  89. Set DTBank = New cvpmDropTarget
  90. With DTBank
  91. .InitDrop Array(Array(sw41,sw41a),Array(sw42,sw42a),Array(sw43,sw43a)), Array(41,42,43)
  92. .Initsnd SoundFX("droptarget",DOFDropTargets), SoundFX("resetdrop",DOFContactors)
  93. End With
  94.  
  95. ' Top Right Saucer
  96. Set bsTR = New cvpmBallStack
  97. With bsTR
  98. .InitSaucer sw45, 45, 194, 20
  99. .KickForceVar = 2
  100. .KickBalls = 1
  101. .InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  102. End With
  103.  
  104. ' Visible Lock
  105. Set vLock = New cvpmVLock2
  106. With vLock
  107. .InitVLock Array(sw38, sw39, sw40), Array(sw38k, sw39k, sw40k), Array(38, 39, 40)
  108. .InitSnd SoundFX("Solenoid",DOFContactors), SoundFX("Solenoid",DOFContactors)
  109. .ExitDir = 194
  110. .ExitForce = 8
  111. .CreateEvents "vLock"
  112. End With
  113.  
  114. ' Main Timer init
  115. PinMAMETimer.Interval = PinMameInterval
  116. PinMAMETimer.Enabled = 1
  117.  
  118. ' reset sling posts
  119. LeftSlingshotpostb.IsDropped = true
  120. LeftSlingshotpostc.IsDropped = true
  121. LeftSlingshotpostd.IsDropped = true
  122.  
  123. RightSlingshotpostb.IsDropped = true
  124. RightSlingshotpostc.IsDropped = true
  125. RightSlingshotpostd.IsDropped = true
  126.  
  127.  
  128.  
  129.  
  130.  
  131. sw33a.IsDropped = 1:sw34a.IsDropped = 1:sw35a.IsDropped = 1:sw36a.IsDropped = 1:sw37a.IsDropped = 1
  132. sw25a.IsDropped = 1:sw26a.IsDropped = 1:sw27a.IsDropped = 1
  133. bump1 = 0:bump2 = 0:bump3 = 0
  134. Llogo2.IsDropped = 1:Rlogo2.IsDropped = 1
  135. SolGi 1
  136.  
  137. StartLampTimer
  138.  
  139. End Sub
  140.  
  141. Sub table1_Paused:Controller.Pause = 1:End Sub
  142. Sub table1_unPaused:Controller.Pause = 0:End Sub
  143.  
  144. '**********
  145. ' Keys
  146. '**********
  147.  
  148. Sub table1_KeyDown(ByVal Keycode)
  149. If KeyDownHandler(KeyCode) Then Exit Sub
  150. If keycode = PlungerKey Then Plunger.Pullback:'Pcount = 0:'PTime.Enabled = 1
  151. If keycode = LeftTiltKey Then LeftNudge 110, 1.8, 20
  152. If keycode = RightTiltKey Then RightNudge 250, 1.8, 20
  153. If keycode = CenterTiltKey Then CenterNudge 180, 2.8, 25
  154. End Sub
  155.  
  156. Sub table1_KeyUp(ByVal Keycode)
  157. If KeyUpHandler(KeyCode) Then Exit Sub
  158. If keycode = PlungerKey Then Plunger.Fire:'PTime.Enabled = 0:Pcount = 0:PTime2.Enabled = 1
  159. End Sub
  160.  
  161. '#############################
  162. ' Rotate Primitive Things
  163. '#############################
  164. Sub Timer_Timer()
  165. p_gate1.Rotx = gate1.CurrentAngle + 90
  166. p_gate3.Rotx = gate3.CurrentAngle + 90
  167. p_gate4.Rotx = gate4.CurrentAngle + 90
  168.  
  169. End Sub
  170.  
  171.  
  172.  
  173.  
  174. '*************************************
  175. ' Nudge System
  176. ' based on Noah's nudgetest table
  177. ' added a counterforce effect
  178. '*************************************
  179.  
  180. Dim LeftNudgeEffect, RightNudgeEffect, NudgeEffect
  181.  
  182. 'StartShake
  183.  
  184. Sub LeftNudge(angle, strength, delay)
  185. Dim a
  186. a = (strength * (delay-LeftNudgeEffect) / delay) + RightNudgeEffect / delay
  187. vpmNudge.DoNudge angle, a
  188. a = - a / 0.6:vpmTimer.AddTimer 100, "CounterForce angle, a '"
  189. LeftNudgeEffect = delay
  190. RightNudgeEffect = 0
  191. RightNudgeTimer.Enabled = 0
  192. LeftNudgeTimer.Interval = delay
  193. LeftNudgeTimer.Enabled = 1
  194. End Sub
  195.  
  196. Sub RightNudge(angle, strength, delay)
  197. Dim a
  198. a = (strength * (delay-RightNudgeEffect) / delay) + LeftNudgeEffect / delay
  199. vpmNudge.DoNudge angle, a
  200. a = - a / 0.6:vpmTimer.AddTimer 100, "CounterForce angle, a '"
  201. RightNudgeEffect = delay
  202. LeftNudgeEffect = 0
  203. LeftNudgeTimer.Enabled = 0
  204. RightNudgeTimer.Interval = delay
  205. RightNudgeTimer.Enabled = 1
  206. End Sub
  207.  
  208. Sub CenterNudge(angle, strength, delay)
  209. Dim a
  210. a = strength * (delay-NudgeEffect) / delay
  211. vpmNudge.DoNudge angle, a
  212. a = - a / 0.8:vpmTimer.AddTimer 100, "CounterForce angle, a '"
  213. NudgeEffect = delay
  214. NudgeTimer.Interval = delay
  215. NudgeTimer.Enabled = 1
  216. End Sub
  217.  
  218. Sub LeftNudgeTimer_Timer()
  219. LeftNudgeEffect = LeftNudgeEffect-1
  220. If LeftNudgeEffect = 0 then LeftNudgeTimer.Enabled = False
  221. End Sub
  222.  
  223. Sub RightNudgeTimer_Timer()
  224. RightNudgeEffect = RightNudgeEffect-1
  225. If RightNudgeEffect = 0 then RightNudgeTimer.Enabled = False
  226. End Sub
  227.  
  228. Sub NudgeTimer_Timer()
  229. NudgeEffect = NudgeEffect-1
  230. If NudgeEffect = 0 then NudgeTimer.Enabled = False
  231. End Sub
  232.  
  233. Sub CounterForce(angle, strength)
  234. Nudge angle, strength
  235. End Sub
  236.  
  237.  
  238.  
  239.  
  240. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  241. 'Slingshot animation
  242. '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  243.  
  244.  
  245. Dim LeftSlingshotStep,RightSlingshotStep
  246.  
  247.  
  248. Sub LeftSlingShot_Slingshot:LeftSlingshota.visible = false:LeftSlingshotposta.IsDropped = true:LeftSlingshotb.visible = true:LeftSlingshotpostb.IsDropped = false:PlaySound SoundFX("slingshot",DOFContactors):vpmTimer.PulseSw 21:LeftSlingshotStep = 0:Me.TimerEnabled = 1:End Sub
  249. Sub LeftSlingshot_Timer
  250. Select Case LeftSlingshotStep
  251. Case 0:LeftSlingshotb.visible = false:LeftSlingshotpostb.IsDropped = true:LeftSlingshotc.visible = true:LeftSlingshotpostc.IsDropped = false
  252. Case 1:LeftSlingshotc.visible = false:LeftSlingshotpostc.IsDropped = true:LeftSlingshotd.visible = true:LeftSlingshotpostd.IsDropped = false
  253. Case 2:LeftSlingshotd.visible = false:LeftSlingshotpostd.IsDropped = true:LeftSlingshotc.visible = true:LeftSlingshotpostc.IsDropped = false
  254. Case 3:LeftSlingshotc.visible = false:LeftSlingshotpostc.IsDropped = true:LeftSlingshotb.visible = true:LeftSlingshotpostb.IsDropped = false
  255. Case 4:LeftSlingshotb.visible = false:LeftSlingshotpostb.IsDropped = true:LeftSlingshota.visible = true:LeftSlingshotposta.IsDropped = false:Me.TimerEnabled = 0 '
  256. End Select
  257.  
  258. LeftSlingshotStep = LeftSlingshotStep + 1
  259. End Sub
  260.  
  261.  
  262. Sub RightSlingShot_Slingshot:RightSlingshota.visible = false:RightSlingshotposta.IsDropped = true:RightSlingshotb.visible = true:RightSlingshotpostb.IsDropped = false:PlaySound SoundFX("slingshot",DOFContactors):vpmTimer.PulseSw 22:RightSlingshotStep = 0:Me.TimerEnabled = 1:End Sub
  263. Sub RightSlingshot_Timer
  264. Select Case RightSlingshotStep
  265. Case 0:RightSlingshotb.visible = false:RightSlingshotpostb.IsDropped = true:RightSlingshotc.visible = true:RightSlingshotpostc.IsDropped = false
  266. Case 1:RightSlingshotc.visible = false:RightSlingshotpostc.IsDropped = true:RightSlingshotd.visible = true:RightSlingshotpostd.IsDropped = false
  267. Case 2:RightSlingshotd.visible = false:RightSlingshotpostd.IsDropped = true:RightSlingshotc.visible = true:RightSlingshotpostc.IsDropped = false
  268. Case 3:RightSlingshotc.visible = false:RightSlingshotpostc.IsDropped = true:RightSlingshotb.visible = true:RightSlingshotpostb.IsDropped = false
  269. Case 4:RightSlingshotb.visible = false:RightSlingshotpostb.IsDropped = true:RightSlingshota.visible = true:RightSlingshotposta.IsDropped = false:Me.TimerEnabled = 0 '
  270. End Select
  271.  
  272. RightSlingshotStep = RightSlingshotStep + 1
  273. End Sub
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287. ' Bumpers
  288. Sub Bumper1_Hit:vpmTimer.PulseSw 46:PlaySound SoundFX("bumper1",DOFContactors):bump1 = 1:Me.TimerEnabled = 1:End Sub
  289. Sub Bumper1_Timer()
  290. Select Case bump1
  291. Case 1:
  292. Case 2:
  293. Case 3:
  294. Case 4:Me.TimerEnabled = 0
  295. End Select
  296. End Sub
  297.  
  298. Sub Bumper2_Hit:vpmTimer.PulseSw 47:PlaySound SoundFX("bumper2",DOFContactors):bump2 = 1:Me.TimerEnabled = 1:End Sub
  299. Sub Bumper2_Timer()
  300. Select Case bump2
  301. Case 1:
  302. Case 2:
  303. Case 3:
  304. Case 4:Me.TimerEnabled = 0
  305. End Select
  306. End Sub
  307.  
  308. Sub Bumper3_Hit:vpmTimer.PulseSw 48:PlaySound SoundFX("bumper1",DOFContactors):bump3 = 1:Me.TimerEnabled = 1:End Sub
  309. Sub Bumper3_Timer()
  310. Select Case bump3
  311. Case 1:
  312. Case 2:
  313. Case 3:
  314. Case 4:Me.TimerEnabled = 0
  315. End Select
  316. End Sub
  317.  
  318. ' Drain holes, vuks & saucers
  319. Sub Drain_Hit:PlaySound "drain":vpmTimer.PulseSw 10:bsTrough.AddBall Me:End Sub
  320. Sub Drain1_Hit:PlaySound "drain":vpmTimer.PulseSw 10:bsTrough.AddBall Me:End Sub
  321. Sub Drain2_Hit:PlaySound "drain":vpmTimer.PulseSw 10:bsTrough.AddBall Me:End Sub
  322. Sub Drain3_Hit:PlaySound "drain":vpmTimer.PulseSw 10:bsTrough.AddBall Me:End Sub
  323. Sub Drain4_Hit:PlaySound "drain":vpmTimer.PulseSw 10:bsTrough.AddBall Me:End Sub
  324. Sub sw45_Hit:bsTR.AddBall 0:End Sub
  325.  
  326. 'VUK Lock
  327. Sub sw29_Hit():PlaySound "kicker_enter":bsVUK.AddBall Me:End Sub
  328.  
  329. ' Rollovers & Ramp Switches
  330. Sub sw17_Hit:P_Trigger17.TransZ = -5:Controller.Switch(17) = 1:PlaySound "sensor":End Sub
  331. Sub sw17_UnHit:P_Trigger17.TransZ = 0:Controller.Switch(17) = 0:End Sub
  332.  
  333. Sub sw18_Hit:P_Trigger18.TransZ = -5:Controller.Switch(18) = 1:PlaySound "sensor":End Sub
  334. Sub sw18_UnHit:P_Trigger18.TransZ = 0:Controller.Switch(18) = 0:End Sub
  335.  
  336. Sub sw20_Hit:P_Trigger20.TransZ = -5:Controller.Switch(20) = 1:PlaySound "sensor":End Sub
  337. Sub sw20_UnHit:P_Trigger20.TransZ = 0:Controller.Switch(20) = 0:End Sub
  338.  
  339. Sub sw19_Hit:P_Trigger19.TransZ = -5:Controller.Switch(19) = 1:PlaySound "sensor":End Sub
  340. Sub sw19_UnHit:P_Trigger19.TransZ = 0:Controller.Switch(19) = 0:End Sub
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348. Sub sw30_Hit:Controller.Switch(30) = 1:PlaySound "sensor":End Sub
  349. Sub sw30_Unhit:Controller.Switch(30) = 0:End Sub
  350.  
  351. Sub sw31_Hit:Controller.Switch(31) = 1:PlaySound "sensor":End Sub
  352. Sub sw31_Unhit:Controller.Switch(31) = 0:End Sub
  353.  
  354. Sub sw14_Hit:Controller.Switch(14) = 1:PlaySound "sensor":End Sub
  355. Sub sw14_Unhit:Controller.Switch(14) = 0:End Sub
  356.  
  357.  
  358.  
  359.  
  360. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  361. ' Drop Targets
  362. '%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
  363.  
  364.  
  365.  
  366.  
  367. dim sw41Dir, sw42Dir, sw43Dir
  368. dim sw41Pos, sw42Pos, sw43Pos
  369.  
  370. sw41Dir = 1:sw42Dir = 1:sw43Dir = 1
  371. sw41Pos = 0:sw42Pos = 0:sw43Pos = 0
  372.  
  373. 'Targets Init
  374. sw41a.TimerEnabled = 1:sw42a.TimerEnabled = 1:sw43a.TimerEnabled = 1
  375.  
  376.  
  377.  
  378.  
  379.  
  380. Sub sw41_Hit:DTBank.Hit 1:sw41Dir = 0:sw41a.TimerEnabled = 1:End Sub
  381. Sub sw42_Hit:DTBank.Hit 2:sw42Dir = 0:sw42a.TimerEnabled = 1:End Sub
  382. Sub sw43_Hit:DTBank.Hit 3:sw43Dir = 0:sw43a.TimerEnabled = 1:End Sub
  383.  
  384.  
  385.  
  386.  
  387. '''Target animation
  388.  
  389.  
  390. Sub sw41a_Timer()
  391. Select Case sw41Pos
  392. Case 0: sw41P.z=0
  393. If sw41Dir = 1 then
  394. sw41a.TimerEnabled = 0
  395. else
  396. end if
  397. Case 1: sw41P.z=0
  398. Case 2: sw41P.z=-4
  399. Case 3: sw41P.z=-8
  400. Case 4: sw41P.z=-12
  401. Case 5: sw41P.z=-16
  402. Case 6: sw41P.z=-20
  403. Case 7: sw41P.z=-24
  404. Case 8: sw41P.z=-28
  405. Case 9: sw41P.z=-32
  406. Case 10: sw41P.z=-36
  407. Case 11: sw41P.z=-40
  408. Case 12: sw41P.z=-44
  409. Case 13: sw41P.z=-48:sw41P.ReflectionEnabled = true
  410. Case 14: sw41P.z=-52:sw41P.ReflectionEnabled = false
  411. If sw41Dir = 1 then
  412. else
  413. sw41a.TimerEnabled = 0
  414. end if
  415.  
  416.  
  417. End Select
  418. If sw41Dir = 1 then
  419. If sw41pos>0 then sw41pos=sw41pos-1
  420. else
  421. If sw41pos<14 then sw41pos=sw41pos+1
  422. end if
  423. End Sub
  424.  
  425.  
  426.  
  427.  
  428.  
  429. Sub sw42a_Timer()
  430. Select Case sw42Pos
  431. Case 0: sw42P.z=0
  432. If sw42Dir = 1 then
  433. sw42a.TimerEnabled = 0
  434. else
  435. end if
  436. Case 1: sw42P.z=0
  437. Case 2: sw42P.z=-4
  438. Case 3: sw42P.z=-8
  439. Case 4: sw42P.z=-12
  440. Case 5: sw42P.z=-16
  441. Case 6: sw42P.z=-20
  442. Case 7: sw42P.z=-24
  443. Case 8: sw42P.z=-28
  444. Case 9: sw42P.z=-32
  445. Case 10: sw42P.z=-36
  446. Case 11: sw42P.z=-40
  447. Case 12: sw42P.z=-44
  448. Case 13: sw42P.z=-48:sw42P.ReflectionEnabled = true
  449. Case 14: sw42P.z=-52:sw42P.ReflectionEnabled = false
  450. If sw42Dir = 1 then
  451. else
  452. sw42a.TimerEnabled = 0
  453. end if
  454.  
  455.  
  456. End Select
  457. If sw42Dir = 1 then
  458. If sw42pos>0 then sw42pos=sw42pos-1
  459. else
  460. If sw42pos<14 then sw42pos=sw42pos+1
  461. end if
  462. End Sub
  463.  
  464.  
  465. Sub sw43a_Timer()
  466. Select Case sw43Pos
  467. Case 0: sw43P.z=0
  468. If sw43Dir = 1 then
  469. sw43a.TimerEnabled = 0
  470. else
  471. end if
  472. Case 1: sw43P.z=0
  473. Case 2: sw43P.z=-4
  474. Case 3: sw43P.z=-8
  475. Case 4: sw43P.z=-12
  476. Case 5: sw43P.z=-16
  477. Case 6: sw43P.z=-20
  478. Case 7: sw43P.z=-24
  479. Case 8: sw43P.z=-28
  480. Case 9: sw43P.z=-32
  481. Case 10: sw43P.z=-36
  482. Case 11: sw43P.z=-40
  483. Case 12: sw43P.z=-44
  484. Case 13: sw43P.z=-48:sw43P.ReflectionEnabled = true
  485. Case 14: sw43P.z=-52:sw43P.ReflectionEnabled = false
  486. If sw43Dir = 1 then
  487. else
  488. sw43a.TimerEnabled = 0
  489. end if
  490.  
  491.  
  492.  
  493. End Select
  494. If sw43Dir = 1 then
  495. If sw43pos>0 then sw43pos=sw43pos-1
  496. else
  497. If sw43pos<14 then sw43pos=sw43pos+1
  498. end if
  499. End Sub
  500.  
  501.  
  502.  
  503.  
  504.  
  505.  
  506.  
  507.  
  508.  
  509.  
  510.  
  511. 'DT Subs
  512. Sub ResetDrops(Enabled)
  513. If Enabled Then
  514. sw41Dir = 1:sw42Dir = 1:sw43Dir = 1
  515. sw41a.TimerEnabled = 1:sw42a.TimerEnabled = 1:sw43a.TimerEnabled = 1
  516. DTBank.DropSol_On
  517. End if
  518. End Sub
  519.  
  520.  
  521.  
  522.  
  523.  
  524.  
  525.  
  526.  
  527.  
  528.  
  529.  
  530.  
  531. '***************************************
  532. ' Targets
  533. '***************************************
  534.  
  535. Dim Target25Step, Target26Step, Target27Step, Target33Step, Target34Step, Target35Step, Target36Step, Target37Step
  536.  
  537.  
  538. Sub sw25_Hit:vpmTimer.PulseSw(25):P_Target25.TransX = -5:Target25Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  539. Sub sw25_timer()
  540. Select Case Target25Step
  541. Case 1:P_Target25.TransX = 3
  542. Case 2:P_Target25.TransX = -2
  543. Case 3:P_Target25.TransX = 1
  544. Case 4:P_Target25.TransX = 0:Me.TimerEnabled = 0
  545. End Select
  546. Target25Step = Target25Step + 1
  547. End Sub
  548.  
  549. Sub sw26_Hit:vpmTimer.PulseSw(26):P_Target26.TransX = -5:Target26Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  550. Sub sw26_timer()
  551. Select Case Target26Step
  552. Case 1:P_Target26.TransX = 3
  553. Case 2:P_Target26.TransX = -2
  554. Case 3:P_Target26.TransX = 1
  555. Case 4:P_Target26.TransX = 0:Me.TimerEnabled = 0
  556. End Select
  557. Target26Step = Target26Step + 1
  558. End Sub
  559.  
  560. Sub sw27_Hit:vpmTimer.PulseSw(27):P_Target27.TransX = -5:Target27Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  561. Sub sw27_timer()
  562. Select Case Target27Step
  563. Case 1:P_Target27.TransX = 3
  564. Case 2:P_Target27.TransX = -2
  565. Case 3:P_Target27.TransX = 1
  566. Case 4:P_Target27.TransX = 0:Me.TimerEnabled = 0
  567. End Select
  568. Target27Step = Target27Step + 1
  569. End Sub
  570.  
  571.  
  572.  
  573. Sub sw33_Hit:vpmTimer.PulseSw(33):P_Target33.TransX = -5:Target33Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  574. Sub sw33_timer()
  575. Select Case Target33Step
  576. Case 1:P_Target33.TransX = 3
  577. Case 2:P_Target33.TransX = -2
  578. Case 3:P_Target33.TransX = 1
  579. Case 4:P_Target33.TransX = 0:Me.TimerEnabled = 0
  580. End Select
  581. Target33Step = Target33Step + 1
  582. End Sub
  583.  
  584. Sub sw34_Hit:vpmTimer.PulseSw(34):P_Target34.TransX = -5:Target34Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  585. Sub sw34_timer()
  586. Select Case Target34Step
  587. Case 1:P_Target34.TransX = 3
  588. Case 2:P_Target34.TransX = -2
  589. Case 3:P_Target34.TransX = 1
  590. Case 4:P_Target34.TransX = 0:Me.TimerEnabled = 0
  591. End Select
  592. Target34Step = Target34Step + 1
  593. End Sub
  594.  
  595. Sub sw35_Hit:vpmTimer.PulseSw(35):P_Target35.TransX = -5:Target35Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  596. Sub sw35_timer()
  597. Select Case Target35Step
  598. Case 1:P_Target35.TransX = 3
  599. Case 2:P_Target35.TransX = -2
  600. Case 3:P_Target35.TransX = 1
  601. Case 4:P_Target35.TransX = 0:Me.TimerEnabled = 0
  602. End Select
  603. Target35Step = Target35Step + 1
  604. End Sub
  605.  
  606. Sub sw36_Hit:vpmTimer.PulseSw(36):P_Target36.TransX = -5:Target36Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  607. Sub sw36_timer()
  608. Select Case Target36Step
  609. Case 1:P_Target36.TransX = 3
  610. Case 2:P_Target36.TransX = -2
  611. Case 3:P_Target36.TransX = 1
  612. Case 4:P_Target36.TransX = 0:Me.TimerEnabled = 0
  613. End Select
  614. Target36Step = Target36Step + 1
  615. End Sub
  616.  
  617. Sub sw37_Hit:vpmTimer.PulseSw(37):P_Target37.TransX = -5:Target37Step = 1:Me.TimerEnabled = 1:PlaySound SoundFX("target",DOFTargets):End Sub
  618. Sub sw37_timer()
  619. Select Case Target37Step
  620. Case 1:P_Target37.TransX = 3
  621. Case 2:P_Target37.TransX = -2
  622. Case 3:P_Target37.TransX = 1
  623. Case 4:P_Target37.TransX = 0:Me.TimerEnabled = 0
  624. End Select
  625. Target37Step = Target37Step + 1
  626. End Sub
  627.  
  628.  
  629. ' Spinners
  630. Sub sw28_Spin():vpmTimer.PulseSw 28:PlaySound "spinner":End Sub
  631.  
  632. ' Ramps helpers
  633. Sub RHelp1_Hit:StopSound "metalrolling":PlaySound "BallHit":End Sub
  634. Sub RHelp2_Hit:StopSound "metalrolling":PlaySound "BallHit":End Sub
  635.  
  636. ' Extra Sounds
  637. Sub Rubbers_Hit(idx):PlaySound "rubber":End Sub
  638. Sub Metals_Hit(idx):PlaySound "metalhit":End Sub
  639. Sub Sound1_Hit:PlaySound "metalrolling":End Sub
  640. Sub Sound2_Hit:PlaySound "metalrolling":End Sub
  641. Sub Sound3_Hit:PlaySound "metalrolling":End Sub
  642. Sub BallRol1_Hit:PlaySound "ballrolling":End Sub
  643.  
  644. '*********
  645. 'Solenoids
  646. '*********
  647.  
  648. SolCallBack(25) = "bsTrough.SolIn"
  649. SolCallBack(26) = "bsTrough.SolOut"
  650. SolCallBack(27) = "vLock.SolExit"
  651. SolCallBack(28) = "bsTR.SolOut"
  652. SolCallBack(29) = "bsVuk.SolOut"
  653. SolCallBack(30) = "ResetDrops"
  654. SolCallBack(32) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  655.  
  656. SolCallBack(1) = "SetLamp 101,"
  657. SolCallBack(2) = "SetLamp 102,"
  658. SolCallback(3) = "SetLamp 103,"
  659. SolCallback(4) = "SetLamp 104,"
  660. SolCallback(5) = "SetLamp 105,"
  661. ' SolCallback(6) = "SetLamp 106," left side
  662. ' SolCallback(7) = "SetLamp 107," center
  663. SolCallback(8) = "SetLamp 108,"
  664. ' SolCallback(9) = "SetLamp 109," 'right side
  665. SolCallback(11) = "SolGi"
  666. SolCallback(12) = "SetLamp 112,"
  667. SolCallback(13) = "SetLamp 113,"
  668. SolCallback(14) = "SetLamp 114,"
  669. SolCallback(15) = "SetLamp 115,"
  670. SolCallback(16) = "SetLamp 116,"
  671.  
  672. '**************
  673. ' Flipper Subs
  674. '**************
  675.  
  676. SolCallback(sLRFlipper) = "SolRFlipper"
  677. SolCallback(sLLFlipper) = "SolLFlipper"
  678.  
  679. Sub SolLFlipper(Enabled)
  680. If Enabled Then
  681. PlaySound SoundFX("FlipperUp",DOFFlippers):LeftFlipper.RotateToEnd
  682. Llogo.IsDropped = 1:Llogo2.IsDropped = 0
  683. Else
  684. PlaySound SoundFX("FlipperDown",DOFFlippers):LeftFlipper.RotateToStart
  685. Llogo2.IsDropped = 1:Llogo.IsDropped = 0
  686. End If
  687. End Sub
  688.  
  689. Sub SolRFlipper(Enabled)
  690. If Enabled Then
  691. PlaySound SoundFX("FlipperUp",DOFFlippers):RightFlipper.RotateToEnd
  692. Rlogo.IsDropped = 1:Rlogo2.IsDropped = 0
  693. Else
  694. PlaySound SoundFX("FlipperDown",DOFFlippers):RightFlipper.RotateToStart
  695. Rlogo2.IsDropped = 1:Rlogo.IsDropped = 0
  696. End If
  697. End Sub
  698.  
  699. Sub LeftFlipper_Collide(parm)
  700. PlaySound "rubber_flipper"
  701. End Sub
  702.  
  703. Sub RightFlipper_Collide(parm)
  704. PlaySound "rubber_flipper"
  705. End Sub
  706.  
  707. '**********
  708. ' Gi Lights
  709. '**********
  710.  
  711. Sub SolGi(Enabled)
  712. Dim obj
  713. If Enabled Then
  714.  
  715. gi1.state = 0
  716. gi2.state = 0
  717. gi3.state = 0
  718. gi4.state = 0
  719. gi5.state = 0
  720. gi6.state = 0
  721. gi7.state = 0
  722. gi8.state = 0
  723. gi9.state = 0
  724. gi10.state = 0
  725. gi11.state = 0
  726. gi12.state = 0
  727. gi13.state = 0
  728. gi14.state = 0
  729. gi15.state = 0
  730. gi16.state = 0
  731. gi17.state = 0
  732. gi18.state = 0
  733. gi19.state = 0
  734. gi20.state = 0
  735. gi21.state = 0
  736. gi22.state = 0
  737. gi23.state = 0
  738. gi24.state = 0
  739. gi25.state = 0
  740. bLight1.state = 0
  741. bLight2.state = 0
  742. bLight3.state = 0
  743. bLight1z.state = 0
  744. bLight2z.state = 0
  745. bLight3z.state = 0
  746. bLight1zb.state = 0
  747. bLight2zb.state = 0
  748. bLight3zb.state = 0
  749.  
  750.  
  751.  
  752.  
  753.  
  754. Else
  755.  
  756.  
  757. gi1.state = 1
  758. gi2.state = 1
  759. gi3.state = 1
  760. gi4.state = 1
  761. gi5.state = 1
  762. gi6.state = 1
  763. gi7.state = 1
  764. gi8.state = 1
  765. gi9.state = 1
  766. gi10.state = 1
  767. gi11.state = 1
  768. gi12.state = 1
  769. gi13.state = 1
  770. gi14.state = 1
  771. gi15.state = 1
  772. gi16.state = 1
  773. gi17.state = 1
  774. gi18.state = 1
  775. gi19.state = 1
  776. gi20.state = 1
  777. gi21.state = 1
  778. gi22.state = 1
  779. gi23.state = 1
  780. gi24.state = 1
  781. gi25.state = 1
  782. bLight1.state = 1
  783. bLight2.state = 1
  784. bLight3.state = 1
  785. bLight1z.state = 1
  786. bLight2z.state = 1
  787. bLight3z.state = 1
  788. bLight1zb.state = 1
  789. bLight2zb.state = 1
  790. bLight3zb.state = 1
  791.  
  792.  
  793.  
  794. End If
  795. End Sub
  796.  
  797. '***************************************************
  798. ' JP's Fading Lamps & Flashers version 9 for VP921
  799. ' Based on PD's Fading Lights
  800. ' SetLamp 0 is Off
  801. ' SetLamp 1 is On
  802. ' FadingLevel(x) = fading state
  803. ' LampState(x) = light state
  804. ' Includes the flash element (needs own timer)
  805. ' Flashers can be used as lights too
  806. '***************************************************
  807.  
  808. Dim LampState(200), FadingLevel(200)
  809. Dim FlashState(200), FlashLevel(200)
  810. Dim FlashSpeedUp, FlashSpeedDown
  811. Dim TextureArray1: TextureArray1 = Array("Plastic with an image trans", "Plastic with an image")
  812.  
  813.  
  814.  
  815. Const LightHaloBrightness = 200
  816.  
  817.  
  818. FlashInit()
  819. FlasherTimer.Interval = 10 'flash fading speed
  820. FlasherTimer.Enabled = 1
  821.  
  822. ' Lamp & Flasher Timers
  823.  
  824. Sub StartLampTimer
  825. AllLampsOff()
  826. LampTimer.Interval = 30 'lamp fading speed
  827. LampTimer.Enabled = 1
  828. End Sub
  829.  
  830. Sub LampTimer_Timer()
  831. Dim chgLamp, num, chg, ii
  832. chgLamp = Controller.ChangedLamps
  833. If Not IsEmpty(chgLamp) Then
  834. For ii = 0 To UBound(chgLamp)
  835. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1)
  836. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4
  837. FlashState(chgLamp(ii, 0) ) = chgLamp(ii, 1)
  838. Next
  839. End If
  840.  
  841. UpdateLamps
  842. 'UpdateMultipleLamps
  843. End Sub
  844.  
  845.  
  846. ' ****************************************************************
  847. ' * JPJ duplication des lumières Bulbs pour reflets sur la bille *
  848. ' ****************************************************************
  849.  
  850. Sub UpdateLamps
  851. FadeL 1, l1, l1z
  852. FadeL 2, l2, l2z
  853. FadeL 3, l3, l3z
  854. FadeL 4, l4, l4z
  855. FadeL 5, l5, l5z
  856. FadeL 6, l6, l6z
  857. FadeL 7, l7, l7z
  858. FadeL 8, l8, l8z
  859. FadeL 9, l9, l9z
  860. FadeL 10, l10, l10z
  861. FadeL 11, l11, l11z
  862. FadeL 12, l12, l12z
  863. FadeL 13, l13, l13z
  864. FadeL 14, l14, l14z
  865. FadeMaterialW 15, Wall356, TextureArray1
  866.  
  867.  
  868. FadeL 16, l16, l16z
  869. FadeL 17, l17, l17z
  870. FadeL 18, l18, l18z
  871. FadeL 19, l19, l19z
  872. FadeL 20, l20, l20z
  873. FadeL 21, l21, l21z
  874. FadeL 22, l22, l22z
  875. FadeL 23, l23, l23z
  876. FadeL 24, l24, l24z
  877. FadeW 25, l25, l25a, l25b
  878. FadeW 26, l26, l26a, l26b
  879. FadeW 27, l27, l27a, l27b
  880. FadeW 28, l28, l28a, l28b
  881. FadeW 29, l29, l29a, l29b
  882. FadeW 30, l30, l30a, l30b
  883. FadeW 31, l31, l31a, l31b
  884. FadeW 32, l32, l32a, l32b
  885. FadeL 33, l33, l33z
  886.  
  887. FadeL 40, l40, l40z
  888. FadeL 41, l41, l41z
  889. FadeL 42, l42, l42z
  890. FadeL 43, l43, l43z
  891. FadeL 44, l44, l44z
  892. FadeL 45, l45, l45z
  893. FadeMaterialW 46, Wall355, TextureArray1
  894.  
  895. FadeL 49, l49, l49z
  896. FadeL 50, l50, l50z
  897. FadeL 51, l51, l51z
  898. FadeL 52, l52, l52z
  899. FadeL 53, l53, l53z
  900. FadeL 54, l54, l54z
  901. FadeL 55, l55, l55z
  902.  
  903.  
  904. FadeL 57, l57, l57z
  905. FadeL 58, l58, l58z
  906. FadeL 59, l59, l59z
  907.  
  908. FadeL 61, l61, l61z
  909. FadeL 62, l62, l62z
  910. FadeL 63, l63, l63z
  911. FadeL 64, l64, l64z
  912.  
  913. ' ***************************************************
  914. ' * JPJ Déjà en bulb donc pas besoin de les doubler * *
  915. ' ***************************************************
  916.  
  917. NFadeLm 15, l15a
  918. NFadeL 15, l15
  919. NFadeLm 46, l46a
  920. NFadeL 46, l46
  921. NFadeLm 47, l47a
  922. NFadeL 47, l47
  923. NFadeLm 48, l48a
  924. NFadeL 48, l48
  925.  
  926. ' ***************************************************************************
  927. ' * JPJ EMREELs dans le backglass sonc pas besoin de reflechir sur la bille * *
  928. ' ***************************************************************************
  929.  
  930. FadeR 34, l34
  931. FadeR 35, l35
  932. FadeR 36, l36
  933. FadeR 37, l37
  934. FadeR 38, l38
  935. FadeR 39, l39
  936. FadeRm 47, l47c
  937.  
  938. FadeMaterialW 47, Wall355, TextureArray1
  939.  
  940. FadeMaterialW 48, Wall355, TextureArray1
  941.  
  942.  
  943. FadeRm 56, l56c
  944. FadeMaterialW 56, Wall356, TextureArray1
  945. NFadeLm 56, l56a
  946. NFadeL 56, l56
  947.  
  948. FadeMaterialW 60, Wall356, TextureArray1
  949. NFadeLm 60, l60a
  950. NFadeL 60, l60
  951. ' FadeW 60, l60, l60a, l60b
  952.  
  953.  
  954. 'Flashers
  955. NFadeLm 101, f1a
  956. NFadeLm 101, f1b
  957. NFadeLm 101, f1c
  958. FadeL 101, f1d, f1dz
  959.  
  960. NFadeLm 102, f2a
  961. NFadeLm 102, f2b
  962. NFadeLm 102, f2c
  963. FadeL 102, f2d, f2dz
  964.  
  965. NFadeLm 103, f3a
  966. NFadeLm 103, f3b
  967. NFadeLm 103, f3c
  968. FadeL 103, f3d, f3dz
  969.  
  970. FadeMaterialW 104, Wall347, TextureArray1
  971. FadeMaterialP 104, Primitive10, TextureArray1
  972. NFadeL 104, f4
  973.  
  974. FadeMaterialP 105, Primitive3, TextureArray1
  975. NFadeL 105, f5
  976. ' FadeR 107, f7
  977.  
  978. FadeMaterialP 108, Primitive2, TextureArray1
  979. NFadeLm 108, f8c
  980. FadeW 108, f8, f8a, f8b
  981.  
  982.  
  983. FadeMaterialP 112, Primitive1, TextureArray1
  984. NFadeL 112, f12
  985. NFadeL 113, f13
  986. NFadeL 114, f14
  987. NFadeL 115, f15
  988. ' NFadeWm 116, f16c
  989.  
  990. FadeMaterialP 116, Primitive16, TextureArray1
  991. NFadeL 116, f16
  992.  
  993.  
  994.  
  995. End Sub
  996.  
  997.  
  998. Sub FadeLight(nr, light)
  999. Select Case FadingState(nr)
  1000. Case 2:FadingState(nr) = 0
  1001. Case 3:FadingState(nr) = 2
  1002. Case 4:light.State = LightStateOff:FadingState(nr) = 3
  1003. Case 5:light.State = LightStateOn:FadingState(nr) = 1
  1004. End Select
  1005. End Sub
  1006.  
  1007. Sub FadeLights(nr, lights)
  1008. Dim ip
  1009. Select Case FadingState(nr)
  1010. Case 2:FadingState(nr) = 0
  1011. Case 3:FadingState(nr) = 2
  1012. Case 4:For each ip in lights:ip.State = LightStateOff:Next:FadingState(nr) = 3
  1013. Case 5:For each ip in lights:ip.State = LightStateOn:Next:FadingState(nr) = 1
  1014. End Select
  1015. End Sub
  1016.  
  1017. 'Sindbad: You can use this instead of FadeLN
  1018. ' call it this way: FadeLight lampnumber, light, Array
  1019. 'Sub FadeLight(nr, Light, group)
  1020. ' Select Case FadingLevel(nr)
  1021. ' Case 2:Light.image = group(3):FadingLevel(nr) = 0 'Off
  1022. ' Case 3:Light.image = group(2):FadingLevel(nr) = 2 'fading...
  1023. ' Case 4:Light.image = group(1):FadingLevel(nr) = 3 'fading...
  1024. ' Case 5:Light.image = group(0):FadingLevel(nr) = 1 'ON
  1025. ' End Select
  1026. 'End Sub
  1027.  
  1028.  
  1029. Sub NFadeL(nr, a)
  1030. Select Case FadingLevel(nr)
  1031. Case 4:a.state = 0:FadingLevel(nr) = 0
  1032. Case 5:a.State = 1:FadingLevel(nr) = 1
  1033. End Select
  1034. End Sub
  1035.  
  1036. Sub NFadeLm(nr, a)
  1037. Select Case FadingLevel(nr)
  1038. Case 4:a.state = 0
  1039. Case 5:a.State = 1
  1040. End Select
  1041. End Sub
  1042.  
  1043.  
  1044.  
  1045. 'trxture swap
  1046. dim itemw, itemp
  1047.  
  1048. Sub FadeMaterialW(nr, itemw, group)
  1049. Select Case FadingLevel(nr)
  1050. Case 4:itemw.TopMaterial = group(1):itemw.SideMaterial = group(1)
  1051. Case 5:itemw.TopMaterial = group(0):itemw.SideMaterial = group(0)
  1052. End Select
  1053. End Sub
  1054.  
  1055.  
  1056. Sub FadeMaterialP(nr, itemp, group)
  1057. Select Case FadingLevel(nr)
  1058. Case 4:itemp.Material = group(1)
  1059. Case 5:itemp.Material = group(0)
  1060. End Select
  1061. End Sub
  1062.  
  1063.  
  1064.  
  1065.  
  1066.  
  1067.  
  1068. ' div lamp subs
  1069.  
  1070. Sub AllLampsOff()
  1071. Dim x
  1072. For x = 0 to 200
  1073. LampState(x) = 0
  1074. FadingLevel(x) = 4
  1075. Next
  1076.  
  1077. UpdateLamps:UpdateLamps:Updatelamps
  1078. End Sub
  1079.  
  1080. Sub SetLamp(nr, value)
  1081. If value <> LampState(nr) Then
  1082. LampState(nr) = abs(value)
  1083. FadingLevel(nr) = abs(value) + 4
  1084. End If
  1085. End Sub
  1086.  
  1087.  
  1088.  
  1089.  
  1090. ' div flasher subs
  1091.  
  1092. Sub FlashInit
  1093. Dim i
  1094. For i = 0 to 200
  1095. FlashState(i) = 0
  1096. FlashLevel(i) = 0
  1097. Next
  1098.  
  1099. FlashSpeedUp = 30 ' fast speed when turning on the flasher
  1100. FlashSpeedDown = 10 ' slow speed when turning off the flasher, gives a smooth fading
  1101. ' you could also change the default images for each flasher or leave it as in the editor
  1102. ' for example
  1103. ' Flasher1.Image = "fr"
  1104. AllFlashOff()
  1105. End Sub
  1106.  
  1107. Sub AllFlashOff
  1108. Dim i
  1109. For i = 0 to 200
  1110. FlashState(i) = 0
  1111. Next
  1112. End Sub
  1113.  
  1114. Sub SetFlash(nr, stat)
  1115. FlashState(nr) = ABS(stat)
  1116. End Sub
  1117.  
  1118.  
  1119. ' Flasher objects
  1120. ' Uses own faster timer
  1121.  
  1122. Sub Flash(nr, object)
  1123. Select Case FlashState(nr)
  1124. Case 0 'off
  1125. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown
  1126. If FlashLevel(nr) < 0 Then
  1127. FlashLevel(nr) = 0
  1128. FlashState(nr) = -1 'completely off
  1129. End if
  1130. Object.opacity = FlashLevel(nr)
  1131. Case 1 ' on
  1132. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp
  1133. If FlashLevel(nr) > 250 Then
  1134. FlashLevel(nr) = 250
  1135. FlashState(nr) = -2 'completely on
  1136. End if
  1137. Object.opacity = FlashLevel(nr)
  1138. End Select
  1139. End Sub
  1140.  
  1141. Sub Flashm(nr, object) 'multiple flashers, it doesn't change the flashstate
  1142. Select Case FlashState(nr)
  1143. Case 0 'off
  1144. Object.opacity = FlashLevel(nr)
  1145. Case 1 ' on
  1146. Object.opacity = FlashLevel(nr)
  1147. End Select
  1148. End Sub
  1149.  
  1150. Sub FlashVal(nr, object, value)
  1151. Select Case FlashState(nr)
  1152. Case 0 'off
  1153. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown
  1154. If FlashLevel(nr) < 0 Then
  1155. FlashLevel(nr) = 0
  1156. FlashState(nr) = -1 'completely off
  1157. End if
  1158. Object.opacity = FlashLevel(nr)
  1159. Case 1 ' on
  1160. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp
  1161. If FlashLevel(nr) > value Then
  1162. FlashLevel(nr) = value
  1163. FlashState(nr) = -2 'completely on
  1164. End if
  1165. Object.opacity = FlashLevel(nr)
  1166. End Select
  1167. End Sub
  1168.  
  1169. Sub FlashValm(nr, object, value) 'multiple flashers, it doesn't change the flashstate
  1170. Select Case FlashState(nr)
  1171. Case 0 'off
  1172. Object.opacity = FlashLevel(nr)
  1173. Case 1 ' on
  1174. Object.opacity = FlashLevel(nr)
  1175. End Select
  1176. End Sub
  1177.  
  1178.  
  1179.  
  1180. Sub FadeLn(nr, Light, a, b, c, d)
  1181. Select Case FadingLevel(nr)
  1182. Case 2:Light.Offimage = d:FadingLevel(nr) = 0 'Off
  1183. Case 3:Light.Offimage = c:FadingLevel(nr) = 2 'fading...
  1184. Case 4:Light.Offimage = b:FadingLevel(nr) = 3 'fading...
  1185. Case 5:Light.Offimage = a:FadingLevel(nr) = 1 'ON
  1186. End Select
  1187. End Sub
  1188.  
  1189. Sub FadeLnm(nr, Light, a, b, c, d)
  1190. Select Case FadingLevel(nr)
  1191. Case 2:Light.Offimage = d
  1192. Case 3:Light.Offimage = c
  1193. Case 4:Light.Offimage = b
  1194. Case 5:Light.Offimage = a
  1195. End Select
  1196. End Sub
  1197.  
  1198. Sub LMapn(nr, Light, a, b, c, d)
  1199. Select Case FadingLevel(nr)
  1200. Case 2:Light.Onimage = d:FadingLevel(nr) = 0 'Off
  1201. Case 3:Light.ONimage = c:FadingLevel(nr) = 2 'fading...
  1202. Case 4:Light.ONimage = b:FadingLevel(nr) = 3 'fading...
  1203. Case 5:Light.ONimage = a:FadingLevel(nr) = 1 'ON
  1204. End Select
  1205. End Sub
  1206.  
  1207. Sub LMapnm(nr, Light, a, b, c, d)
  1208. Select Case FadingLevel(nr)
  1209. Case 2:Light.ONimage = d
  1210. Case 3:Light.ONimage = c
  1211. Case 4:Light.ONimage = b
  1212. Case 5:Light.ONimage = a
  1213. End Select
  1214. End Sub
  1215. ' Walls
  1216.  
  1217. Sub FadeW(nr, a, b, c)
  1218. Select Case FadingLevel(nr)
  1219. Case 2:c.IsDropped = 1:FadingLevel(nr) = 0 'Off
  1220. Case 3:b.IsDropped = 1:c.IsDropped = 0:FadingLevel(nr) = 2 'fading...
  1221. Case 4:a.IsDropped = 1:b.IsDropped = 0:FadingLevel(nr) = 3 'fading...
  1222. Case 5:a.IsDropped = 0:FadingLevel(nr) = 1 'ON
  1223. End Select
  1224. End Sub
  1225.  
  1226. Sub FadeWm(nr, a, b, c)
  1227. Select Case FadingLevel(nr)
  1228. Case 2:c.IsDropped = 1
  1229. Case 3:b.IsDropped = 1:c.IsDropped = 0
  1230. Case 4:a.IsDropped = 1:b.IsDropped = 0
  1231. Case 5:a.IsDropped = 0
  1232. End Select
  1233. End Sub
  1234.  
  1235. Sub NFadeW(nr, a)
  1236. Select Case FadingLevel(nr)
  1237. Case 4:a.IsDropped = 1:FadingLevel(nr) = 0
  1238. Case 5:a.IsDropped = 0:FadingLevel(nr) = 1
  1239. End Select
  1240. End Sub
  1241.  
  1242. Sub NFadeWm(nr, a)
  1243. Select Case FadingLevel(nr)
  1244. Case 4:a.IsDropped = 1
  1245. Case 5:a.IsDropped = 0
  1246. End Select
  1247. End Sub
  1248.  
  1249. Sub NFadeWi(nr, a)
  1250. Select Case FadingLevel(nr)
  1251. Case 4:a.IsDropped = 0:FadingLevel(nr) = 0
  1252. Case 5:a.IsDropped = 1:FadingLevel(nr) = 1
  1253. End Select
  1254. End Sub
  1255.  
  1256. Sub NFadeWim(nr, a)
  1257. Select Case FadingLevel(nr)
  1258. Case 4:a.IsDropped = 0
  1259. Case 5:a.IsDropped = 1
  1260. End Select
  1261. End Sub
  1262.  
  1263. 'Lights
  1264.  
  1265. Sub FadeL(nr, a, b)
  1266. Select Case FadingLevel(nr)
  1267. Case 4:a.state = 0:FadingLevel(nr) = 0:b.state = 0:FadingLevel(nr) = 0
  1268. Case 5:a.state = 1:FadingLevel(nr) = 1:b.state = 1:FadingLevel(nr) = 1
  1269. End Select
  1270. End Sub
  1271.  
  1272. Sub FadeLm(nr, a, b)
  1273. Select Case FadingLevel(nr)
  1274. Case 2:b.state = 0
  1275. Case 3:b.state = 1
  1276. Case 4:a.state = 0
  1277. Case 5:a.state = 1
  1278. End Select
  1279. End Sub
  1280.  
  1281. 'Sub NFadeL(nr, a)
  1282. ' Select Case FadingLevel(nr)
  1283. ' Case 4:a.state = 0:FadingLevel(nr) = 0
  1284. ' Case 5:a.State = 1:FadingLevel(nr) = 1
  1285. ' End Select
  1286. 'End Sub
  1287. '
  1288. 'Sub NFadeLm(nr, a)
  1289. ' Select Case FadingLevel(nr)
  1290. ' Case 4:a.state = 0
  1291. ' Case 5:a.State = 1
  1292. ' End Select
  1293. 'End Sub
  1294.  
  1295. Sub LMap(nr, a, b, c) 'can be used with normal/olod style lights too
  1296. Select Case FadingLevel(nr)
  1297. Case 2:c.state = 0:FadingLevel(nr) = 0
  1298. Case 3:b.state = 0:c.state = 1:FadingLevel(nr) = 2
  1299. Case 4:a.state = 0:b.state = 1:FadingLevel(nr) = 3
  1300. Case 5:b.state = 0:c.state = 0:a.state = 1:FadingLevel(nr) = 1
  1301. End Select
  1302. End Sub
  1303.  
  1304. Sub LMapm(nr, a, b, c)
  1305. Select Case FadingLevel(nr)
  1306. Case 2:c.state = 0
  1307. Case 3:b.state = 0:c.state = 1
  1308. Case 4:a.state = 0:b.state = 1
  1309. Case 5:b.state = 0:c.state = 0:a.state = 1
  1310. End Select
  1311. End Sub
  1312.  
  1313. 'Reels
  1314.  
  1315. Sub FadeR(nr, a)
  1316. Select Case FadingLevel(nr)
  1317. Case 2:a.SetValue 3:FadingLevel(nr) = 0
  1318. Case 3:a.SetValue 2:FadingLevel(nr) = 2
  1319. Case 4:a.SetValue 1:FadingLevel(nr) = 3
  1320. Case 5:a.SetValue 1:FadingLevel(nr) = 1
  1321. End Select
  1322. End Sub
  1323.  
  1324. Sub FadeRm(nr, a)
  1325. Select Case FadingLevel(nr)
  1326. Case 2:a.SetValue 3
  1327. Case 3:a.SetValue 2
  1328. Case 4:a.SetValue 1
  1329. Case 5:a.SetValue 1
  1330. End Select
  1331. End Sub
  1332.  
  1333. 'Texts
  1334.  
  1335. Sub NFadeT(nr, a, b)
  1336. Select Case FadingLevel(nr)
  1337. Case 4:a.Text = "":FadingLevel(nr) = 0
  1338. Case 5:a.Text = b:FadingLevel(nr) = 1
  1339. End Select
  1340. End Sub
  1341.  
  1342. Sub NFadeTm(nr, a, b)
  1343. Select Case FadingLevel(nr)
  1344. Case 4:a.Text = ""
  1345. Case 5:a.Text = b
  1346. End Select
  1347. End Sub
  1348.  
  1349. ' Flash a light, not controlled by the rom
  1350.  
  1351. Sub FlashL(nr, a, b)
  1352. Select Case FadingLevel(nr)
  1353. Case 1:b.state = 0:FadingLevel(nr) = 0
  1354. Case 2:b.state = 1:FadingLevel(nr) = 1
  1355. Case 3:a.state = 0:FadingLevel(nr) = 2
  1356. Case 4:a.state = 1:FadingLevel(nr) = 3
  1357. Case 5:b.state = 1:FadingLevel(nr) = 4
  1358. End Select
  1359. End Sub
  1360.  
  1361. ' Light acting as a flash. C is the light number to be restored
  1362.  
  1363. Sub MFadeL(nr, a, b, c)
  1364. Select Case FadingLevel(nr)
  1365. Case 2:b.state = 0:FadingLevel(nr) = 0:SetLamp c, FadingLevel(c)
  1366. Case 3:b.state = 1:FadingLevel(nr) = 2
  1367. Case 4:a.state = 0:FadingLevel(nr) = 3
  1368. Case 5:a.state = 1:FadingLevel(nr) = 1
  1369. End Select
  1370. End Sub
  1371.  
  1372. Sub MFadeLm(nr, a, b, c)
  1373. Select Case FadingLevel(nr)
  1374. Case 2:b.state = 0:SetLamp c, FadingLevel(c)
  1375. Case 3:b.state = 1
  1376. Case 4:a.state = 0
  1377. Case 5:a.state = 1
  1378. End Select
  1379. End Sub
  1380.  
  1381. 'Alpha Ramps used as fading lights
  1382. 'ramp is the name of the ramp
  1383. 'a,b,c,d are the images used for on...off
  1384. 'r is the refresh light
  1385.  
  1386. Sub FadeAR(nr, ramp, a, b, c, d)
  1387. Select Case FadingLevel(nr)
  1388. Case 2:ramp.image = d:FadingLevel(nr) = 0 'Off
  1389. Case 3:ramp.image = c:FadingLevel(nr) = 2 'fading...
  1390. Case 4:ramp.image = b:FadingLevel(nr) = 3 'fading...
  1391. Case 5:ramp.image = a:FadingLevel(nr) = 1 'ON
  1392. End Select
  1393. End Sub
  1394.  
  1395. Sub FadeARm(nr, ramp, a, b, c, d)
  1396. Select Case FadingLevel(nr)
  1397. Case 2:ramp.image = d
  1398. Case 3:ramp.image = c
  1399. Case 4:ramp.image = b
  1400. Case 5:ramp.image = a
  1401. End Select
  1402. End Sub
  1403.  
  1404. Sub FlashFO(nr, ramp, a, b, c) 'used for reflections when there is no off ramp
  1405. Select Case FadingLevel(nr)
  1406. Case 2:ramp.IsVisible = 0:FadingLevel(nr) = 0 'Off
  1407. Case 3:ramp.image = c:FadingLevel(nr) = 2 'fading...
  1408. Case 4:ramp.image = b:FadingLevel(nr) = 3 'fading...
  1409. Case 5:ramp.image = a:ramp.IsVisible = 1:FadingLevel(nr) = 1 'ON
  1410. End Select
  1411. End Sub
  1412.  
  1413. Sub FlashAR(nr, ramp, a, b, c) 'used for reflections when there is no off ramp
  1414. Select Case FadingLevel(nr)
  1415. Case 2:ramp.alpha = 0:FadingLevel(nr) = 0 'Off
  1416. Case 3:ramp.image = c:FadingLevel(nr) = 2 'fading...
  1417. Case 4:ramp.image = b:FadingLevel(nr) = 3 'fading...
  1418. Case 5:ramp.image = a:ramp.alpha = 1:FadingLevel(nr) = 1 'ON
  1419. End Select
  1420. End Sub
  1421.  
  1422. Sub FlashARm(nr, ramp, a, b, c)
  1423. Select Case FadingLevel(nr)
  1424. Case 2:ramp.alpha = 0
  1425. Case 3:ramp.image = c
  1426. Case 4:ramp.image = b
  1427. Case 5:ramp.image = a:ramp.alpha = 1
  1428. End Select
  1429. End Sub
  1430.  
  1431. Sub NFadeAR(nr, ramp, a, b)
  1432. Select Case FadingLevel(nr)
  1433. Case 4:ramp.image = b:FadingLevel(nr) = 0 'off
  1434. Case 5:ramp.image = a:FadingLevel(nr) = 1 'on
  1435. End Select
  1436. End Sub
  1437.  
  1438. Sub NFadeARm(nr, ramp, a, b)
  1439. Select Case FadingLevel(nr)
  1440. Case 4:ramp.image = b
  1441. Case 5:ramp.image = a
  1442. End Select
  1443. End Sub
  1444.  
  1445. Sub MNFadeAR(nr, ramp, a, b, c)
  1446. Select Case FadingLevel(nr)
  1447. Case 4:ramp.image = b:FadingLevel(nr) = 0:SetLamp c, FadingLevel(c) 'off
  1448. Case 5:ramp.image = a:FadingLevel(nr) = 1 'on
  1449. End Select
  1450. End Sub
  1451.  
  1452. Sub MNFadeARm(nr, ramp, a, b, c)
  1453. Select Case FadingLevel(nr)
  1454. Case 4:ramp.image = b:SetLamp c, FadingLevel(c) 'off
  1455. Case 5:ramp.image = a 'on
  1456. End Select
  1457. End Sub
  1458.  
  1459. ' Flashers using PRIMITIVES
  1460. ' pri is the name of the primitive
  1461. ' a,b,c,d are the images used for on...off
  1462.  
  1463. Sub FadePri(nr, pri, a, b, c, d)
  1464. Select Case FadingLevel(nr)
  1465. Case 2:pri.image = d:FadingLevel(nr) = 0 'Off
  1466. Case 3:pri.image = c:FadingLevel(nr) = 2 'fading...
  1467. Case 4:pri.image = b:FadingLevel(nr) = 3 'fading...
  1468. Case 5:pri.image = a:FadingLevel(nr) = 1 'ON
  1469. End Select
  1470. End Sub
  1471.  
  1472. Sub FadePri3m(nr, pri, group)
  1473. Select Case FadingLevel(nr)
  1474. Case 3:pri.image = group(2)
  1475. Case 4:pri.image = group(1)
  1476. Case 5:pri.image = group(0)
  1477. End Select
  1478. End Sub
  1479.  
  1480. Sub FadePri3(nr, pri, group)
  1481. Select Case FadingLevel(nr)
  1482. Case 3:pri.image = group(2):FadingLevel(nr) = 0 'Off
  1483. Case 4:pri.image = group(1):FadingLevel(nr) = 3 'fading...
  1484. Case 5:pri.image = group(0):FadingLevel(nr) = 1 'ON
  1485. End Select
  1486. End Sub
  1487.  
  1488.  
  1489.  
  1490.  
  1491. Sub FadePri4m(nr, pri, group)
  1492. Select Case FadingLevel(nr)
  1493. Case 2:pri.image = group(3) 'Off
  1494. Case 3:pri.image = group(2) 'Fading...
  1495. Case 4:pri.image = group(1) 'Fading...
  1496. Case 5:pri.image = group(0) 'ON
  1497. End Select
  1498. End Sub
  1499.  
  1500. Sub FadePri4(nr, pri, group)
  1501. Select Case FadingLevel(nr)
  1502. Case 2:pri.image = group(3):FadingLevel(nr) = 0 'Off
  1503. Case 3:pri.image = group(2):FadingLevel(nr) = 2 'Fading...
  1504. Case 4:pri.image = group(1):FadingLevel(nr) = 3 'Fading...
  1505. Case 5:pri.image = group(0):FadingLevel(nr) = 1 'ON
  1506. End Select
  1507. End Sub
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513.  
  1514.  
  1515.  
  1516.  
  1517.  
  1518.  
  1519.  
  1520. Sub FadePriC(nr, pri, a, b, c, d)
  1521. Select Case FadingLevel(nr)
  1522. Case 2:For each xx in pri:xx.image = d:Next:FadingLevel(nr) = 0 'Off
  1523. Case 3:For each xx in pri:xx.image = c:Next:FadingLevel(nr) = 2 'fading...
  1524. Case 4:For each xx in pri:xx.image = b:Next:FadingLevel(nr) = 3 'fading...
  1525. Case 5:For each xx in pri:xx.image = a:Next:FadingLevel(nr) = 1 'ON
  1526. End Select
  1527. End Sub
  1528.  
  1529. Sub FadePrih(nr, pri, a, b, c, d)
  1530. Select Case FadingLevel(nr)
  1531. Case 2:pri.image = d:SetFlash nr, 0:FadingLevel(nr) = 0 'Off
  1532. Case 3:pri.image = c:FadingLevel(nr) = 2 'fading...
  1533. Case 4:pri.image = b:FadingLevel(nr) = 3 'fading...
  1534. Case 5:pri.image = a:SetFlash nr, 1:FadingLevel(nr) = 1 'ON
  1535. End Select
  1536. End Sub
  1537.  
  1538. Sub FadePrim(nr, pri, a, b, c, d)
  1539. Select Case FadingLevel(nr)
  1540. Case 2:pri.image = d
  1541. Case 3:pri.image = c
  1542. Case 4:pri.image = b
  1543. Case 5:pri.image = a
  1544. End Select
  1545. End Sub
  1546.  
  1547. Sub NFadePri(nr, pri, a, b)
  1548. Select Case FadingLevel(nr)
  1549. Case 4:pri.image = b:FadingLevel(nr) = 0 'off
  1550. Case 5:pri.image = a:FadingLevel(nr) = 1 'on
  1551. End Select
  1552. End Sub
  1553.  
  1554. Sub NFadePrim(nr, pri, a, b)
  1555. Select Case FadingLevel(nr)
  1556. Case 4:pri.image = b
  1557. Case 5:pri.image = a
  1558. End Select
  1559. End Sub
  1560.  
  1561. 'Fade a collection of lights
  1562.  
  1563. Sub FadeLCo(nr, a, b) 'fading collection of lights
  1564. Dim obj
  1565. Select Case FadingLevel(nr)
  1566. Case 2:vpmSolToggleObj b, Nothing, 0, 0:FadingLevel(nr) = 0
  1567. Case 3:vpmSolToggleObj b, Nothing, 0, 1:FadingLevel(nr) = 2
  1568. Case 4:vpmSolToggleObj a, Nothing, 0, 0:FadingLevel(nr) = 3
  1569. Case 5:vpmSolToggleObj a, Nothing, 0, 1:FadingLevel(nr) = 1
  1570. End Select
  1571. End Sub
  1572.  
  1573. 'only for this table
  1574.  
  1575. ' Alternate two lights made with walls
  1576.  
  1577. Sub AlternateW(nr, a, b)
  1578. Select Case LampState(nr)
  1579. Case 4:SetLamp a, 0:SetLamp b, 0:LampState(nr) = 0 'both off
  1580. Case 5:SetLamp a, 1:SetLamp b, 0:LampState(nr) = 6 'On - Off
  1581. Case 6:LampState(nr) = 7 'wait
  1582. Case 7:LampState(nr) = 8 'wait
  1583. Case 8:LampState(nr) = 9 'wait
  1584. Case 9:LampState(nr) = 10 'wait
  1585. Case 10:SetLamp a, 0:SetLamp b, 1:LampState(nr) = 11 'Off - On
  1586. Case 11:LampState(nr) = 12 'wait
  1587. Case 12:LampState(nr) = 13 'wait
  1588. Case 13:LampState(nr) = 14 'wait
  1589. Case 14:LampState(nr) = 15 'wait
  1590. Case 15:LampState(nr) = 5
  1591. End Select
  1592. End Sub
  1593.  
  1594. '***********************
  1595. ' Visible Locks
  1596. ' Adapted to this table
  1597. ' based on the core.vbs
  1598. '***********************
  1599.  
  1600. Class cvpmVLock2
  1601. Private mTrig, mKick, mSw(), mSize, mBalls, mGateOpen, mRealForce, mBallSnd, mNoBallSnd
  1602. Public ExitDir, ExitForce, KickForceVar
  1603.  
  1604. Private Sub Class_Initialize
  1605. mBalls = 0:ExitDir = 0:ExitForce = 0:KickForceVar = 0:mGateOpen = False
  1606. vpmTimer.addResetObj Me
  1607. End Sub
  1608.  
  1609. Public Sub InitVLock(aTrig, aKick, aSw)
  1610. Dim ii
  1611. mSize = vpmSetArray(mTrig, aTrig)
  1612. If vpmSetArray(mKick, aKick) <> mSize Then MsgBox "cvpmVLock: Unmatched kick+trig":Exit Sub
  1613. On Error Resume Next
  1614. ReDim mSw(mSize)
  1615. If IsArray(aSw) Then
  1616. For ii = 0 To UBound(aSw):mSw(ii) = aSw(ii):Next
  1617. ElseIf aSw = 0 Or Err Then
  1618. For ii = 0 To mSize:mSw(ii) = mTrig(ii).TimerInterval:Next
  1619. Else
  1620. mSw(0) = aSw
  1621. End If
  1622. End Sub
  1623.  
  1624. Public Sub InitSnd(aBall, aNoBall):mBallSnd = aBall:mNoBallSnd = aNoBall:End Sub
  1625. Public Sub CreateEvents(aName)
  1626. Dim ii
  1627. If Not vpmCheckEvent(aName, Me) Then Exit Sub
  1628. For ii = 0 To mSize
  1629. vpmBuildEvent mTrig(ii), "Hit", aName & ".TrigHit ActiveBall," & ii + 1
  1630.  
  1631. vpmBuildEvent mTrig(ii), "Unhit", aName & ".TrigUnhit ActiveBall," & ii + 1
  1632.  
  1633. vpmBuildEvent mKick(ii), "Hit", aName & ".KickHit " & ii + 1
  1634. Next
  1635. End Sub
  1636.  
  1637. Public Sub SolExit(aEnabled)
  1638. Dim ii
  1639. mGateOpen = aEnabled
  1640. If Not aEnabled Then Exit Sub
  1641. If mBalls> 0 Then PlaySound mBallSnd:Else PlaySound mNoBallSnd:Exit Sub
  1642. For ii = 0 To mBalls-1
  1643. mKick(ii).Enabled = False:If mSw(ii) Then Controller.Switch(mSw(ii) ) = False
  1644. Next
  1645. ' If ExitForce > 0 Then ' Up
  1646. ' mRealForce = ExitForce + (Rnd - 0.5)*KickForceVar : mKick(mBalls-1).Kick ExitDir, mRealForce
  1647. ' Else ' Down
  1648. mRealForce = ExitForce + (Rnd - 0.5) * KickForceVar:mKick(0).Kick ExitDir, mRealForce
  1649. ' End If
  1650. End Sub
  1651.  
  1652. Public Sub Reset
  1653. Dim ii:If mBalls = 0 Then Exit Sub
  1654. For ii = 0 To mBalls-1
  1655. If mSw(ii) Then Controller.Switch(mSw(ii) ) = True
  1656. Next
  1657. End Sub
  1658.  
  1659. Public Property Get Balls:Balls = mBalls:End Property
  1660.  
  1661. Public Property Let Balls(aBalls)
  1662. Dim ii:mBalls = aBalls
  1663. For ii = 0 To mSize
  1664. If ii >= aBalls Then
  1665. mKick(ii).DestroyBall:If mSw(ii) Then Controller.Switch(mSw(ii) ) = False
  1666. Else
  1667. vpmCreateBall mKick(ii):If mSw(ii) Then Controller.Switch(mSw(ii) ) = True
  1668. End If
  1669. Next
  1670. End Property
  1671.  
  1672. Public Sub TrigHit(aBall, aNo)
  1673. aNo = aNo - 1:If mSw(aNo) Then Controller.Switch(mSw(aNo) ) = True
  1674. If aBall.VelY <-1 Then Exit Sub ' Allow small upwards speed
  1675. If aNo = mSize Then mBalls = mBalls + 1
  1676. If mBalls> aNo Then mKick(aNo).Enabled = Not mGateOpen
  1677. End Sub
  1678.  
  1679. Public Sub TrigUnhit(aBall, aNo)
  1680. aNo = aNo - 1:If mSw(aNo) Then Controller.Switch(mSw(aNo) ) = False
  1681. If aBall.VelY> -1 Then
  1682. If aNo = 0 Then mBalls = mBalls - 1
  1683. If aNo <mSize Then mKick(aNo + 1).Kick 0, 0
  1684. Else
  1685. If aNo = mSize Then mBalls = mBalls - 1
  1686. If aNo> 0 Then mKick(aNo-1).Kick ExitDir, mRealForce
  1687. End If
  1688. End Sub
  1689.  
  1690. Public Sub KickHit(aNo):mKick(aNo-1).Enabled = False:End Sub
  1691. End Class
  1692.  
  1693.  
  1694.  
  1695.  
  1696.  
  1697.  
  1698.  
  1699.  
  1700.  
  1701. ' *********************************************************************
  1702. ' Supporting Ball & Sound Functions
  1703. ' *********************************************************************
  1704.  
  1705. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  1706. Vol = Csng(BallVel(ball) ^2 / 2000) * 100
  1707. End Function
  1708.  
  1709. Function Vol2(ball1, ball2) ' Calculates the Volume of the sound based on the speed of two balls
  1710. Vol2 = (Vol(ball1) + Vol(ball2) ) / 2
  1711. End Function
  1712.  
  1713. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  1714. Dim tmp
  1715. tmp = ball.x * 2 / table1.width-1
  1716. If tmp> 0 Then
  1717. Pan = Csng(tmp ^10)
  1718. Else
  1719. Pan = Csng(-((- tmp) ^10) )
  1720. End If
  1721. End Function
  1722.  
  1723. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  1724. Pitch = BallVel(ball) * 20
  1725. End Function
  1726.  
  1727. Function BallVel(ball) 'Calculates the ball speed
  1728. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  1729. End Function
  1730.  
  1731. '*****************************************
  1732. ' JP's VP10 Collision & Rolling Sounds
  1733. '*****************************************
  1734.  
  1735. Const tnob = 8 ' total number of balls
  1736. ReDim rolling(tnob)
  1737. ReDim collision(tnob)
  1738. Initcollision
  1739.  
  1740. Sub Initcollision
  1741. Dim i
  1742. For i = 0 to tnob
  1743. collision(i) = -1
  1744. rolling(i) = False
  1745. Next
  1746. End Sub
  1747.  
  1748. Sub CollisionTimer_Timer()
  1749. Dim BOT, B, B1, B2, dx, dy, dz, distance, radii
  1750. BOT = GetBalls
  1751.  
  1752. ' rolling
  1753.  
  1754. For B = UBound(BOT) +1 to tnob
  1755. rolling(b) = False
  1756. StopSound("fx_ballrolling" & b)
  1757. Next
  1758.  
  1759. If UBound(BOT) = -1 Then Exit Sub
  1760.  
  1761. For B = 0 to UBound(BOT)
  1762. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  1763. rolling(b) = True
  1764. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  1765. Else
  1766. If rolling(b) = True Then
  1767. StopSound("fx_ballrolling" & b)
  1768. rolling(b) = False
  1769. End If
  1770. End If
  1771. Next
  1772.  
  1773. 'collision
  1774.  
  1775. If UBound(BOT) < 1 Then Exit Sub
  1776.  
  1777. For B1 = 0 to UBound(BOT)
  1778. For B2 = B1 + 1 to UBound(BOT)
  1779. dz = INT(ABS((BOT(b1).z - BOT(b2).z) ) )
  1780. radii = BOT(b1).radius + BOT(b2).radius
  1781. If dz <= radii Then
  1782.  
  1783. dx = INT(ABS((BOT(b1).x - BOT(b2).x) ) )
  1784. dy = INT(ABS((BOT(b1).y - BOT(b2).y) ) )
  1785. distance = INT(SQR(dx ^2 + dy ^2) )
  1786.  
  1787. If distance <= radii AND (collision(b1) = -1 OR collision(b2) = -1) Then
  1788. collision(b1) = b2
  1789. collision(b2) = b1
  1790. PlaySound("fx_collide"), 0, Vol2(BOT(b1), BOT(b2)), Pan(BOT(b1)), 0, Pitch(BOT(b1)), 0, 0
  1791. Else
  1792. If distance > (radii + 10) Then
  1793. If collision(b1) = b2 Then collision(b1) = -1
  1794. If collision(b2) = b1 Then collision(b2) = -1
  1795. End If
  1796. End If
  1797. End If
  1798. Next
  1799. Next
  1800. End Sub
  1801.  
  1802.  
  1803. '************************************
  1804. ' What you need to add to your table
  1805. '************************************
  1806.  
  1807. ' a timer called CollisionTimer. With a fast interval, like from 1 to 10
  1808. ' one collision sound, in this script is called fx_collide
  1809. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  1810. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  1811.  
  1812.  
  1813. '******************************************
  1814. ' Explanation of the rolling sound routine
  1815. '******************************************
  1816.  
  1817. ' sounds are played based on the ball speed and position
  1818.  
  1819. ' the routine checks first for deleted balls and stops the rolling sound.
  1820.  
  1821. ' The For loop goes through all the balls on the table and checks for the ball speed and
  1822. ' if the ball is on the table (height lower than 30) then then it plays the sound
  1823. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  1824.  
  1825. ' The sound is played using the VOL, PAN and PITCH functions, so the volume and pitch of the sound
  1826. ' will change according to the ball speed, and the PAN function will change the stereo position according
  1827. ' to the position of the ball on the table.
  1828.  
  1829.  
  1830. '**************************************
  1831. ' Explanation of the collision routine
  1832. '**************************************
  1833.  
  1834. ' The Double For loop: This is a double cycle used to check the collision between a ball and the other ones.
  1835. ' If you look at the parameters of both cycles, you’ll notice they are designed to avoid checking
  1836. ' collision twice. For example, I will never check collision between ball 2 and ball 1,
  1837. ' because I already checked collision between ball 1 and 2. So, if we have 4 balls,
  1838. ' the collision checks will be: ball 1 with 2, 1 with 3, 1 with 4, 2 with 3, 2 with 4 and 3 with 4.
  1839.  
  1840. ' Sum first the radius of both balls, and if the height between them is higher then do not calculate anything more,
  1841. ' since the balls are on different heights so they can't collide.
  1842.  
  1843. ' The next 3 lines calculates distance between xth and yth balls with the Pytagorean theorem,
  1844.  
  1845. ' The first "If": Checking if the distance between the two balls is less than the sum of the radius of both balls,
  1846. ' and both balls are not already colliding.
  1847.  
  1848. ' Why are we checking if balls are already in collision?
  1849. ' Because we do not want the sound repeting when two balls are resting closed to each other.
  1850.  
  1851. ' Set the collision property of both balls to True, and we assign the number of the ball colliding
  1852.  
  1853. ' Play the collide sound of your choice using the VOL, PAN and PITCH functions
  1854.  
  1855. ' Last lines: If the distance between 2 balls is more than the radius of a ball,
  1856. ' then there is no collision and then set the collision property of the ball to False (-1).
  1857.  
  1858.  
  1859. Sub Pins_Hit (idx)
  1860. PlaySound "pinhit_low", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  1861. End Sub
  1862.  
  1863. Sub Targets_Hit (idx)
  1864. PlaySound "target", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  1865. End Sub
  1866.  
  1867. Sub Metals_Thin_Hit (idx)
  1868. PlaySound "metalhit_thin", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1869. End Sub
  1870.  
  1871. Sub Metals_Medium_Hit (idx)
  1872. PlaySound "metalhit_medium", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1873. End Sub
  1874.  
  1875. Sub Metals2_Hit (idx)
  1876. PlaySound "metalhit2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1877. End Sub
  1878.  
  1879. Sub Gates_Hit (idx)
  1880. PlaySound "gate4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1881. End Sub
  1882.  
  1883. Sub Spinner_Spin
  1884. PlaySound "fx_spinner",0,.25,0,0.25
  1885. End Sub
  1886.  
  1887. Sub Rubbers_Hit(idx)
  1888. dim finalspeed
  1889. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1890. If finalspeed > 20 then
  1891. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1892. End if
  1893. If finalspeed >= 6 AND finalspeed <= 20 then
  1894. RandomSoundRubber()
  1895. End If
  1896. End Sub
  1897.  
  1898. Sub Posts_Hit(idx)
  1899. dim finalspeed
  1900. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1901. If finalspeed > 16 then
  1902. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1903. End if
  1904. If finalspeed >= 6 AND finalspeed <= 16 then
  1905. RandomSoundRubber()
  1906. End If
  1907. End Sub
  1908.  
  1909. Sub RandomSoundRubber()
  1910. Select Case Int(Rnd*3)+1
  1911. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1912. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1913. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1914. End Select
  1915. End Sub
  1916.  
  1917. Sub LeftFlipper_Collide(parm)
  1918. RandomSoundFlipper()
  1919. End Sub
  1920.  
  1921. Sub RightFlipper_Collide(parm)
  1922. RandomSoundFlipper()
  1923. End Sub
  1924.  
  1925. Sub RandomSoundFlipper()
  1926. Select Case Int(Rnd*3)+1
  1927. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1928. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1929. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  1930. End Select
  1931. End Sub
Advertisement
Add Comment
Please, Sign In to add comment