Arngrim

smbmw

Jul 2nd, 2017
407
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.01 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.  
  10. Const cGameName="smbmush",UseSolenoids=1,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  11.  
  12. Const swStartButton=4 'Remap Start Button
  13.  
  14. LoadVPM "01210000","gts3.vbs",3.1
  15. Dim DesktopMode: DesktopMode = Table1.ShowDT
  16.  
  17. If DesktopMode = True Then 'Show Desktop components
  18. Ramp16.visible=1
  19. Ramp15.visible=1
  20. Primitive13.visible=1
  21. Primitive22.Visible = 0
  22. Else
  23. Ramp16.visible=0
  24. Ramp15.visible=0
  25. Primitive13.visible=0
  26. Primitive22.Visible = 1
  27. End if
  28.  
  29. '*************************************************************
  30. 'Solenoid Call backs
  31. '**********************************************************************************************************
  32.  
  33. SolCallback(5)= "SolTop"
  34. SolCallback(6)= "bsBL.SolOut"
  35. SolCallback(7)= "bsBR.SolOut"
  36. SolCallback(8)= "RampPost.IsDropped="
  37. SolCallback(9)= "dtL.SolDropUp"
  38. SolCallback(10)= "dtR.SolDropUp"
  39. SolCallback(11)= "dtL.SolHit 1,"
  40. SolCallback(12)= "dtL.SolHit 2,"
  41. SolCallback(13)= "dtL.SolHit 3,"
  42. SolCallback(14)= "dtL.SolHit 4,"
  43. SolCallback(15)= "dtL.SolHit 5,"
  44. SolCallback(16)= "dtR.SolHit 1,"
  45. SolCallback(17)= "dtR.SolHit 2,"
  46. SolCallback(18)= "dtR.SolHit 3,"
  47. SolCallback(19)= "dtR.SolHit 4,"
  48. SolCallback(20)= "dtR.SolHit 5,"
  49. SolCallback(21)= "SetLamp 150," 'BackWall Dome Flasher
  50. SolCallback(22)= "SetLamp 160," 'BackWall Dome Flasher
  51. SolCallback(23)= "SetLamp 170," 'BackWall Dome Flasher
  52. SolCallback(26)= "SetLamp 180," 'BackGlass GI used to control backwall LEDs
  53. '27 Ticket/Coin Meter Enable
  54. SolCallback(28)= "bsTrough.SolOut"
  55. SolCallback(29)= "bsTrough.SolIn"
  56. SolCallback(30)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  57. SolCallback(32)= "vpmNudge.SolGameOn"
  58.  
  59. SolCallback(sLRFlipper) = "SolRFlipper"
  60. SolCallback(sLLFlipper) = "SolLFlipper"
  61.  
  62. Sub SolLFlipper(Enabled)
  63. If Enabled Then
  64. PlaySound SoundFX("fx_Flipperup",DOFFlippers):LeftFlipper.RotateToEnd
  65. Else
  66. PlaySound SoundFX("fx_Flipperdown",DOFFlippers):LeftFlipper.RotateToStart
  67. End If
  68. End Sub
  69.  
  70. Sub SolRFlipper(Enabled)
  71. If Enabled Then
  72. PlaySound SoundFX("fx_Flipperup",DOFFlippers):RightFlipper.RotateToEnd
  73. Else
  74. PlaySound SoundFX("fx_Flipperdown",DOFFlippers):RightFlipper.RotateToStart
  75. End If
  76. End Sub
  77. '**********************************************************************************************************
  78.  
  79. 'Solenoid Controlled toys
  80. '**********************************************************************************************************
  81.  
  82. Sub SolTop(Enabled)
  83. If Enabled Then
  84. If bsTop.Balls Then
  85. sw24.DestroyBall
  86. bsTop.ExitSol_On
  87. End If
  88. End If
  89. End Sub
  90.  
  91. Sub FlipperTimer_Timer
  92. LFLogo.roty = LeftFlipper.currentangle + 0
  93. RFlogo.roty = RightFlipper.currentangle + 0
  94. End Sub
  95.  
  96. '**********************************************************************************************************
  97.  
  98. 'Initiate Table
  99. '**********************************************************************************************************
  100.  
  101. Dim bsTrough, dtL, dtR, bsTop, bsBL, bsBR
  102.  
  103. Sub Table1_Init
  104. vpmInit Me
  105. On Error Resume Next
  106. With Controller
  107. .GameName = cGameName
  108. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  109. .SplashInfoLine = "Super Mario Mushroom World Gottlieb"&chr(13)&"You Suck"
  110. .HandleMechanics=0
  111. .HandleKeyboard=0
  112. .ShowDMDOnly=1
  113. .ShowFrame=0
  114. .ShowTitle=0
  115. .hidden = 0
  116. On Error Resume Next
  117. .Run GetPlayerHWnd
  118. If Err Then MsgBox Err.Description
  119. On Error Goto 0
  120. End With
  121. On Error Goto 0
  122.  
  123. PinMAMETimer.Interval=PinMAMEInterval
  124. PinMAMETimer.Enabled=1
  125.  
  126. vpmNudge.TiltSwitch=151
  127. vpmNudge.Sensitivity=3
  128. vpmNudge.TiltObj=Array(Bumper1,Bumper2,Bumper3,LeftSlingshot)
  129.  
  130. Set bsTrough=New cvpmBallStack
  131. bsTrough.InitSw 33,0,23,0,0,0,0,0
  132. bsTrough.InitKick BallRelease,180,3
  133. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  134. bsTrough.Balls=1
  135. bsTrough.AddBall 0
  136.  
  137. Set bsTop=New cvpmBallStack
  138. bsTop.InitSw 0,24,0,0,0,0,0,0
  139. bsTop.InitKick sw24a,117,3
  140. bsTop.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  141.  
  142. Set bsBL=New cvpmBallStack
  143. bsBL.InitSw 0,14,0,0,0,0,0,0
  144. bsBL.InitKick sw14,115,15
  145. bsBL.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  146.  
  147. Set bsBR=New cvpmBallStack
  148. bsBR.InitSw 0,34,0,0,0,0,0,0
  149. bsBR.InitKick sw34,255,15
  150. bsBR.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  151.  
  152. Set dtL=New cvpmDropTarget
  153. dtL.InitDrop Array(sw20,sw5,sw15,sw25,sw35),Array (20,5,15,25,35)
  154. dtL.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  155. dtL.CreateEvents "dtL"
  156.  
  157. Set dtR=New cvpmDropTarget
  158. dtR.InitDrop Array(sw36,sw26,sw6,sw16,sw30),Array (36,26,6,16,30)
  159. dtR.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  160. dtR.CreateEvents "dtR"
  161.  
  162. End Sub
  163.  
  164. '**********************************************************************************************************
  165. 'Plunger code
  166. '**********************************************************************************************************
  167.  
  168. Sub Table1_KeyDown(ByVal KeyCode)
  169. If KeyDownHandler(keycode) Then Exit Sub
  170. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  171. If KeyCode=LeftFlipperKey Then Controller.Switch(81)=1
  172. If KeyCode=RightFlipperKey Then Controller.Switch(82)=1
  173. End Sub
  174.  
  175. Sub Table1_KeyUp(ByVal KeyCode)
  176. If KeyUpHandler(keycode) Then Exit Sub
  177. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  178. If KeyCode=LeftFlipperKey Then Controller.Switch(81)=0
  179. If KeyCode=RightFlipperKey Then Controller.Switch(82)=0
  180. End Sub
  181.  
  182. '**********************************************************************************************************
  183. ' Drain hole and kickers
  184. Sub Drain_Hit:bsTrough.addball me : playsound"drain" : End Sub
  185. Sub sw14_Hit:bsBL.AddBall Me : playsound "popper_ball": End Sub
  186. Sub sw24_Hit:bsTop.AddBall 0 : playsound "popper_ball": End Sub
  187. Sub sw34_Hit:bsBR.AddBall Me : playsound "popper_ball": End Sub
  188.  
  189. Sub sw80_Hit:Me.DestroyBall:vpmTimer.PulseSwitch 80,200,"HandleLeft" : playsound "popper_ball": End Sub
  190. Sub HandleLeft(swNo):bsBL.AddBall 0:End Sub
  191.  
  192. Sub sw90_Hit:Me.DestroyBall:vpmTimer.PulseSwitch 90,200,"HandleRight" : playsound "popper_ball": End Sub
  193. Sub HandleRight(swNo):bsBR.AddBall 0:End Sub
  194.  
  195. 'Drop Targets
  196. Sub Sw20_Dropped:dtL.Hit 1 :End Sub
  197. Sub Sw5_Dropped: dtL.Hit 2 :End Sub
  198. Sub Sw15_Dropped:dtL.Hit 3 :End Sub
  199. Sub Sw25_Dropped:dtL.Hit 4 :End Sub
  200. Sub Sw35_Dropped:dtL.Hit 5 :End Sub
  201.  
  202. 'Drop Targets
  203. Sub Sw36_Dropped:dtR.Hit 1 :End Sub
  204. Sub Sw26_Dropped:dtR.Hit 2 :End Sub
  205. Sub Sw16_Dropped:dtR.Hit 3 :End Sub
  206. Sub Sw6_Dropped: dtR.Hit 4 :End Sub
  207. Sub Sw30_Dropped:dtR.Hit 5 :End Sub
  208.  
  209. 'Bumpers
  210. Sub Bumper1_Hit : vpmTimer.PulseSw(10) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  211. Sub Bumper2_Hit : vpmTimer.PulseSw(11) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  212. Sub Bumper3_Hit : vpmTimer.PulseSw(12) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  213.  
  214. 'Wire Triggers
  215. Sub SW22_Hit:Controller.Switch(22)=1 : playsound"rollover" : End Sub
  216. Sub SW22_unHit:Controller.Switch(22)=0:End Sub
  217.  
  218. 'Gate Triggers
  219. Sub sw0_hit:vpmTimer.pulseSw 0 : End Sub
  220.  
  221. 'Stand Up Target
  222. Sub sw32_hit:vpmTimer.pulseSw 32:DOF 106, DOFPulse:End Sub
  223.  
  224. 'Generic Soudns
  225. Sub Trigger1_Hit: playsound"fx_ballrampdrop" : End Sub
  226. Sub Trigger2_Hit: playsound"fx_ballrampdrop" : End Sub
  227.  
  228. '***************************************************
  229. ' JP's VP10 Fading Lamps & Flashers
  230. ' Based on PD's Fading Light System
  231. ' SetLamp 0 is Off
  232. ' SetLamp 1 is On
  233. ' fading for non opacity objects is 4 steps
  234. '***************************************************
  235.  
  236. Dim LampState(200), FadingLevel(200)
  237. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  238.  
  239. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  240. LampTimer.Interval = 5 'lamp fading speed
  241. LampTimer.Enabled = 1
  242.  
  243. ' Lamp & Flasher Timers
  244.  
  245. Sub LampTimer_Timer()
  246. Dim chgLamp, num, chg, ii
  247. chgLamp = Controller.ChangedLamps
  248. If Not IsEmpty(chgLamp) Then
  249. For ii = 0 To UBound(chgLamp)
  250. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  251. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  252. Next
  253. End If
  254. UpdateLamps
  255. End Sub
  256.  
  257.  
  258. Sub UpdateLamps
  259. NFadeObjm 1, l1, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  260. Flash 1, F1a 'Apron LED
  261. NFadeObjm 2, l2, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  262. Flash 2, F2a 'Apron LED
  263. NFadeObjm 3, l3, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  264. Flash 3, F3 'Apron LED
  265. NFadeObjm 4, l4, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  266. Flash 4, F4 'Apron LED
  267. NFadeObjm 5, l5, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  268. Flash 5, F5 'Apron LED
  269. NFadeObjm 6, l6, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  270. Flash 6, F6 'Apron LED
  271. NFadeObjm 7, l7, "bulbcover1_greenOn", "bulbcover1_green" 'Apron LED
  272. Flash 7, F7 'Apron LED
  273.  
  274. NFadeLm 10, l10 'GI
  275. NFadeL 10, l10a 'GI
  276. NFadeLm 11, l11 'GI
  277. NFadeL 11, l11a 'GI
  278.  
  279. NFadeObjm 14, l14, "bulbcover1_redOn", "bulbcover1_red"
  280. Flash 14, F14 'Mushroom Arch entrance
  281. NFadeObjm 15, l15, "bulbcover1_redOn", "bulbcover1_red"
  282. Flash 15, F15 'Mushroom Arch entrance
  283. NFadeObjm 16, l16, "bulbcover1_redOn", "bulbcover1_red"
  284. Flash 16, F16 'Mushroom Arch entrance
  285. NFadeObjm 17, l17, "bulbcover1_redOn", "bulbcover1_red"
  286. Flash 17, F17 'Mushroom Arch entrance
  287.  
  288. NFadeL 20, l20 'Bumper 1
  289. NFadeL 21, l21 'Bumper 2
  290. NFadeL 22, l22 'Bumper 3
  291.  
  292. NFadeL 23, l23
  293.  
  294. NFadeObjm 24, l24, "bulbcover1_redOn", "bulbcover1_red"
  295. Flash 24, F24 'Mario L model LED
  296. NFadeObjm 25, l25, "bulbcover1_redOn", "bulbcover1_red"
  297. Flash 25, F25 'Mario L model LED
  298. NFadeObjm 26, l26, "bulbcover1_redOn", "bulbcover1_red"
  299. Flash 26, F26 'Mario L model LED
  300. NFadeObjm 27, l27, "bulbcover1_redOn", "bulbcover1_red"
  301. Flash 27, F27 'Mario L model LED
  302.  
  303. NFadeL 33, l33
  304. NFadeL 34, l34
  305. NFadeL 35, l35
  306. NFadeL 36, l36
  307. NFadeL 37, l37
  308.  
  309. NFadeL 43, l43
  310. NFadeL 44, l44
  311. NFadeL 45, l45
  312. NFadeL 46, l46
  313. NFadeL 47, l47
  314.  
  315. NFadeL 53, l53
  316. NFadeL 54, l54
  317. NFadeL 55, l55
  318. NFadeL 56, l56
  319. NFadeL 57, l57
  320.  
  321. INFadeLm 120, L120a 'Left Sling GI
  322. INFadeL 120, L120b 'Left Sling GI
  323. NFadeLm 121, F121 'Left Orange Dome
  324. NFadeL 121, F121a 'Left Orange Dome
  325. INFadeLm 122, L122a 'Left ramp GI
  326. INFadeLm 122, L122b 'Left ramp GI
  327. INFadeL 122, L122c 'Left ramp GI
  328. INFadeLm 123, L123a 'Left Drop Target GI
  329. INFadeL 123, L123b 'Left Drop Target GI
  330. INFadeLm 124, l124a
  331. INFadeLm 124, l124b
  332. INFadeL 124, l124c
  333. INFadeLm 125, l125a
  334. INFadeLm 125, l125b
  335. INFadeL 125, l125c
  336. NFadeLm 126, F126 'Right Orange Dome
  337. NFadeLm 126, F126a 'Right Orange Dome
  338. INFadeLm 127, l127a 'Right Slling GI
  339. INFadeLm 127, l127b 'Right Slling GI
  340. INFadeL 127, l127c 'Right Slling GI
  341.  
  342.  
  343. 'Solenoid Controlled Flashers
  344. NFadeObjm 150, L221, "dome2_0_orangeON", "dome2_0_orange"
  345. Flash 150, F221
  346. NFadeObjm 160, L222, "dome2_0_redON", "dome2_0_red"
  347. Flash 160, F222
  348. NFadeObjm 170, L223, "dome2_0_orangeON", "dome2_0_orange"
  349. Flash 170, F223
  350.  
  351. 'BackWall LEDs
  352. NFadeObjm 180, LED1, "bulbcover1_orange", "bulbcover1_orangeOn"
  353. IFlashm 180, F180a
  354. NFadeObjm 180, LED2, "bulbcover1_red", "bulbcover1_redOn"
  355. IFlashm 180, F180b
  356. NFadeObjm 180, LED3, "bulbcover1_blue", "bulbcover1_blueOn"
  357. IFlashm 180, F180c
  358. NFadeObjm 180, LED4, "bulbcover1_red", "bulbcover1_redOn"
  359. IFlashm 180, F180d
  360. NFadeObjm 180, LED5, "bulbcover1_orange", "bulbcover1_orangeOn"
  361. IFlashm 180, F180e
  362. NFadeObjm 180, LED6, "bulbcover1_orange", "bulbcover1_orangeOn"
  363. IFlashm 180, F180f
  364. NFadeObjm 180, LED7, "bulbcover1_red", "bulbcover1_redOn"
  365. IFlashm 180, F180g
  366. NFadeObjm 180, LED8, "bulbcover1_blue", "bulbcover1_blueOn"
  367. IFlashm 180, F180h
  368. NFadeObjm 180, LED9, "bulbcover1_red", "bulbcover1_redOn"
  369. IFlashm 180, F180i
  370. NFadeObjm 180, LED10, "bulbcover1_orange", "bulbcover1_orangeOn"
  371. IFlash 180, F180j
  372.  
  373. End Sub
  374.  
  375.  
  376. ' div lamp subs
  377.  
  378. Sub InitLamps()
  379. Dim x
  380. For x = 0 to 200
  381. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  382. FadingLevel(x) = 4 ' used to track the fading state
  383. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  384. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  385. FlashMax(x) = 1 ' the maximum value when on, usually 1
  386. FlashMin(x) = 0 ' the minimum value when off, usually 0
  387. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  388. Next
  389. End Sub
  390.  
  391. Sub AllLampsOff
  392. Dim x
  393. For x = 0 to 200
  394. SetLamp x, 0
  395. Next
  396. End Sub
  397.  
  398. Sub SetLamp(nr, value)
  399. If value <> LampState(nr) Then
  400. LampState(nr) = abs(value)
  401. FadingLevel(nr) = abs(value) + 4
  402. End If
  403. End Sub
  404.  
  405. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  406.  
  407. Sub NFadeL(nr, object)
  408. Select Case FadingLevel(nr)
  409. Case 4:object.state = 0:FadingLevel(nr) = 0
  410. Case 5:object.state = 1:FadingLevel(nr) = 1
  411. End Select
  412. End Sub
  413.  
  414. Sub NFadeLm(nr, object) ' used for multiple lights
  415. Select Case FadingLevel(nr)
  416. Case 4:object.state = 0
  417. Case 5:object.state = 1
  418. End Select
  419. End Sub
  420.  
  421. Sub NFadeObj(nr, object, a, b)
  422. Select Case FadingLevel(nr)
  423. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  424. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  425. End Select
  426. End Sub
  427.  
  428. Sub NFadeObjm(nr, object, a, b)
  429. Select Case FadingLevel(nr)
  430. Case 4:object.image = b
  431. Case 5:object.image = a
  432. End Select
  433. End Sub
  434.  
  435. ' Flasher objects
  436.  
  437. Sub Flash(nr, object)
  438. Select Case FadingLevel(nr)
  439. Case 4 'off
  440. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  441. If FlashLevel(nr) < FlashMin(nr) Then
  442. FlashLevel(nr) = FlashMin(nr)
  443. FadingLevel(nr) = 0 'completely off
  444. End if
  445. Object.IntensityScale = FlashLevel(nr)
  446. Case 5 ' on
  447. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  448. If FlashLevel(nr) > FlashMax(nr) Then
  449. FlashLevel(nr) = FlashMax(nr)
  450. FadingLevel(nr) = 1 'completely on
  451. End if
  452. Object.IntensityScale = FlashLevel(nr)
  453. End Select
  454. End Sub
  455.  
  456. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  457. Object.IntensityScale = FlashLevel(nr)
  458. End Sub
  459.  
  460. 'Inverted Lights always on but light turns them off
  461.  
  462. Sub INFadeL(nr, object)
  463. Select Case FadingLevel(nr)
  464. Case 4:object.state = 1:FadingLevel(nr) = 1
  465. Case 5:object.state = 0:FadingLevel(nr) = 0
  466. End Select
  467. End Sub
  468.  
  469. Sub INFadeLm(nr, object) ' used for multiple lights
  470. Select Case FadingLevel(nr)
  471. Case 4:object.state = 1
  472. Case 5:object.state = 0
  473. End Select
  474. End Sub
  475.  
  476. Sub IFlash(nr, object)
  477. Select Case FadingLevel(nr)
  478. Case 4 'on
  479. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  480. If FlashLevel(nr) > FlashMax(nr) Then
  481. FlashLevel(nr) = FlashMax(nr)
  482. FadingLevel(nr) = 1 'completely on
  483. End if
  484. Object.IntensityScale = FlashLevel(nr)
  485. Case 5 ' off
  486. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  487. If FlashLevel(nr) < FlashMin(nr) Then
  488. FlashLevel(nr) = FlashMin(nr)
  489. FadingLevel(nr) = 0 'completely off
  490. End if
  491. Object.IntensityScale = FlashLevel(nr)
  492. End Select
  493. End Sub
  494.  
  495. Sub IFlashm(nr, object) 'multiple flashers, it just sets the flashlevel
  496. Object.IntensityScale = FlashLevel(nr)
  497. End Sub
  498.  
  499. '**********************************************************************************************************
  500. '**********************************************************************************************************
  501. ' Start of VPX functions
  502. '**********************************************************************************************************
  503. '**********************************************************************************************************
  504.  
  505. '**********Sling Shot Animations
  506. ' Rstep and Lstep are the variables that increment the animation
  507. '****************
  508. Dim RStep, Lstep
  509.  
  510. Sub RightSlingShot_Slingshot
  511. vpmTimer.PulseSw 13
  512. DOF 102, DOFPulse
  513. PlaySound SoundFX("right_slingshot",DOFContactors), 0, 1, 0.05, 0.05
  514. RSling.Visible = 0
  515. RSling1.Visible = 1
  516. sling1.TransZ = -20
  517. RStep = 0
  518. RightSlingShot.TimerEnabled = 1
  519. End Sub
  520.  
  521. Sub RightSlingShot_Timer
  522. Select Case RStep
  523. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.TransZ = -10
  524. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.TransZ = 0:RightSlingShot.TimerEnabled = 0:
  525. End Select
  526. RStep = RStep + 1
  527. End Sub
  528.  
  529. Sub LeftSlingShot_Slingshot
  530. vpmTimer.PulseSw 13
  531. DOF 101, DOFPulse
  532. PlaySound SoundFX("left_slingshot",DOFContactors),0,1,-0.05,0.05
  533. LSling.Visible = 0
  534. LSling1.Visible = 1
  535. sling2.TransZ = -20
  536. LStep = 0
  537. LeftSlingShot.TimerEnabled = 1
  538. End Sub
  539.  
  540. Sub LeftSlingShot_Timer
  541. Select Case LStep
  542. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.TransZ = -10
  543. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.TransZ = 0:LeftSlingShot.TimerEnabled = 0:
  544. End Select
  545. LStep = LStep + 1
  546. End Sub
  547.  
  548.  
  549. ' *********************************************************************
  550. ' Supporting Ball & Sound Functions
  551. ' *********************************************************************
  552.  
  553. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  554. Vol = Csng(BallVel(ball) ^2 / 2000)
  555. End Function
  556.  
  557. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  558. Dim tmp
  559. tmp = ball.x * 2 / table1.width-1
  560. If tmp > 0 Then
  561. Pan = Csng(tmp ^10)
  562. Else
  563. Pan = Csng(-((- tmp) ^10) )
  564. End If
  565. End Function
  566.  
  567. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  568. Pitch = BallVel(ball) * 20
  569. End Function
  570.  
  571. Function BallVel(ball) 'Calculates the ball speed
  572. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  573. End Function
  574.  
  575. '*****************************************
  576. ' JP's VP10 Rolling Sounds
  577. '*****************************************
  578.  
  579. Const tnob = 5 ' total number of balls
  580. ReDim rolling(tnob)
  581. InitRolling
  582.  
  583. Sub InitRolling
  584. Dim i
  585. For i = 0 to tnob
  586. rolling(i) = False
  587. Next
  588. End Sub
  589.  
  590. Sub RollingTimer_Timer()
  591. Dim BOT, b
  592. BOT = GetBalls
  593.  
  594. ' stop the sound of deleted balls
  595. For b = UBound(BOT) + 1 to tnob
  596. rolling(b) = False
  597. StopSound("fx_ballrolling" & b)
  598. Next
  599.  
  600. ' exit the sub if no balls on the table
  601. If UBound(BOT) = -1 Then Exit Sub
  602.  
  603. ' play the rolling sound for each ball
  604. For b = 0 to UBound(BOT)
  605. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  606. rolling(b) = True
  607. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  608. Else
  609. If rolling(b) = True Then
  610. StopSound("fx_ballrolling" & b)
  611. rolling(b) = False
  612. End If
  613. End If
  614. Next
  615. End Sub
  616.  
  617. '**********************
  618. ' Ball Collision Sound
  619. '**********************
  620.  
  621. Sub OnBallBallCollision(ball1, ball2, velocity)
  622. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  623. End Sub
  624.  
  625.  
  626.  
  627. '************************************
  628. ' What you need to add to your table
  629. '************************************
  630.  
  631. ' a timer called RollingTimer. With a fast interval, like 10
  632. ' one collision sound, in this script is called fx_collide
  633. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  634. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  635.  
  636.  
  637. '******************************************
  638. ' Explanation of the rolling sound routine
  639. '******************************************
  640.  
  641. ' sounds are played based on the ball speed and position
  642.  
  643. ' the routine checks first for deleted balls and stops the rolling sound.
  644.  
  645. ' The For loop goes through all the balls on the table and checks for the ball speed and
  646. ' if the ball is on the table (height lower than 30) then then it plays the sound
  647. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  648.  
  649. ' The sound is played using the VOL, PAN and PITCH functions, so the volume and pitch of the sound
  650. ' will change according to the ball speed, and the PAN function will change the stereo position according
  651. ' to the position of the ball on the table.
  652.  
  653.  
  654. '**************************************
  655. ' Explanation of the collision routine
  656. '**************************************
  657.  
  658. ' The collision is built in VP.
  659. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  660. ' 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
  661. ' depending of the speed of the collision.
  662.  
  663.  
  664. Sub Pins_Hit (idx)
  665. PlaySound "pinhit_low", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  666. End Sub
  667.  
  668. Sub Targets_Hit (idx)
  669. PlaySound "target", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 0, 0
  670. End Sub
  671.  
  672. Sub Metals_Thin_Hit (idx)
  673. PlaySound "metalhit_thin", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  674. End Sub
  675.  
  676. Sub Metals_Medium_Hit (idx)
  677. PlaySound "metalhit_medium", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  678. End Sub
  679.  
  680. Sub Metals2_Hit (idx)
  681. PlaySound "metalhit2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  682. End Sub
  683.  
  684. Sub Gates_Hit (idx)
  685. PlaySound "gate4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  686. End Sub
  687.  
  688. Sub Spinner_Spin
  689. PlaySound "fx_spinner",0,.25,0,0.25
  690. End Sub
  691.  
  692. Sub Rubbers_Hit(idx)
  693. dim finalspeed
  694. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  695. If finalspeed > 20 then
  696. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  697. End if
  698. If finalspeed >= 6 AND finalspeed <= 20 then
  699. RandomSoundRubber()
  700. End If
  701. End Sub
  702.  
  703. Sub Posts_Hit(idx)
  704. dim finalspeed
  705. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  706. If finalspeed > 16 then
  707. PlaySound "fx_rubber2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  708. End if
  709. If finalspeed >= 6 AND finalspeed <= 16 then
  710. RandomSoundRubber()
  711. End If
  712. End Sub
  713.  
  714. Sub RandomSoundRubber()
  715. Select Case Int(Rnd*3)+1
  716. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  717. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  718. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  719. End Select
  720. End Sub
  721.  
  722. Sub LeftFlipper_Collide(parm)
  723. RandomSoundFlipper()
  724. End Sub
  725.  
  726. Sub RightFlipper_Collide(parm)
  727. RandomSoundFlipper()
  728. End Sub
  729.  
  730. Sub RandomSoundFlipper()
  731. Select Case Int(Rnd*3)+1
  732. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  733. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  734. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  735. End Select
  736. End Sub
Advertisement
Add Comment
Please, Sign In to add comment