Arngrim

U Boat

Apr 8th, 2021 (edited)
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 41.51 KB | None | 0 0
  1. option Explicit
  2. Randomize
  3.  
  4. On Error Resume Next
  5. ExecuteGlobal GetTextFile("controller.vbs")
  6. If Err Then MsgBox "You need the controller.vbs in order to run this table, available in the vp10 package"
  7. On Error Goto 0
  8.  
  9. ' ball size
  10. 'Const BallSize = 50 ' sets the ball size
  11. 'Const BallMass = 1.95
  12.  
  13. Const cgamename = "uboat65", UseSolenoids=1,UseLamps=0,UseGI=0, SCoin="coin3"
  14. Const FreePlay = True 'add a coin on StartGame
  15. Const WatchdogActive = False 'activates the watchdog to correct some ROM issues
  16.  
  17. LoadVPM "01560000","nuova.vbs",3.2
  18.  
  19. '*************************************************************
  20. 'Solenoid Call backs
  21. '**********************************************************************************************************
  22.  
  23.  
  24. SolCallback(3)="vpmSolSound ""knocker"","
  25. SolCallback(5)="bsTrough.SolOut"
  26. SolCallback(7)="bsTrough.SolIn" '"SolOuthole"
  27. SolCallback(14)="SolVUKPopper"
  28. SolCallback(15)="Sol15" '"bsLeftKicker.SolOut"
  29. SolCallback(17)="SolMotor"
  30. SolCallback(19)="Sol19" 'SolGameOn
  31. SolCallback(20)="SolRamp"
  32.  
  33. SolCallback(sLRFlipper) = "SolRFlipper"
  34. SolCallback(sLLFlipper) = "SolLFlipper"
  35.  
  36. Sub SolLFlipper(Enabled)
  37. If Enabled Then
  38. PlaySound SoundFX("FlipperUp_Akiles",DOFFlippers):LeftFlipper.RotateToEnd
  39. Else
  40. PlaySound SoundFX("FlipperDown_Akiles",DOFFlippers):LeftFlipper.RotateToStart
  41. End If
  42. End Sub
  43.  
  44. Sub SolRFlipper(Enabled)
  45. If Enabled Then
  46. PlaySound SoundFX("FlipperUp_Akiles",DOFFlippers):RightFlipper.RotateToEnd
  47. Else
  48. PlaySound SoundFX("FlipperDown_Akiles",DOFFlippers):RightFlipper.RotateToStart
  49. End If
  50. End Sub
  51.  
  52. '**********************************************************************************************************
  53. 'Solenoid Controlled toys
  54. '**********************************************************************************************************
  55.  
  56. Sub Sol19(enabled)
  57. VpmNudge.SolGameOn enabled
  58. Flipperactive = enabled
  59. if WatchdogActive then
  60. if not enabled then
  61. Sol15(True)
  62. vpmTimer.AddTimer 1000,"SolVUKPopper(True)'"
  63. vpmTimer.AddTimer 2500,"Sol15(True)'"
  64. end if
  65. end if
  66. end sub
  67.  
  68. Sub Sol15(enabled)
  69. if WatchdogActive then
  70. if SW24WatchdogTimer.enabled Then Exit Sub
  71. if Controller.switch(41) Then Exit Sub
  72. end if
  73. if enabled then
  74. if bsLeftKicker.balls then
  75. bsLeftKicker.ExitSol_On
  76. end if
  77. end if
  78. end sub
  79.  
  80. 'Playfield GI
  81. '*****GI Lights On
  82. dim xx
  83. For each xx in GI:xx.State = 1: Next
  84.  
  85. '**********************************************************************************************************
  86. 'Plunger code
  87. '**********************************************************************************************************
  88.  
  89.  
  90. Sub Table1_KeyDown(ByVal Keycode)
  91. If keycode = LeftMagnaSave Then bLutActive = True
  92. If keycode = RightMagnaSave Then
  93. If bLutActive Then NextLUT: End If
  94. End If
  95. If KeyCode=LeftFlipperKey Then Controller.Switch(12)=1
  96. If KeyCode=RightFlipperKey Then Controller.Switch(5)=1
  97. If KeyCode=PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  98. if FreePlay and keycode = Startgamekey then
  99. vpmtimer.pulsesw 9
  100. end if
  101. If KeyDownHandler(keycode) Then Exit Sub
  102. End Sub
  103.  
  104. Sub Table1_KeyUp(ByVal Keycode)
  105. If keycode = LeftMagnaSave Then bLutActive = False
  106. If KeyCode=LeftFlipperKey Then Controller.Switch(12)=0
  107. If KeyCode=RightFlipperKey Then Controller.Switch(5)=0
  108. If KeyCode=PlungerKey Then PlaySound"plunger":Plunger.Fire
  109. If KeyUpHandler(keycode) Then Exit Sub
  110. End Sub
  111.  
  112.  
  113.  
  114. ' Movable Ramp
  115. Dim RampIsDown,RampDir
  116. Sub SolRamp(enabled)
  117. if enabled then
  118. RampIsDown = False
  119. RampDir = 5
  120. RampDown.collidable = False
  121. RampUp.collidable = True
  122. RampTimer.enabled = True
  123. if WatchdogActive then
  124. RampSwitchTimer1.enabled = True
  125. end if
  126. Playsound SoundFX("flapopen",DOFContactors),0,0.5,-0.15,0.2
  127. else
  128. if WatchdogActive then
  129. RampSwitchTimer2.enabled = True
  130. else
  131. RampIsDown = True
  132. RampDir = -5
  133. RampDown.collidable = True
  134. RampUp.collidable = False
  135. RampTimer.enabled = True
  136. Playsound SoundFX("flapclos",DOFContactors),0,0.5,-0.15,0.2
  137. end if
  138. end if
  139. end sub
  140.  
  141. Sub RampTimer_Timer
  142. P_BridgeRamp.rotx = P_BridgeRamp.rotx + RampDir
  143. P_Ramparm.rotx = P_Ramparm.rotx - (RampDir*2)
  144.  
  145. if P_BridgeRamp.rotx < -22 then
  146. RampTimer.enabled = False
  147. P_BridgeRamp.rotx = -22
  148. P_Ramparm.rotx = 40
  149. end if
  150. if P_BridgeRamp.rotx > 5 then
  151. RampTimer.enabled = False
  152. P_BridgeRamp.rotx = 5
  153. P_Ramparm.rotx = -15
  154. end if
  155. End Sub
  156.  
  157. Sub RampSwitchTimer1_Timer
  158. RampSwitchTimer1.enabled = False
  159. End Sub
  160.  
  161. Sub RampSwitchTimer2_Timer
  162. if not RampSwitchTimer1.enabled then
  163. if not controller.solenoid(20) then
  164. RampSwitchTimer2.enabled = False
  165. RampIsDown = True
  166. RampDir = -5
  167. RampDown.collidable = True
  168. RampUp.collidable = False
  169. RampTimer.enabled = True
  170. Playsound "flapclos",0,0.5,-0.15,0.2
  171. end if
  172. end if
  173. End Sub
  174.  
  175. ' Target Bank
  176. Dim BankIsUp, MotorDir, MotorPos
  177. MotorPos = 0
  178. Sub SolMotor(enabled)
  179. if WatchdogActive then Exit Sub
  180. if enabled then
  181. Controller.switch(47) = False
  182. Controller.switch(48) = False
  183. if BankIsUp then
  184. MotorDir = - 1
  185. else
  186. MotorDir = 1
  187. end if
  188. MotorTimer.enabled = True
  189. else
  190. MotorTimer.enabled = False
  191. if MotorPos < -45 then
  192. MotorPos = -50
  193. end if
  194. if MotorPos > -5 then
  195. MotorPos = 0
  196. end if
  197. end if
  198. End Sub
  199.  
  200. Sub MotorTimer_Timer
  201. Playsound SoundFX("Motor1",DOFGear),0,1,0.1,0.1
  202.  
  203. MotorPos = MotorPos + MotorDir
  204.  
  205. if MotorPos > -40 then
  206. P_TargetCover.collidable = True
  207. P_TargetCover2.collidable = True
  208. end if
  209.  
  210. if (MotorPos < 0) and (MotorPos > -50) then
  211. Controller.switch(47) = False
  212. Controller.switch(48) = False
  213. END IF
  214.  
  215. if (MotorPos <= 0) and (MotorPos >= -50) then
  216. P_T21.TransZ = MotorPos
  217. P_T20.TransZ = MotorPos
  218. P_T19.TransZ = MotorPos
  219. P_T18.TransZ = MotorPos
  220. P_T17.TransZ = MotorPos
  221. P_TargetCover.TransZ = MotorPos
  222. P_TargetCover2.TransZ = MotorPos
  223. end if
  224.  
  225. if MotorPos >= 0 then
  226. if WatchdogActive then
  227. MotorActive = False
  228. MotorTimer.enabled = False
  229. if MotorPos < -45 then
  230. MotorPos = -50
  231. end if
  232. if MotorPos > -5 then
  233. MotorPos = 0
  234. end if
  235. end if
  236. BankIsUp = True
  237. Controller.switch(47) = False
  238. Controller.switch(48) = True
  239. P_T21.TransZ = 0
  240. P_T20.TransZ = 0
  241. P_T19.TransZ = 0
  242. P_T18.TransZ = 0
  243. P_T17.TransZ = 0
  244. P_TargetCover.TransZ = 0
  245. P_TargetCover2.TransZ = 0
  246. Target17.isdropped = False
  247. Target18.isdropped = False
  248. Target19.isdropped = False
  249. Target20.isdropped = False
  250. Target21.isdropped = False
  251. DTRescue.isdropped = False
  252. if MotorPos > 10 then
  253. MotorDir = - MotorDir
  254. end if
  255. end if
  256.  
  257. if MotorPos <= -50 then
  258. if WatchdogActive then
  259. MotorActive = False
  260. MotorTimer.enabled = False
  261. if MotorPos < -45 then
  262. MotorPos = -50
  263. end if
  264. if MotorPos > -5 then
  265. MotorPos = 0
  266. end if
  267. end if
  268. BankIsUp = False
  269. Controller.switch(47) = True
  270. Controller.switch(48) = False
  271. P_T21.TransZ = -50
  272. P_T20.TransZ = -50
  273. P_T19.TransZ = -50
  274. P_T18.TransZ = -50
  275. P_T17.TransZ = -50
  276. P_TargetCover.TransZ = -50
  277. P_TargetCover2.TransZ = -50
  278. Target17.isdropped = True
  279. Target18.isdropped = True
  280. Target19.isdropped = True
  281. Target20.isdropped = True
  282. Target21.isdropped = True
  283. P_TargetCover.collidable = False
  284. P_TargetCover2.collidable = False
  285. DTRescue.isdropped = True
  286. if MotorPos < -60 then
  287. MotorDir = - MotorDir
  288. End if
  289. end if
  290. End Sub
  291.  
  292.  
  293. ' Vuk Popper code from JPSalas
  294. Dim VUKBall, VUKBallZpos, AnimStarted
  295. AnimStarted = 0
  296.  
  297. Sub SolVUKPopper(Enabled)
  298. if WatchdogActive then
  299. if SW24WatchdogTimer.enabled Then Exit Sub
  300. if Controller.switch(41) Then Exit Sub
  301. end if
  302.  
  303. If AnimStarted Then Exit Sub
  304. If Enabled Then
  305. If bsRightVUK.Balls Then
  306. 'bsRightVUK.ExitSol_On
  307. AnimStarted = 1
  308. RightVUK.DestroyBall
  309. Set VUKBall = RightVUK.Createball
  310. VUKBallZpos = 25
  311. RightVUK.TimerInterval = 1
  312. RightVUK.TimerEnabled = 1
  313. End If
  314. End If
  315. End Sub
  316.  
  317. Sub RightVUK_Timer
  318. VUKBall.Z = VUKBallZpos
  319. VUKBallZpos = VUKBallZpos + 10
  320. If VUKBallZpos> 125 Then
  321. RightVUK.TimerEnabled = 0
  322. RightVUK.DestroyBall
  323. bsRightVUK.ExitSol_On
  324. AnimStarted = 0
  325. End If
  326. End Sub
  327.  
  328.  
  329. '--------------------------
  330. '------ Table Init ------
  331. '--------------------------
  332. Dim bsTrough,obj,bsLeftKicker,bsRightVUK,Flipperactive
  333.  
  334. Sub Table1_Init
  335. 'Drain Helper to register balls correctly
  336. DrainWall1.isdropped = True
  337. DrainWall2.isdropped = True
  338.  
  339. vpminit me
  340.  
  341. Controller.GameName=cGameName
  342. Controller.SplashInfoLine="U-Boat 65" & vbNewLine & "created by mfuegemann"
  343. Controller.HandleKeyboard=False
  344. Controller.ShowTitle=0
  345. Controller.ShowFrame=0
  346. Controller.ShowDMDOnly=1
  347. 'Controller.Hidden = 1 'enable to hide DMD if You use a B2S backglass
  348.  
  349.  
  350. Controller.HandleMechanics=0
  351.  
  352. Controller.SolMask(0)=0
  353. vpmTimer.AddTimer 3000,"Controller.SolMask(0)=&Hffffffff'" 'ignore all solenoids - then add the timer to renable all the solenoids after 2 seconds
  354.  
  355. Controller.Run
  356. If Err Then MsgBox Err.Description
  357. On Error Goto 0
  358.  
  359. PinMAMETimer.Interval=PinMAMEInterval
  360. PinMAMETimer.Enabled = true
  361.  
  362. vpmNudge.TiltSwitch=7
  363. vpmNudge.Sensitivity=5
  364. vpmNudge.TiltObj = Array(Bumper1,Bumper2,Bumper3,LeftSlingshot,RightSlingshot,URightSlingshot)
  365.  
  366.  
  367. 'init Target bank up
  368. BankIsUp = True
  369. Controller.switch(47) = False
  370. Controller.switch(48) = True
  371. Target17.isdropped = False
  372. Target18.isdropped = False
  373. Target19.isdropped = False
  374. Target20.isdropped = False
  375. Target21.isdropped = False
  376.  
  377. 'init Ramp down
  378. RampIsDown = True
  379. ' RampDown.isvisible = RampIsDown
  380. RampDown.collidable = RampIsDown
  381. ' RampUp.isvisible = not RampIsDown
  382. RampUp.collidable = not RampIsDown
  383. if RampIsDown then
  384. P_BridgeRamp.rotx = -22
  385. P_Ramparm.rotx = 40
  386. else
  387. P_BridgeRamp.rotx = 5
  388. P_Ramparm.rotx = -15
  389. end if
  390.  
  391. Set bsTrough=New cvpmBallStack
  392. bsTrough.InitSw 8,3,2,1,0,0,0,0 '0.1 = Switch 0
  393. bsTrough.InitKick BallRelease,90,5
  394. bsTrough.InitExitSnd SoundFX("BallRel",DOFContactors),SoundFX("Solenoid",DOFContactors)
  395. bsTrough.Balls=3
  396.  
  397. Set bsLeftKicker = New cvpmBallStack
  398. bsLeftKicker.InitExitSnd SoundFX("Popper",DOFContactors),SoundFX("Solenoid",DOFContactors)
  399. bsLeftKicker.initsaucer LeftKicker,45,0,20
  400.  
  401. Set bsRightVUK = New cvpmBallStack
  402. bsRightVUK.InitExitSnd SoundFX("Popper",DOFContactors),SoundFX("Solenoid",DOFContactors)
  403. bsRightVUK.initsaucer VUKTop,46,260,20
  404.  
  405. End Sub
  406.  
  407. '------------------------------
  408. '------ Trough Handler ------
  409. '------------------------------
  410. Sub Drain_Hit()
  411. 'Ball Drain after 2 balls are locked - the ROM does not recognize the drain if both switches 45 and 46 are ON
  412. if WatchdogActive then
  413. DrainWall1.isdropped = False
  414. DrainWall1.Timerenabled = True
  415. DrainWall2.isdropped = False
  416. DrainWall2.Timerenabled = True
  417.  
  418. if Controller.Switch(45) and Controller.Switch(46) then
  419. Controller.Switch(3) = True
  420. Controller.Switch(2) = True
  421. Controller.Switch(1) = True
  422. Controller.Switch(45) = False
  423. Controller.Switch(46) = False
  424. BallDrainTimer.enabled = True
  425. end if
  426. end if
  427.  
  428.  
  429. SoundTimer.enabled = False
  430. bsTrough.AddBall Me
  431. playsound "Drain5"
  432. End Sub
  433.  
  434. '----------------------------
  435. '------ ROM Watchdog ------
  436. '----------------------------
  437. WatchdogTimer.enabled = WatchdogActive
  438. Dim MotorActive,ActiveBalls
  439. MotorActive = False
  440. Sub WatchdogTimer_Timer
  441. 'Ball Launch after Lock - the ROM sometimes misses to kick the 3rd ball out after ball lock 2
  442. if Controller.Switch(45) and Controller.Switch(46) and Controller.Switch(3) and not BallDrainTimer.enabled then
  443. BallLaunchTimer.enabled = True
  444. end if
  445.  
  446. ActiveBalls = 0
  447. if not controller.switch(1) then
  448. ActiveBalls = ActiveBalls + 1
  449. end if
  450. if not controller.switch(2) then
  451. ActiveBalls = ActiveBalls + 1
  452. end if
  453. if not controller.switch(3) then
  454. ActiveBalls = ActiveBalls + 1
  455. end if
  456. if controller.switch(45) then
  457. ActiveBalls = ActiveBalls - 1
  458. end if
  459. if controller.switch(46) then
  460. ActiveBalls = ActiveBalls - 1
  461. end if
  462. if ActiveBalls = 0 then
  463. TargetBankUpTimer.enabled = False
  464. TargetBankDownTimer.enabled = False
  465. end if
  466. End Sub
  467.  
  468. Sub BallLaunchTimer_Timer
  469. BallLaunchTimer.enabled = False
  470. bstrough.ExitSol_On
  471. End Sub
  472.  
  473. Sub BallDrainTimer_Timer
  474. Controller.Switch(45) = True
  475. Controller.Switch(46) = True
  476. Controller.Switch(2) = False
  477. Controller.Switch(1) = False
  478. BallDrainTimer.enabled = False
  479. End Sub
  480.  
  481. Sub DrainWall1_Timer
  482. DrainWall1.Timerenabled = False
  483. DrainWall1.isdropped = True
  484. End Sub
  485. Sub DrainWall2_Timer
  486. DrainWall2.Timerenabled = False
  487. DrainWall2.isdropped = True
  488. DrainWall1.isdropped = False
  489. DrainWall1.Timerenabled = True
  490. End Sub
  491.  
  492. 'Avoid early VUK kick
  493. Sub SW24WatchdogTimer_timer
  494. SW24WatchdogTimer.enabled = False
  495. End Sub
  496.  
  497. 'Avoid moving Target bank on Ball Lock 2
  498. Sub SW34WatchdogTimer_timer
  499. SW34WatchdogTimer.enabled = False
  500. End Sub
  501.  
  502. Sub TargetBankUpTimer_Timer
  503. TargetBankUpTimer.enabled = False
  504. if BankIsUp then
  505. MotorDir = - 1
  506. MotorTimer.enabled = True
  507. end if
  508. End Sub
  509.  
  510. Dim OnCount,TotalCount
  511. Sub TargetBankDownTimer_Timer
  512. TotalCount = Totalcount + 1
  513. if Controller.lamp(1) and Controller.lamp(1) then
  514. OnCount = OnCount + 1
  515. end if
  516. if TotalCount >= 20 then
  517. TargetBankDownTimer.enabled = False
  518. if (not BankIsUp) and (OnCount > 10) then
  519. MotorDir = 1
  520. MotorTimer.enabled = True
  521. end if
  522. end if
  523. End Sub
  524.  
  525. 'Avoid stuck balls behind lowered ramp
  526. Sub RampRescue_Hit
  527. RampRescue.Timerenabled = True
  528. End Sub
  529.  
  530. Sub RampRescue1_Hit
  531. if RampIsDown and RampRescue.Timerenabled then
  532. RampRescue.Timerenabled = False
  533. SolRamp(True)
  534. vpmTimer.AddTimer 100,"SolRamp(False)'"
  535. end if
  536. End Sub
  537.  
  538. Sub RampRescue_Timer
  539. RampRescue.Timerenabled = False
  540. End Sub
  541.  
  542. 'Avoid stuck balls behind raised DT bank
  543. Sub DTRescue_Hit
  544. DTRescue.timerenabled = True
  545. TargetBankUpTimer.enabled = True
  546. End Sub
  547.  
  548. Sub DTRescue_Timer
  549. DTRescue.timerenabled = False
  550. End Sub
  551.  
  552.  
  553. '------------------------------
  554. '------ Switch Handler ------
  555. '------------------------------
  556.  
  557. Sub RightVUK_Hit
  558. SoundTimer.enabled = False
  559. Playsound "Gobblehole",0,0.5,0.16,0.1
  560. bsRightVUK.addball Me
  561. End Sub
  562. Sub LeftKicker_Hit
  563. SoundTimer.enabled = False
  564. Playsound "Gobblehole",0,0.5,-0.16,0.1
  565. bsLeftKicker.addball 0
  566. End Sub
  567.  
  568. ' Rollover Switches
  569.  
  570. sub LOutlane_hit:Controller.Switch(42)=1:PlaySound "rollover",0,0.1,-0.16,0.1:DOF 101, DOFOn:End Sub
  571. sub LOutlane_unhit:Controller.Switch(42)=0:DOF 101, DOFOff:End Sub
  572.  
  573. sub LInlane_hit:Controller.Switch(44)=1:PlaySound "rollover",0,0.1,-0.15,0.1:End Sub
  574. sub LInlane_unhit:Controller.Switch(44)=0:End Sub
  575.  
  576. sub ROutlane_hit:Controller.Switch(42)=1:PlaySound "rollover",0,0.1,0.16,0.1:DOF 102, DOFOn:End Sub
  577. sub ROutlane_unhit:Controller.Switch(42)=0:DOF 102, DOFOff:End Sub
  578.  
  579. sub RInlane_hit:Controller.Switch(43)=1:PlaySound "rollover",0,0.1,0.15,0.1:End Sub
  580. sub RInlane_unhit:Controller.Switch(43)=0:End Sub
  581.  
  582. sub SW13_hit:Controller.Switch(13)=1:PlaySound "rollover",0,0.1,0,0.1:End Sub
  583. sub SW13_unhit:Controller.Switch(13)=0:End Sub
  584.  
  585. sub SW14_hit:Controller.Switch(14)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  586. sub SW14_unhit:Controller.Switch(14)=0:End Sub
  587.  
  588. sub SW15_hit:Controller.Switch(15)=1:PlaySound "rollover",0,0.1,-0.1,0.1:End Sub
  589. sub SW15_unhit:Controller.Switch(15)=0:End Sub
  590.  
  591. sub SW23_hit:Controller.Switch(23)=1:PlaySound "rollover",0,0.1,0.15,0.1:End Sub
  592. sub SW23_unhit:Controller.Switch(23)=0:End Sub
  593.  
  594. sub SW24_hit
  595. If Watchdogactive then
  596. SW24WatchdogTimer.enabled = True
  597. end if
  598. PlaySound "rollover",0,0.1,-0.12,0.1:
  599. Controller.Switch(24)=1
  600. End Sub
  601.  
  602. sub SW24_unhit:SW24.timerenabled=True:Controller.Switch(24)=0:End Sub
  603.  
  604. sub SW33_hit:Controller.Switch(33)=1:PlaySound "rollover",0,0.1,-0.15,0.1:End Sub
  605. sub SW33_unhit:Controller.Switch(33)=0:End Sub
  606.  
  607. sub SW34_hit
  608. If Watchdogactive and bsRightVUK.balls then
  609. SolVUKPopper(True)
  610. SW34WatchdogTimer.enabled = True
  611. end if
  612. PlaySound "rollover",0,0.1,0.15,0.1:
  613. Controller.Switch(34)=1
  614. End Sub
  615. sub SW34_unhit:LOutlane.timerenabled=True:Controller.Switch(34)=0:End Sub
  616.  
  617. sub SW41_hit
  618. PlaySound "rollover",0,0.1,0.18,0.1:
  619. Controller.Switch(41)=1
  620. if WatchdogActive then
  621. Controller.switch(5)=1
  622. BallLaunchTimer.enabled = False
  623. end if
  624. End Sub
  625. sub SW41_unhit
  626. Controller.Switch(41)=0
  627. if WatchdogActive then
  628. Controller.switch(5)=0
  629. end if
  630. End Sub
  631.  
  632. ' Targets
  633.  
  634. Sub Target4_Hit:vpmTimer.PulseSw 4:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.02,0.1:End Sub
  635.  
  636. Sub Target17_Hit:vpmTimer.PulseSw 17:MoveTarget17:PlaySound SoundFX("Target1",DOFTargets),0,1,0.16,0.1:End Sub
  637. Sub Target18_Hit:vpmTimer.PulseSw 18:MoveTarget18:PlaySound SoundFX("Target1",DOFTargets),0,1,0.14,0.1:End Sub
  638. Sub Target19_Hit:vpmTimer.PulseSw 19:MoveTarget19:PlaySound SoundFX("Target1",DOFTargets),0,1,0.12,0.1:End Sub
  639. Sub Target20_Hit:vpmTimer.PulseSw 20:MoveTarget20:PlaySound SoundFX("Target1",DOFTargets),0,1,0.10,0.1:End Sub
  640. Sub Target21_Hit:vpmTimer.PulseSw 21:MoveTarget21:PlaySound SoundFX("Target1",DOFTargets),0,1,0.08,0.1:End Sub
  641.  
  642. Sub Target22_Hit:vpmTimer.PulseSw 22:MoveTarget22:PlaySound SoundFX("Target1",DOFTargets),0,1,0.12,0.1:End Sub
  643.  
  644. Sub Target25_Hit:vpmTimer.PulseSw 25:PlaySound SoundFX("Target1",DOFTargets),0,1,0.15,0.1:End Sub
  645. Sub Target26_Hit:vpmTimer.PulseSw 26:PlaySound SoundFX("Target1",DOFTargets),0,1,0.15,0.1:End Sub
  646. Sub Target27_Hit:vpmTimer.PulseSw 27:PlaySound SoundFX("Target1",DOFTargets),0,1,0.15,0.1:End Sub
  647. Sub Target28_Hit:vpmTimer.PulseSw 28:PlaySound SoundFX("Target1",DOFTargets),0,1,0.15,0.1:End Sub
  648. Sub Target29_Hit:vpmTimer.PulseSw 29:PlaySound SoundFX("Target1",DOFTargets),0,1,0.15,0.1:End Sub
  649.  
  650. Sub Target30_Hit:vpmTimer.PulseSw 30:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.1:End Sub
  651. Sub Target31_Hit:vpmTimer.PulseSw 31:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.1:End Sub
  652. Sub Target32_Hit:vpmTimer.PulseSw 32:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.1:End Sub
  653.  
  654.  
  655. ' Bumpers
  656.  
  657. Sub Bumper1_Hit:vpmTimer.PulseSw 39: PlayBumperSound
  658. L12.State = 1
  659. Me.TimerEnabled = 1
  660. End Sub
  661.  
  662. Sub Bumper1_Timer
  663. L12.State = 0
  664. Me.Timerenabled = 0
  665. End Sub
  666.  
  667. Sub Bumper2_Hit:vpmTimer.PulseSw 38:PlayBumperSound
  668. L13.State = 1
  669. Me.TimerEnabled = 1
  670. End Sub
  671.  
  672. Sub Bumper2_Timer
  673. L13.State = 0
  674. Me.Timerenabled = 0
  675. End Sub
  676.  
  677. Sub Bumper3_Hit:vpmTimer.PulseSw 40:PlayBumperSound
  678. L16.State = 1
  679. Me.TimerEnabled = 1
  680. End Sub
  681.  
  682. Sub Bumper3_Timer
  683. L16.State = 0
  684. Me.Timerenabled = 0
  685. End Sub
  686.  
  687. Sub PlayBumperSound()
  688. Select Case Int(Rnd*3)+1
  689. Case 1 : PlaySound SoundFX("LeftBumper",DOFContactors)
  690. Case 2 : PlaySound SoundFX("TopBumper",DOFContactors)
  691. Case 3 : PlaySound SoundFX("RightBumper",DOFContactors)
  692. End Select
  693. End Sub
  694.  
  695. ' Gates
  696.  
  697. Sub Gate1_Hit:PlaySound "Gate5",0,1,0.1,0.1:End Sub
  698. Sub Gate2_Hit:PlaySound "Gate5",0,1,0.1,0.1:End Sub
  699. Sub Gate3_Hit:PlaySound "Gate5",0,1,-0.15,0.1:End Sub
  700. Sub LeftGate_Hit:PlaySound "Gate5",0,1,-0.15,0.1:End Sub
  701.  
  702. '**********Sling Shot Animations
  703. ' Rstep and Lstep are the variables that increment the animation
  704. '****************
  705. Dim RStep, Lstep, uRStep
  706.  
  707. Sub RightSlingShot_Slingshot
  708. vpmTimer.PulseSw 36
  709. PlaySound SoundFX("rSling",DOFContactors), 0,1,0.3,0.1 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  710. RSling.Visible = 0
  711. RSling1.Visible = 1
  712. sling1.rotx = 20
  713. RStep = 0
  714. RightSlingShot.TimerEnabled = 1
  715. ' gi1.State = 0:Gi2.State = 0
  716. End Sub
  717.  
  718. Sub RightSlingShot_Timer
  719. Select Case RStep
  720. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  721. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
  722. End Select
  723. RStep = RStep + 1
  724. End Sub
  725.  
  726. Sub LeftSlingShot_Slingshot
  727. vpmTimer.PulseSw 35
  728. PlaySound SoundFX("lSling",DOFContactors), 0,1,-0.3,0.1 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  729. LSling.Visible = 0
  730. LSling1.Visible = 1
  731. sling2.rotx = 20
  732. LStep = 0
  733. LeftSlingShot.TimerEnabled = 1
  734. ' gi3.State = 0:Gi4.State = 0
  735. End Sub
  736.  
  737. Sub LeftSlingShot_Timer
  738. Select Case LStep
  739. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  740. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0:
  741. End Select
  742. LStep = LStep + 1
  743. End Sub
  744.  
  745. Sub URightSlingShot_Slingshot
  746. vpmTimer.PulseSw 37
  747. PlaySound SoundFX("rSling",DOFContactors), 0,1,0.3,0.1 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  748. URSling.Visible = 0
  749. URSling1.Visible = 1
  750. sling3.rotx = 20
  751. uRStep = 0
  752. URightSlingShot.TimerEnabled = 1
  753. ' gi1.State = 0:Gi2.State = 0
  754. End Sub
  755.  
  756. Sub RightSlingShot_Timer
  757. Select Case uRStep
  758. Case 3:URSLing1.Visible = 0:URSLing2.Visible = 1:sling3.rotx = 10
  759. Case 4:URSLing2.Visible = 0:URSLing.Visible = 1:sling3.rotx = 0:URightSlingShot.TimerEnabled = 0:
  760. End Select
  761. uRStep = uRStep + 1
  762. End Sub
  763.  
  764.  
  765. '--------------------------------
  766. '------ Helper Functions ------
  767. '--------------------------------
  768.  
  769.  
  770. Sub MoveTarget17
  771. P_T17.Transy = 5
  772. Target17.Timerenabled = False
  773. Target17.Timerenabled = True
  774. End Sub
  775. Sub Target17_Timer
  776. Target17.Timerenabled = False
  777. P_T17.Transy = 0
  778. End Sub
  779.  
  780. Sub MoveTarget18
  781. P_T18.Transy = 5
  782. Target18.Timerenabled = False
  783. Target18.Timerenabled = True
  784. End Sub
  785. Sub Target18_Timer
  786. Target18.Timerenabled = False
  787. P_T18.Transy = 0
  788. End Sub
  789.  
  790. Sub MoveTarget19
  791. P_T19.Transy = 5
  792. Target19.Timerenabled = False
  793. Target19.Timerenabled = True
  794. End Sub
  795. Sub Target19_Timer
  796. Target19.Timerenabled = False
  797. P_T19.Transy = 0
  798. End Sub
  799.  
  800. Sub MoveTarget20
  801. P_T20.Transy = 5
  802. Target20.Timerenabled = False
  803. Target20.Timerenabled = True
  804. End Sub
  805. Sub Target20_Timer
  806. Target20.Timerenabled = False
  807. P_T20.Transy = 0
  808. End Sub
  809.  
  810. Sub MoveTarget21
  811. P_T21.Transy = 5
  812. Target21.Timerenabled = False
  813. Target21.Timerenabled = True
  814. End Sub
  815. Sub Target21_Timer
  816. Target21.Timerenabled = False
  817. P_T21.Transy = 0
  818. End Sub
  819.  
  820. Sub MoveTarget22
  821. P_T22.Transy = 5
  822. Target22.Timerenabled = False
  823. Target22.Timerenabled = True
  824. End Sub
  825. Sub Target22_Timer
  826. Target22.Timerenabled = False
  827. P_T22.Transy = 0
  828. End Sub
  829.  
  830. 'additional Lamp Callback
  831. Sub LampTimer_Timer
  832.  
  833. if WatchdogActive and not DTRescue.timerenabled then
  834. 'Move Bank up if all lights are ON
  835. if Controller.Lamp(2)<>0 and (Controller.Lamp(49)<>0 or Controller.Lamp(33)<>0 or Controller.Lamp(17)<>0 or Controller.Lamp(13)<>0) then
  836. if (not BankisUp) and (not TargetBankDownTimer.enabled) then
  837. OnCount = 0
  838. TotalCount = 0
  839. TargetBankDownTimer.enabled = True
  840. end if
  841. end if
  842. 'Move Bank down if all lights are OFF
  843. if Controller.Lamp(2)=0 and Controller.Lamp(49)=0 and Controller.Lamp(33)=0 and Controller.Lamp(17)=0 and Controller.Lamp(13)=0 then
  844. TargetBankUpTimer.enabled = True
  845. end if
  846. if Controller.Lamp(17)<>0 or Controller.Lamp(13)<>0 then
  847. TargetBankUpTimer.enabled = False
  848. end if
  849. end if
  850. End sub
  851.  
  852.  
  853. '***************************************************
  854. ' JP's VP10 Fading Lamps & Flashers
  855. ' Based on PD's Fading Light System
  856. ' SetLamp 0 is Off
  857. ' SetLamp 1 is On
  858. ' fading for non opacity objects is 4 steps
  859. '***************************************************
  860.  
  861. Dim LampState(200), FadingLevel(200)
  862. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  863.  
  864. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  865. LampTimer.Interval = 5 'lamp fading speed
  866. LampTimer.Enabled = 1
  867.  
  868. ' Lamp & Flasher Timers
  869.  
  870. Sub LampTimer_Timer()
  871. Dim chgLamp, num, chg, ii
  872. chgLamp = Controller.ChangedLamps
  873. If Not IsEmpty(chgLamp) Then
  874. For ii = 0 To UBound(chgLamp)
  875. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  876. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  877. Next
  878. End If
  879. UpdateLamps
  880. End Sub
  881.  
  882. Sub UpdateLamps()
  883.  
  884.  
  885. NFadeL 1, l1
  886. NFadeL 2, l2
  887. NFadeL 3, l3
  888. NFadeL 4, l4
  889. NFadeL 5, l5
  890. NFadeL 6, l6
  891. NFadeL 7, L7
  892. NFadeL 8, l8
  893. NFadeL 9, l9
  894. NFadeL 10, l10
  895. NFadeL 11, L11
  896.  
  897. NFadeLm 14, l14 'Flasher
  898. NFadeL 14, l14a 'Flasher
  899. NFadeLm 15, l15 'Flasher
  900. NFadeL 15, l15a 'Flasher
  901.  
  902. NFadeL 17, l17
  903. NFadeL 18, l18
  904. NFadeL 19, l19
  905. NFadeL 20, l20
  906. NFadeL 21, l21
  907. NFadeL 22, l22
  908. NFadeL 23, l23
  909. NFadeL 24, l24
  910. NFadeL 25, l25
  911. NFadeL 26, l26
  912. NFadeL 27, l27
  913. NFadeLm 31, l31
  914. NFadeL 31, l31a 'Flasher
  915. NFadeL 33, l33
  916. NFadeL 34, l34
  917. NFadeL 35, l35
  918. NFadeL 36, l36
  919. NFadeL 37, l37
  920. NFadeL 38, l38
  921. NFadeL 39, l39
  922. NFadeL 40, l40
  923. NFadeL 41, l41
  924. NFadeLm 42, l42
  925. NFadeLm 42, l42a
  926. NFadeL 42, l42b
  927. NFadeL 43, l43
  928. NFadeL 44, l44
  929.  
  930. NFadeLm 46, l46 'Flasher
  931. NFadeL 46, l46a 'Flasher
  932.  
  933. NFadeL 49, l49
  934. NFadeL 50, l50
  935. NFadeL 51, l51
  936. NFadeL 52, l52
  937. NFadeL 53, l53
  938. NFadeL 54, l54
  939. NFadeL 55, l55
  940. NFadeL 56, l56
  941. NFadeL 57, l57
  942. NFadeL 58, l58
  943.  
  944. NFadeLm 59, l59
  945. NFadeLm 59, l59a
  946. NFadeL 59, l59b 'Apron Light
  947.  
  948. NFadeL 60, l60
  949.  
  950. NFadeLm 62, l62 'Flasher
  951. NFadeL 62, l62a 'Flasher
  952.  
  953.  
  954. 'Solenid Controlled Lamps
  955.  
  956.  
  957. End Sub
  958.  
  959. ' div lamp subs
  960.  
  961. Sub InitLamps()
  962. Dim x
  963. For x = 0 to 200
  964. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  965. FadingLevel(x) = 4 ' used to track the fading state
  966. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  967. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  968. FlashMax(x) = 1 ' the maximum value when on, usually 1
  969. FlashMin(x) = 0 ' the minimum value when off, usually 0
  970. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  971. Next
  972. End Sub
  973.  
  974. Sub AllLampsOff
  975. Dim x
  976. For x = 0 to 200
  977. SetLamp x, 0
  978. Next
  979. End Sub
  980.  
  981. Sub SetLamp(nr, value)
  982. If value <> LampState(nr) Then
  983. LampState(nr) = abs(value)
  984. FadingLevel(nr) = abs(value) + 4
  985. End If
  986. End Sub
  987.  
  988. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  989.  
  990. Sub NFadeL(nr, object)
  991. Select Case FadingLevel(nr)
  992. Case 4:object.state = 0:FadingLevel(nr) = 0
  993. Case 5:object.state = 1:FadingLevel(nr) = 1
  994. End Select
  995. End Sub
  996.  
  997. Sub NFadeLm(nr, object) ' used for multiple lights
  998. Select Case FadingLevel(nr)
  999. Case 4:object.state = 0
  1000. Case 5:object.state = 1
  1001. End Select
  1002. End Sub
  1003.  
  1004. 'Lights, Ramps & Primitives used as 4 step fading lights
  1005. 'a,b,c,d are the images used from on to off
  1006.  
  1007. Sub FadeObj(nr, object, a, b, c, d)
  1008. Select Case FadingLevel(nr)
  1009. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  1010. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  1011. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  1012. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  1013. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  1014. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  1015. End Select
  1016. End Sub
  1017.  
  1018. Sub FadeObjm(nr, object, a, b, c, d)
  1019. Select Case FadingLevel(nr)
  1020. Case 4:object.image = b
  1021. Case 5:object.image = a
  1022. Case 9:object.image = c
  1023. Case 13:object.image = d
  1024. End Select
  1025. End Sub
  1026.  
  1027. Sub NFadeObj(nr, object, a, b)
  1028. Select Case FadingLevel(nr)
  1029. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  1030. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  1031. End Select
  1032. End Sub
  1033.  
  1034. Sub NFadeObjm(nr, object, a, b)
  1035. Select Case FadingLevel(nr)
  1036. Case 4:object.image = b
  1037. Case 5:object.image = a
  1038. End Select
  1039. End Sub
  1040.  
  1041. ' Flasher objects
  1042.  
  1043. Sub Flash(nr, object)
  1044. Select Case FadingLevel(nr)
  1045. Case 4 'off
  1046. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  1047. If FlashLevel(nr) < FlashMin(nr) Then
  1048. FlashLevel(nr) = FlashMin(nr)
  1049. FadingLevel(nr) = 0 'completely off
  1050. End if
  1051. Object.IntensityScale = FlashLevel(nr)
  1052. Case 5 ' on
  1053. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  1054. If FlashLevel(nr) > FlashMax(nr) Then
  1055. FlashLevel(nr) = FlashMax(nr)
  1056. FadingLevel(nr) = 1 'completely on
  1057. End if
  1058. Object.IntensityScale = FlashLevel(nr)
  1059. End Select
  1060. End Sub
  1061.  
  1062. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  1063. Object.IntensityScale = FlashLevel(nr)
  1064. End Sub
  1065.  
  1066.  
  1067. '-------------------------------
  1068. '------ DIP Switch Menu ------
  1069. '-------------------------------
  1070.  
  1071. Sub editDips
  1072. Dim vpmDips:Set vpmDips=New cvpmDips
  1073. With vpmDips
  1074. .AddForm 200,250,"U-Boat 65 DIP switches"
  1075. .AddFrame 5, 0,170,"Balls per game",&HC0000000,Array("2 balls",&HC0000000,"3 balls",0,"4 balls",&H80000000,"5 balls",&H40000000) '31+32
  1076. .AddFrame 5,80,170,"Max. credits",&H03000000,Array("10",0,"15",&H01000000,"25",&H02000000,"40",&H03000000) '25+26
  1077. .AddChk 5,160,170,Array("Match feature",&H08000000) '28
  1078. .AddChk 5,180,170,Array("Autopercentage",&H20000000) '30
  1079. .AddChk 5,200,170,Array("Only one Special per game",&H10000000) '29
  1080.  
  1081. .AddFrame 210,0,170,"Extra Ball lights",&H04000000,Array("Alternating",0,"Always on",&H04000000) '27
  1082. .AddChk 210,55,170,Array("Memory Multiplicator",32768) '8
  1083. .AddChk 210,75,170,Array("Memory Bonus Ramp",&H00000040) '7
  1084. .AddChk 210,95,170,Array("Memory Outhole Bonus",&H00000020) '6
  1085. .AddChk 210,115,170,Array("Memory 250/500K Mines",&H00004000) '15
  1086. .AddChk 210,135,170,Array("Memory Mines",&H00002000) '14
  1087. .AddChk 210,155,170,Array("Memory A-B-C",&H00800000) '24
  1088. .AddChk 210,175,170,Array("Memory Target Bank",&H00200000) '22
  1089. .AddChk 210,195,170,Array("Memory Ships",&H00100000) '21
  1090.  
  1091. .AddLabel 0,230,280,20,"After hitting OK, press F3 to reset game with new settings."
  1092. .ViewDips
  1093. End With
  1094. End Sub
  1095. Set vpmShowDips=GetRef("editDips")
  1096.  
  1097. '*************
  1098. ' JP'S LUT
  1099. '*************
  1100.  
  1101. Dim bLutActive, LUTImage
  1102. Sub LoadLUT
  1103. Dim x
  1104. x = LoadValue(cGameName, "LUTImage")
  1105. If(x <> "") Then LUTImage = x Else LUTImage = 0
  1106. UpdateLUT
  1107. End Sub
  1108.  
  1109. Sub SaveLUT
  1110. SaveValue cGameName, "LUTImage", LUTImage
  1111. End Sub
  1112.  
  1113. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  1114.  
  1115. Sub UpdateLUT
  1116. Select Case LutImage
  1117. Case 0: table1.ColorGradeImage = "LUT0"
  1118. Case 1: table1.ColorGradeImage = "LUT1"
  1119. Case 2: table1.ColorGradeImage = "LUT2"
  1120. Case 3: table1.ColorGradeImage = "LUT3"
  1121. Case 4: table1.ColorGradeImage = "LUT4"
  1122. Case 5: table1.ColorGradeImage = "LUT5"
  1123. Case 6: table1.ColorGradeImage = "LUT6"
  1124. Case 7: table1.ColorGradeImage = "LUT7"
  1125. Case 8: table1.ColorGradeImage = "LUT8"
  1126. Case 9: table1.ColorGradeImage = "LUT9"
  1127.  
  1128. End Select
  1129. End Sub
  1130.  
  1131.  
  1132. '*********************************************************************
  1133. ' Positional Sound Playback Functions
  1134. '*********************************************************************
  1135.  
  1136. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  1137. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  1138. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  1139. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  1140. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  1141. End Sub
  1142.  
  1143. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  1144. Sub PlaySoundAt(soundname, tableobj)
  1145. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  1146. End Sub
  1147.  
  1148. Sub PlaySoundAtBall(soundname)
  1149. PlaySoundAt soundname, ActiveBall
  1150. End Sub
  1151.  
  1152.  
  1153. '*********************************************************************
  1154. ' Supporting Ball & Sound Functions
  1155. '*********************************************************************
  1156.  
  1157. Function AudioFade(tableobj) ' Fades between front and back of the table (for surround systems or 2x2 speakers, etc), depending on the Y position on the table. "table1" is the name of the table
  1158. Dim tmp
  1159. tmp = tableobj.y * 2 / table1.height-1
  1160. If tmp > 0 Then
  1161. AudioFade = Csng(tmp ^10)
  1162. Else
  1163. AudioFade = Csng(-((- tmp) ^10) )
  1164. End If
  1165. End Function
  1166.  
  1167. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  1168. Dim tmp
  1169. tmp = tableobj.x * 2 / table1.width-1
  1170. If tmp > 0 Then
  1171. AudioPan = Csng(tmp ^10)
  1172. Else
  1173. AudioPan = Csng(-((- tmp) ^10) )
  1174. End If
  1175. End Function
  1176.  
  1177. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  1178. Vol = Csng(BallVel(ball) ^2 / 2000)
  1179. End Function
  1180.  
  1181. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  1182. Pitch = BallVel(ball) * 20
  1183. End Function
  1184.  
  1185. Function BallVel(ball) 'Calculates the ball speed
  1186. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  1187. End Function
  1188.  
  1189.  
  1190. '********************************************************************
  1191. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  1192. '********************************************************************
  1193.  
  1194. Const tnob = 5 ' total number of balls
  1195. ReDim rolling(tnob)
  1196. InitRolling
  1197.  
  1198. Sub InitRolling
  1199. Dim i
  1200. For i = 0 to tnob
  1201. rolling(i) = False
  1202. Next
  1203. End Sub
  1204.  
  1205. Sub RollingTimer_Timer()
  1206. Dim BOT, b
  1207. BOT = GetBalls
  1208.  
  1209. ' stop the sound of deleted balls
  1210. For b = UBound(BOT) + 1 to tnob
  1211. rolling(b) = False
  1212. StopSound "fx_ballrolling" & b
  1213. StopSound "fx_plasticrolling" & b
  1214. StopSound "fx_metalrolling" & b
  1215. Next
  1216.  
  1217. ' exit the sub if no balls on the table
  1218. If UBound(BOT) = -1 Then Exit Sub
  1219.  
  1220. ' play the rolling sound for each ball
  1221. For b = 0 to UBound(BOT)
  1222. If BallVel(BOT(b) ) > 1 Then
  1223. rolling(b) = True
  1224. If BOT(b).Z > 30 Then
  1225. ' ball on plastic ramp
  1226. StopSound "fx_ballrolling" & b
  1227. StopSound "fx_metalrolling" & b
  1228. PlaySound "fx_plasticrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  1229. Else
  1230. ' ball on playfield
  1231. StopSound "fx_plasticrolling" & b
  1232. StopSound "fx_metalrolling" & b
  1233. PlaySound "fx_ballrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  1234. End If
  1235. Else
  1236. If rolling(b) Then
  1237. StopSound "fx_ballrolling" & b
  1238. StopSound "fx_plasticrolling" & b
  1239. StopSound "fx_metalrolling" & b
  1240. rolling(b) = False
  1241. End If
  1242. End If
  1243.  
  1244. ' ball drop sounds matching the adjusted height params but not the way down the ramps
  1245. If BOT(b).VelZ < -1 And BOT(b).Z < 55 And BOT(b).Z > 27 then 'And Not InRect(BOT(b).X, BOT(b).Y, 610,320, 740,320, 740,550, 610,550) And Not InRect(BOT(b).X, BOT(b).Y, 180,400, 230,400, 230, 550, 180,550) Then
  1246. PlaySound "fx_ball_drop" & Int(Rnd()*3), 0, ABS(BOT(b).VelZ)/17*5, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  1247. End If
  1248.  
  1249. Next
  1250. End Sub
  1251. '**********************
  1252. ' Ball Collision Sound
  1253. '**********************
  1254.  
  1255. Sub OnBallBallCollision(ball1, ball2, velocity)
  1256. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  1257. End Sub
  1258.  
  1259.  
  1260. '*****************************************
  1261. ' ninuzzu's FLIPPER SHADOWS
  1262. '*****************************************
  1263.  
  1264. sub FlipperTimer_Timer()
  1265. pleftFlipper.objrotz=leftFlipper.CurrentAngle
  1266. prightFlipper.objrotz=rightFlipper.CurrentAngle
  1267. FlipperLSh.RotZ = LeftFlipper.currentangle
  1268. FlipperRSh.RotZ = RightFlipper.currentangle
  1269.  
  1270. End Sub
  1271.  
  1272. '*****************************************
  1273. ' ninuzzu's BALL SHADOW
  1274. '*****************************************
  1275. Dim BallShadow
  1276. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  1277.  
  1278. Sub BallShadowUpdate_timer()
  1279. Dim BOT, b
  1280. BOT = GetBalls
  1281. ' hide shadow of deleted balls
  1282. If UBound(BOT)<(tnob-1) Then
  1283. For b = (UBound(BOT) + 1) to (tnob-1)
  1284. BallShadow(b).visible = 0
  1285. Next
  1286. End If
  1287. ' exit the Sub if no balls on the table
  1288. If UBound(BOT) = -1 Then Exit Sub
  1289. ' render the shadow for each ball
  1290. For b = 0 to UBound(BOT)
  1291. If BOT(b).X < Table1.Width/2 Then
  1292. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  1293. Else
  1294. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  1295. End If
  1296. ballShadow(b).Y = BOT(b).Y + 12
  1297. If BOT(b).Z > 20 Then
  1298. BallShadow(b).visible = 1
  1299. Else
  1300. BallShadow(b).visible = 0
  1301. End If
  1302. Next
  1303. End Sub
  1304.  
  1305. '************************************
  1306. ' What you need to add to your table
  1307. '************************************
  1308.  
  1309. ' a timer called RollingTimer. With a fast interval, like 10
  1310. ' one collision sound, in this script is called fx_collide
  1311. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  1312. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  1313.  
  1314.  
  1315. '******************************************
  1316. ' Explanation of the rolling sound routine
  1317. '******************************************
  1318.  
  1319. ' sounds are played based on the ball speed and position
  1320.  
  1321. ' the routine checks first for deleted balls and stops the rolling sound.
  1322.  
  1323. ' The For loop goes through all the balls on the table and checks for the ball speed and
  1324. ' if the ball is on the table (height lower than 30) then then it plays the sound
  1325. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  1326.  
  1327. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  1328. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  1329. ' according to the position of the ball on the table.
  1330.  
  1331.  
  1332. '**************************************
  1333. ' Explanation of the collision routine
  1334. '**************************************
  1335.  
  1336. ' The collision is built in VP.
  1337. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  1338. ' will call this routine. What you add in the sub is up to you. As an example is a simple Playsound with volume and paning
  1339. ' depending of the speed of the collision.
  1340.  
  1341.  
  1342. Sub Pins_Hit (idx)
  1343. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  1344. End Sub
  1345.  
  1346. Sub Targets_Hit (idx)
  1347. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  1348. End Sub
  1349.  
  1350. Sub Metals_Thin_Hit (idx)
  1351. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1352. End Sub
  1353.  
  1354. Sub Metals_Medium_Hit (idx)
  1355. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1356. End Sub
  1357.  
  1358. Sub Metals2_Hit (idx)
  1359. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1360. End Sub
  1361.  
  1362. Sub Gates_Hit (idx)
  1363. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1364. End Sub
  1365.  
  1366. Sub Spinner_Spin
  1367. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  1368. End Sub
  1369.  
  1370. Sub Rubbers_Hit(idx)
  1371. dim finalspeed
  1372. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1373. If finalspeed > 20 then
  1374. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1375. End if
  1376. If finalspeed >= 6 AND finalspeed <= 20 then
  1377. RandomSoundRubber()
  1378. End If
  1379. End Sub
  1380.  
  1381. Sub Posts_Hit(idx)
  1382. dim finalspeed
  1383. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  1384. If finalspeed > 16 then
  1385. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1386. End if
  1387. If finalspeed >= 6 AND finalspeed <= 16 then
  1388. RandomSoundRubber()
  1389. End If
  1390. End Sub
  1391.  
  1392. Sub RandomSoundRubber()
  1393. Select Case Int(Rnd*3)+1
  1394. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1395. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1396. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1397. End Select
  1398. End Sub
  1399.  
  1400. Sub LeftFlipper_Collide(parm)
  1401. RandomSoundFlipper()
  1402. End Sub
  1403.  
  1404. Sub RightFlipper_Collide(parm)
  1405. RandomSoundFlipper()
  1406. End Sub
  1407.  
  1408. Sub RandomSoundFlipper()
  1409. Select Case Int(Rnd*3)+1
  1410. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1411. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1412. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  1413. End Select
  1414. End Sub
  1415.  
  1416. Sub Table1_Exit()
  1417. If B2SOn Then
  1418. Controller.Pause = False
  1419. Controller.Stop
  1420. End If
  1421. End Sub
  1422.  
Add Comment
Please, Sign In to add comment