Arngrim

Beat the clock

Sep 7th, 2021
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 29.30 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. Const cGameName="beatclck",UseSolenoids=1,UseLamps=0,UseGI=0,sCoin="coin3"
  10.  
  11. LoadVPM "01120100", "BALLY.VBS", 3.02
  12.  
  13. Dim DesktopMode: DesktopMode = Table1.ShowDT
  14. If DesktopMode = True Then 'Show Desktop components
  15. Ramp16.visible=1
  16. Ramp15.visible=1
  17. Primitive13.visible=1
  18. Else
  19. Ramp16.visible=0
  20. Ramp15.visible=0
  21. Primitive13.visible=0
  22. End if
  23.  
  24.  
  25. '*************************************************************
  26. 'Solenoid Call backs
  27. '**********************************************************************************************************
  28.  
  29. SolCallBack(8)="bsSaucer46.SolOut" 'Left Saucer
  30. SolCallBack(9)="bsSaucer47.SolOut" 'Middle Saucer
  31. SolCallback(10)="dtR.SolDropUp" 'Single Drop Target Reset
  32. SolCallback(11)="dtL.SolDropUp" '1-6 Drop Target Reset
  33. SolCallback(14)="bsTrough.SolOut" 'BallRelease
  34. SolCallback(15)="vpmSolSound SoundFX(""knocker"",DOFKnocker)," 'Knocker
  35. 'SolCallback(19)="vpmNudge.SolGameOn"
  36.  
  37. SolCallback(sLRFlipper) = "SolRFlipper"
  38. SolCallback(sLLFlipper) = "SolLFlipper"
  39.  
  40. Sub SolLFlipper(Enabled)
  41. If Enabled Then
  42. PlaySound SoundFx("FlipperUp",DOFFlippers):LeftFlipper.RotateToEnd
  43. Else
  44. PlaySound SoundFx("FlipperDown",DOFFlippers):LeftFlipper.RotateToStart
  45. End If
  46. End Sub
  47.  
  48. Sub SolRFlipper(Enabled)
  49. If Enabled Then
  50. PlaySound SoundFx("FlipperUp",DOFFlippers):RightFlipper.RotateToEnd:Flipper1.RotateToEnd
  51. Else
  52. PlaySound SoundFx("FlipperDown",DOFFlippers):RightFlipper.RotateToStart:Flipper1.RotateToStart
  53. End If
  54. End Sub
  55.  
  56.  
  57. '**********************************************************************************************************
  58. 'Solenoid Controlled toys
  59. '**********************************************************************************************************
  60.  
  61. 'Playfield GI
  62. '*****GI Lights On
  63. dim xx
  64. For each xx in GI:xx.State = 1: Next
  65.  
  66. '**********************************************************************************************************
  67.  
  68. 'Initiate Table
  69. '**********************************************************************************************************
  70.  
  71.  
  72. Dim bsTrough,bsSaucer46,bsSaucer47,dtL,dtR
  73.  
  74. Sub Table1_Init
  75. vpmInit Me
  76. On Error Resume Next
  77. With Controller
  78. .GameName = cGameName
  79. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  80. .SplashInfoLine = "Beat The Clock'"&chr(13)&"You Suck"
  81. .HandleMechanics=0
  82. .HandleKeyboard=0
  83. .ShowDMDOnly=1
  84. .ShowFrame=0
  85. .ShowTitle=0
  86. .hidden = 1
  87. .Games(cGameName).Settings.Value("sound")=1
  88. '.PuPHide = 1
  89. On Error Resume Next
  90. .Run GetPlayerHWnd
  91. If Err Then MsgBox Err.Description
  92. On Error Goto 0
  93. End With
  94. On Error Goto 0
  95.  
  96. PinMAMETimer.Interval=PinMAMEInterval
  97. PinMAMETimer.Enabled=1
  98.  
  99. vpmNudge.TiltSwitch=15
  100. vpmNudge.Sensitivity=3
  101. vpmNudge.TiltObj=Array(Bumper1,Bumper2,Bumper3,LeftSlingshot,RightSlingshot)
  102.  
  103. Set dtL=New cvpmDropTarget
  104. dtL.InitDrop Array(sw1,sw2,sw3,sw4,sw5,sw7),Array(1,2,3,4,5,7)
  105. dtL.InitSnd SoundFX("dtdrop",DOFDropTargets),SoundFX("dtreset",DOFContactors)
  106.  
  107. Set dtR=New cvpmDropTarget
  108. dtR.InitDrop sw45,45
  109. dtR.InitSnd SoundFX("dtdrop",DOFContactors),SoundFX("flapclos",DOFContactors)
  110.  
  111. Set bsTrough=New cvpmBallStack
  112. bsTrough.InitSw 0,8,0,0,0,0,0,0
  113. bsTrough.InitKick BallRelease,110,4
  114. bsTrough.InitExitSnd SoundFX("ballrel",DOFContactors),SoundFX("solon",DOFContactors)
  115. bsTrough.Balls=1
  116.  
  117. Set bsSaucer46=New cvpmBallStack
  118. bsSaucer46.InitSaucer sw46,46,100,10
  119. bsSaucer46.InitExitSnd SoundFX("popper",DOFContactors),SoundFX("solon",DOFContactors)
  120. bsSaucer46.KickForceVar = 5
  121.  
  122. Set bsSaucer47=New cvpmBallStack
  123. bsSaucer47.InitSaucer sw47,47,180,10
  124. bsSaucer47.InitExitSnd SoundFX("popper",DOFContactors),SoundFX("solon",DOFContactors)
  125. bsSaucer47.KickAngleVar=10
  126. bsSaucer47.KickForceVar = 5
  127. End Sub
  128.  
  129. '**********************************************************************************************************
  130. 'Plunger code
  131. '**********************************************************************************************************
  132.  
  133. Sub Table1_KeyDown(ByVal keycode)
  134. If keycode = LeftMagnaSave Then bLutActive = True
  135. If keycode = RightMagnaSave Then
  136. If bLutActive Then NextLUT: End If
  137. End If
  138. If keycode = PlungerKey Then Plunger.PullBack: playsound"plungerpull"
  139. If KeyDownHandler(keycode) Then Exit Sub
  140. End Sub
  141.  
  142. Sub Table1_KeyUp(ByVal keycode)
  143. If keycode = LeftMagnaSave Then bLutActive = False
  144. If keycode = PlungerKey Then Plunger.Fire:playsound"plunger"
  145. If KeyUpHandler(keycode) Then Exit Sub
  146. End Sub
  147.  
  148. '------------------------------
  149. '------ Switch Handler ------
  150. '------------------------------
  151.  
  152. ' Drain hole and kickers
  153.  
  154. Sub Drain_Hit:bsTrough.AddBall Me: playsound "drain" : End Sub
  155. Sub sw46_Hit:bsSaucer46.AddBall 0 : playsound "Popper_Ball": End Sub
  156. Sub sw47_Hit:bsSaucer47.AddBall 0 : playsound "Popper_Ball": End Sub
  157.  
  158. ' Drop Targets
  159.  
  160. Sub sw1_Hit:dtL.Hit 1:End Sub
  161. Sub sw2_Hit:dtL.Hit 2:End Sub
  162. Sub sw3_Hit:dtL.Hit 3:End Sub
  163. Sub sw4_Hit:dtL.Hit 4:End Sub
  164. Sub sw5_Hit:dtL.Hit 5:End Sub
  165. Sub sw7_Hit:dtL.Hit 6:End Sub
  166. Sub sw45_Hit:dtR.Hit 1:End Sub
  167.  
  168. ' Stand Up Targets
  169.  
  170. Sub sw17_Hit:vpmTimer.PulseSw(17):PlaySound SoundFX("Target1",DOFTargets):End Sub
  171. Sub sw18_Hit:vpmTimer.PulseSw(18):PlaySound SoundFX("Target1",DOFTargets):End Sub
  172. Sub sw19_Hit:vpmTimer.PulseSw(19):PlaySound SoundFX("Target1",DOFTargets):End Sub
  173. Sub sw20_Hit:vpmTimer.PulseSw(20):PlaySound SoundFX("Target1",DOFTargets):End Sub
  174. Sub sw21_Hit:vpmTimer.PulseSw(21):PlaySound SoundFX("Target1",DOFTargets):End Sub
  175.  
  176.  
  177. Sub sw33_Hit:vpmTimer.PulseSw(33):PlaySound SoundFX("Target1",DOFTargets):End Sub
  178. Sub sw34_Hit:vpmTimer.PulseSw(34):PlaySound SoundFX("Target1",DOFTargets):End Sub
  179. Sub sw35_Hit:vpmTimer.PulseSw(35):PlaySound SoundFX("Target1",DOFTargets):End Sub
  180. Sub sw36_Hit:vpmTimer.PulseSw(36):PlaySound SoundFX("Target1",DOFTargets):End Sub
  181.  
  182. ' Star Triggers
  183.  
  184. Sub sw30_Hit:Controller.Switch(30)=1:PlaySound "Gate2":End Sub
  185. Sub sw30_unHit:Controller.Switch(30)=0:End Sub
  186. Sub sw31_Hit:Controller.Switch(31)=1:PlaySound "Gate2":End Sub
  187. Sub sw31_unHit:Controller.Switch(31)=0:End Sub
  188. Sub sw32_Hit:Controller.Switch(32)=1:PlaySound "Gate2":Me.TimerEnabled=1:Light16.State=0:End Sub
  189. Sub sw32_unHit:Controller.Switch(32)=0:End Sub
  190. Sub sw32_Timer:Me.TimerEnabled=0:Light16.State=1:End Sub
  191.  
  192. '------------------------------
  193. '------ Bumpers ------
  194. '------------------------------
  195.  
  196. Sub Bumper1_Hit:vpmTimer.PulseSw 25 : PlayBumperSound : End Sub
  197. Sub Bumper2_Hit:vpmTimer.PulseSw 26 : PlayBumperSound : End Sub
  198. Sub Bumper3_Hit:vpmTimer.PulseSw 27 : PlayBumperSound : End Sub
  199.  
  200. Sub PlayBumperSound()
  201. Select Case Int(Rnd*3)+1
  202. Case 1 : PlaySound SoundFX("fx_bumper_1",DOFContactors)
  203. Case 2 : PlaySound SoundFX("fx_bumper_1",DOFContactors)
  204. Case 3 : PlaySound SoundFX("fx_bumper_1",DOFContactors)
  205. End Select
  206. End Sub
  207.  
  208. ' Gates
  209. Sub Gate1_Hit:playsound "Gate5":End Sub
  210. Sub Gate2_Hit:playsound "Gate5":End Sub
  211. Sub Gate3_Hit:playsound "Gate5":End Sub
  212. Sub Gate4_Hit:playsound "Gate5":End Sub
  213. Sub Gate5_Hit:playsound "Gate5":End Sub
  214.  
  215. ' Wire Triggers
  216.  
  217. Sub sw13_Hit:Controller.Switch(13)=1: playsound "rollover": End Sub
  218. Sub sw13_unHit:Controller.Switch(13)=0:End Sub
  219. Sub sw16_Hit:Controller.Switch(16)=1: playsound "rollover": End Sub
  220. Sub sw16_unHit:Controller.Switch(16)=0:End Sub
  221. Sub sw23_Hit:Controller.Switch(23)=1: playsound "rollover": End Sub
  222. Sub sw23_unHit:Controller.Switch(23)=0:End Sub
  223. Sub sw24_Hit:Controller.Switch(24)=1: playsound "rollover": End Sub
  224. Sub sw24_unHit:Controller.Switch(24)=0:End Sub
  225. Sub sw37_Hit:Controller.Switch(37)=1: playsound "rollover": End Sub
  226. Sub sw37_unHit:Controller.Switch(37)=0: End Sub
  227. Sub sw38_Hit:Controller.Switch(38)=1: playsound "rollover": End Sub
  228. Sub sw38_unHit:Controller.Switch(38)=0: End Sub
  229. Sub sw39_Hit:Controller.Switch(39)=1: playsound "rollover": End Sub
  230. Sub sw39_unHit:Controller.Switch(39)=0: End Sub
  231. Sub sw40_Hit:Controller.Switch(40)=1: playsound "rollover": End Sub
  232. Sub sw40_unHit:Controller.Switch(40)=0: End Sub
  233.  
  234. '**********Sling Shot Animations
  235. ' Rstep and Lstep are the variables that increment the animation
  236. '****************
  237.  
  238. Dim RStep, Lstep
  239.  
  240. Sub RightSlingShot_Slingshot
  241. vpmTimer.PulseSw 28
  242. PlaySound SoundFX("RSling",DOFContactors), 0,1,0.15,0.1 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  243. RSling.Visible = 0
  244. RSling1.Visible = 1
  245. sling1.rotx = 20
  246. RStep = 0
  247. RightSlingShot.TimerEnabled = 1
  248. ' gi1.State = 0:Gi2.State = 0
  249. End Sub
  250.  
  251. Sub RightSlingShot_Timer
  252. Select Case RStep
  253. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  254. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
  255. End Select
  256. RStep = RStep + 1
  257. End Sub
  258.  
  259. Sub LeftSlingShot_Slingshot
  260. vpmTimer.PulseSw 29
  261. PlaySound SoundFX("LSling",DOFContactors), 0,1,-0.16,0.1 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  262. LSling.Visible = 0
  263. LSling1.Visible = 1
  264. sling2.rotx = 20
  265. LStep = 0
  266. LeftSlingShot.TimerEnabled = 1
  267. ' gi3.State = 0:Gi4.State = 0
  268. End Sub
  269.  
  270. Sub LeftSlingShot_Timer
  271. Select Case LStep
  272. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  273. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0:
  274. End Select
  275. LStep = LStep + 1
  276. End Sub
  277.  
  278. '***************************************************
  279. ' JP's VP10 Fading Lamps & Flashers
  280. ' Based on PD's Fading Light System
  281. ' SetLamp 0 is Off
  282. ' SetLamp 1 is On
  283. ' fading for non opacity objects is 4 steps
  284. '***************************************************
  285.  
  286. Dim LampState(200), FadingLevel(200)
  287. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  288.  
  289. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  290. LampTimer.Interval = 5 'lamp fading speed
  291. LampTimer.Enabled = 1
  292.  
  293. ' Lamp & Flasher Timers
  294.  
  295. Sub LampTimer_Timer()
  296. Dim chgLamp, num, chg, ii
  297. chgLamp = Controller.ChangedLamps
  298. If Not IsEmpty(chgLamp) Then
  299. For ii = 0 To UBound(chgLamp)
  300. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  301. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  302. Next
  303. End If
  304. UpdateLamps
  305. End Sub
  306.  
  307. Sub UpdateLamps()
  308.  
  309. NFadeL 2, Light2
  310. NFadeL 4, Light4
  311. NFadeL 5, Light5
  312. NFadeL 7, Light7
  313. NFadeL 8, Light8
  314. NFadeL 9, Light9
  315. NFadeL 10, Light10
  316. NFadeL 11, Light11
  317. NFadeL 12, Light12
  318. NFadeL 13, Light13
  319. NFadeL 14, Light14
  320. NFadeL 15, Light15
  321. NFadeL 16, Light16
  322. NFadeL 20, Light20
  323. NFadeL 21, Light21
  324. NFadeL 22, Light22
  325. NFadeL 23, Light23
  326. NFadeL 24, Light24
  327. NFadeL 25, Light25
  328. NFadeL 26, Light26
  329. NFadeL 27, Light27
  330. NFadeL 28, Light28
  331. NFadeL 29, Light29
  332. NFadeL 30, Light30
  333. NFadeL 31, Light31
  334. NFadeL 35, Light35
  335. NFadeL 36, Light36
  336. NFadeL 37, Light37
  337. NFadeL 38, Light38
  338. NFadeL 39, Light39
  339.  
  340. NFadeL 40, Light40
  341. NFadeL 41, Light41
  342. NFadeL 42, Light42
  343. NFadeL 43, Light43
  344. NFadeL 44, Light44
  345. NFadeL 45, Light45
  346. NFadeL 46, Light46
  347. NFadeL 47, Light47
  348. NFadeL 49, Light49
  349. NFadeL 50, Light50
  350. NFadeL 51, Light51
  351. NFadeL 52, Light52
  352. NFadeL 53, Light53
  353. NFadeL 54, Light54
  354. NFadeL 58, Light58
  355. NFadeL 59, Light59
  356. NFadeL 60, Light60
  357. NFadeL 62, Light62
  358. NFadeL 63, Light63
  359. NFadeL 65, Light65
  360. NFadeL 67, Light67
  361. NFadeL 68, Light68
  362. NFadeL 69, Light69
  363. NFadeL 74, Light74
  364. NFadeL 75, Light75
  365. NFadeL 76, Light76
  366. NFadeL 77, Light77
  367. NFadeL 78, Light78
  368. NFadeL 79, Light79
  369. NFadeL 81, Light81
  370. NFadeL 82, Light82
  371. NFadeL 83, Light83
  372. NFadeL 84, Light84
  373. NFadeL 85, Light85
  374. NFadeL 89, Light89
  375. NFadeL 90, Light90
  376. NFadeL 91, Light91
  377. NFadeL 92, Light92
  378. NFadeL 93, Light93
  379. NFadeL 94, Light94
  380. NFadeL 95, Light95
  381.  
  382.  
  383. 'Solenid Controlled Lamps
  384.  
  385.  
  386. End Sub
  387.  
  388. ' div lamp subs
  389.  
  390. Sub InitLamps()
  391. Dim x
  392. For x = 0 to 200
  393. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  394. FadingLevel(x) = 4 ' used to track the fading state
  395. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  396. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  397. FlashMax(x) = 1 ' the maximum value when on, usually 1
  398. FlashMin(x) = 0 ' the minimum value when off, usually 0
  399. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  400. Next
  401. End Sub
  402.  
  403. Sub AllLampsOff
  404. Dim x
  405. For x = 0 to 200
  406. SetLamp x, 0
  407. Next
  408. End Sub
  409.  
  410. Sub SetLamp(nr, value)
  411. If value <> LampState(nr) Then
  412. LampState(nr) = abs(value)
  413. FadingLevel(nr) = abs(value) + 4
  414. End If
  415. End Sub
  416.  
  417. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  418.  
  419. Sub NFadeL(nr, object)
  420. Select Case FadingLevel(nr)
  421. Case 4:object.state = 0:FadingLevel(nr) = 0
  422. Case 5:object.state = 1:FadingLevel(nr) = 1
  423. End Select
  424. End Sub
  425.  
  426. Sub NFadeLm(nr, object) ' used for multiple lights
  427. Select Case FadingLevel(nr)
  428. Case 4:object.state = 0
  429. Case 5:object.state = 1
  430. End Select
  431. End Sub
  432.  
  433. 'Lights, Ramps & Primitives used as 4 step fading lights
  434. 'a,b,c,d are the images used from on to off
  435.  
  436. Sub FadeObj(nr, object, a, b, c, d)
  437. Select Case FadingLevel(nr)
  438. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  439. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  440. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  441. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  442. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  443. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  444. End Select
  445. End Sub
  446.  
  447. Sub FadeObjm(nr, object, a, b, c, d)
  448. Select Case FadingLevel(nr)
  449. Case 4:object.image = b
  450. Case 5:object.image = a
  451. Case 9:object.image = c
  452. Case 13:object.image = d
  453. End Select
  454. End Sub
  455.  
  456. Sub NFadeObj(nr, object, a, b)
  457. Select Case FadingLevel(nr)
  458. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  459. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  460. End Select
  461. End Sub
  462.  
  463. Sub NFadeObjm(nr, object, a, b)
  464. Select Case FadingLevel(nr)
  465. Case 4:object.image = b
  466. Case 5:object.image = a
  467. End Select
  468. End Sub
  469.  
  470. ' Flasher objects
  471.  
  472. Sub Flash(nr, object)
  473. Select Case FadingLevel(nr)
  474. Case 4 'off
  475. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  476. If FlashLevel(nr) < FlashMin(nr) Then
  477. FlashLevel(nr) = FlashMin(nr)
  478. FadingLevel(nr) = 0 'completely off
  479. End if
  480. Object.IntensityScale = FlashLevel(nr)
  481. Case 5 ' on
  482. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  483. If FlashLevel(nr) > FlashMax(nr) Then
  484. FlashLevel(nr) = FlashMax(nr)
  485. FadingLevel(nr) = 1 'completely on
  486. End if
  487. Object.IntensityScale = FlashLevel(nr)
  488. End Select
  489. End Sub
  490.  
  491. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  492. Object.IntensityScale = FlashLevel(nr)
  493. End Sub
  494.  
  495. '**********************************************************************************************************
  496. 'Digital Display
  497. '**********************************************************************************************************
  498.  
  499. Dim Digits(32)
  500. ' 1st Player
  501. Digits(0) = Array(LED10,LED11,LED12,LED13,LED14,LED15,LED16)
  502. Digits(1) = Array(LED20,LED21,LED22,LED23,LED24,LED25,LED26)
  503. Digits(2) = Array(LED30,LED31,LED32,LED33,LED34,LED35,LED36)
  504. Digits(3) = Array(LED40,LED41,LED42,LED43,LED44,LED45,LED46)
  505. Digits(4) = Array(LED50,LED51,LED52,LED53,LED54,LED55,LED56)
  506. Digits(5) = Array(LED60,LED61,LED62,LED63,LED64,LED65,LED66)
  507. Digits(6) = Array(LED70,LED71,LED72,LED73,LED74,LED75,LED76)
  508.  
  509. ' 2nd Player
  510. Digits(7) = Array(LED80,LED81,LED82,LED83,LED84,LED85,LED86)
  511. Digits(8) = Array(LED90,LED91,LED92,LED93,LED94,LED95,LED96)
  512. Digits(9) = Array(LED100,LED101,LED102,LED103,LED104,LED105,LED106)
  513. Digits(10) = Array(LED110,LED111,LED112,LED113,LED114,LED115,LED116)
  514. Digits(11) = Array(LED120,LED121,LED122,LED123,LED124,LED125,LED126)
  515. Digits(12) = Array(LED130,LED131,LED132,LED133,LED134,LED135,LED136)
  516. Digits(13) = Array(LED140,LED141,LED142,LED143,LED144,LED145,LED146)
  517.  
  518. ' 3rd Player
  519. Digits(14) = Array(LED150,LED151,LED152,LED153,LED154,LED155,LED156)
  520. Digits(15) = Array(LED160,LED161,LED162,LED163,LED164,LED165,LED166)
  521. Digits(16) = Array(LED170,LED171,LED172,LED173,LED174,LED175,LED176)
  522. Digits(17) = Array(LED180,LED181,LED182,LED183,LED184,LED185,LED186)
  523. Digits(18) = Array(LED190,LED191,LED192,LED193,LED194,LED195,LED196)
  524. Digits(19) = Array(LED200,LED201,LED202,LED203,LED204,LED205,LED206)
  525. Digits(20) = Array(LED210,LED211,LED212,LED213,LED214,LED215,LED216)
  526.  
  527. ' 4th Player
  528. Digits(21) = Array(LED220,LED221,LED222,LED223,LED224,LED225,LED226)
  529. Digits(22) = Array(LED230,LED231,LED232,LED233,LED234,LED235,LED236)
  530. Digits(23) = Array(LED240,LED241,LED242,LED243,LED244,LED245,LED246)
  531. Digits(24) = Array(LED250,LED251,LED252,LED253,LED254,LED255,LED256)
  532. Digits(25) = Array(LED260,LED261,LED262,LED263,LED264,LED265,LED266)
  533. Digits(26) = Array(LED270,LED271,LED272,LED273,LED274,LED275,LED276)
  534. Digits(27) = Array(LED280,LED281,LED282,LED283,LED284,LED285,LED286)
  535.  
  536. ' Credits
  537. Digits(28) = Array(LED4,LED2,LED6,LED7,LED5,LED1,LED3)
  538. Digits(29) = Array(LED18,LED9,LED27,LED28,LED19,LED8,LED17)
  539. ' Balls
  540. Digits(30) = Array(LED39,LED37,LED48,LED49,LED47,LED29,LED38)
  541. Digits(31) = Array(LED67,LED58,LED69,LED77,LED68,LED57,LED59)
  542.  
  543. Sub DisplayTimer_Timer
  544. Dim ChgLED,ii,num,chg,stat,obj
  545. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  546. If Not IsEmpty(ChgLED) Then
  547. If DesktopMode = True Then
  548. For ii = 0 To UBound(chgLED)
  549. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  550. if (num < 32) then
  551. For Each obj In Digits(num)
  552. If chg And 1 Then obj.State = stat And 1
  553. chg = chg\2 : stat = stat\2
  554. Next
  555. else
  556. end if
  557. next
  558. end if
  559. end if
  560. End Sub
  561.  
  562.  
  563. '*********************************************************************
  564. ' Positional Sound Playback Functions
  565. '*********************************************************************
  566.  
  567. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  568. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  569. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  570. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  571. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  572. End Sub
  573.  
  574. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  575. Sub PlaySoundAt(soundname, tableobj)
  576. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  577. End Sub
  578.  
  579. Sub PlaySoundAtBall(soundname)
  580. PlaySoundAt soundname, ActiveBall
  581. End Sub
  582.  
  583.  
  584. '*********************************************************************
  585. ' Supporting Ball & Sound Functions
  586. '*********************************************************************
  587.  
  588. 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
  589. Dim tmp
  590. tmp = tableobj.y * 2 / table1.height-1
  591. If tmp > 0 Then
  592. AudioFade = Csng(tmp ^10)
  593. Else
  594. AudioFade = Csng(-((- tmp) ^10) )
  595. End If
  596. End Function
  597.  
  598. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  599. Dim tmp
  600. tmp = tableobj.x * 2 / table1.width-1
  601. If tmp > 0 Then
  602. AudioPan = Csng(tmp ^10)
  603. Else
  604. AudioPan = Csng(-((- tmp) ^10) )
  605. End If
  606. End Function
  607.  
  608. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  609. Vol = Csng(BallVel(ball) ^2 / 32000)
  610. End Function
  611.  
  612. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  613. Pitch = BallVel(ball) * 20
  614. End Function
  615.  
  616. Function BallVel(ball) 'Calculates the ball speed
  617. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  618. End Function
  619.  
  620.  
  621. '********************************************************************
  622. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  623. '********************************************************************
  624.  
  625. Const tnob = 5 ' total number of balls
  626. ReDim rolling(tnob)
  627. InitRolling
  628.  
  629. Sub InitRolling
  630. Dim i
  631. For i = 0 to tnob
  632. rolling(i) = False
  633. Next
  634. End Sub
  635.  
  636. Sub RollingTimer_Timer()
  637. Dim BOT, b
  638. BOT = GetBalls
  639.  
  640. ' stop the sound of deleted balls
  641. For b = UBound(BOT) + 1 to tnob
  642. rolling(b) = False
  643. StopSound("fx_ballrolling" & b)
  644. Next
  645.  
  646. ' exit the sub if no balls on the table
  647. If UBound(BOT) = -1 Then Exit Sub
  648.  
  649. For b = 0 to UBound(BOT)
  650. ' play the rolling sound for each ball
  651. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  652. rolling(b) = True
  653. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  654. Else
  655. If rolling(b) = True Then
  656. StopSound("fx_ballrolling" & b)
  657. rolling(b) = False
  658. End If
  659. End If
  660.  
  661. ' play ball drop sounds
  662. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  663. PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  664. End If
  665. Next
  666. End Sub
  667.  
  668. '**********************
  669. ' Ball Collision Sound
  670. '**********************
  671.  
  672. Sub OnBallBallCollision(ball1, ball2, velocity)
  673. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  674. End Sub
  675.  
  676.  
  677. '*****************************************
  678. ' ninuzzu's FLIPPER SHADOWS
  679. '*****************************************
  680.  
  681. sub FlipperTimer_Timer()
  682.  
  683. FlipperLSh.RotZ = LeftFlipper.currentangle
  684. FlipperRSh.RotZ = RightFlipper.currentangle
  685.  
  686. End Sub
  687.  
  688. '*****************************************
  689. ' ninuzzu's BALL SHADOW
  690. '*****************************************
  691. Dim BallShadow
  692. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  693.  
  694. Sub BallShadowUpdate_timer()
  695. Dim BOT, b
  696. BOT = GetBalls
  697. ' hide shadow of deleted balls
  698. If UBound(BOT)<(tnob-1) Then
  699. For b = (UBound(BOT) + 1) to (tnob-1)
  700. BallShadow(b).visible = 0
  701. Next
  702. End If
  703. ' exit the Sub if no balls on the table
  704. If UBound(BOT) = -1 Then Exit Sub
  705. ' render the shadow for each ball
  706. For b = 0 to UBound(BOT)
  707. If BOT(b).X < Table1.Width/2 Then
  708. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  709. Else
  710. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  711. End If
  712. ballShadow(b).Y = BOT(b).Y + 12
  713. If BOT(b).Z > 20 Then
  714. BallShadow(b).visible = 1
  715. Else
  716. BallShadow(b).visible = 0
  717. End If
  718. Next
  719. End Sub
  720.  
  721. '*************
  722. ' JP'S LUT
  723. '*************
  724.  
  725. Dim bLutActive, LUTImage
  726. Sub LoadLUT
  727. Dim x
  728. x = LoadValue(cGameName, "LUTImage")
  729. If(x <> "") Then LUTImage = x Else LUTImage = 0
  730. UpdateLUT
  731. End Sub
  732.  
  733. Sub SaveLUT
  734. SaveValue cGameName, "LUTImage", LUTImage
  735. End Sub
  736.  
  737. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  738.  
  739. Sub UpdateLUT
  740. Select Case LutImage
  741. Case 0: table1.ColorGradeImage = "LUT0"
  742. Case 1: table1.ColorGradeImage = "LUT1"
  743. Case 2: table1.ColorGradeImage = "LUT2"
  744. Case 3: table1.ColorGradeImage = "LUT3"
  745. Case 4: table1.ColorGradeImage = "LUT4"
  746. Case 5: table1.ColorGradeImage = "LUT5"
  747. Case 6: table1.ColorGradeImage = "LUT6"
  748. Case 7: table1.ColorGradeImage = "LUT7"
  749. Case 8: table1.ColorGradeImage = "LUT8"
  750. Case 9: table1.ColorGradeImage = "LUT9"
  751.  
  752. End Select
  753. End Sub
  754.  
  755. '************************************
  756. ' What you need to add to your table
  757. '************************************
  758.  
  759. ' a timer called RollingTimer. With a fast interval, like 10
  760. ' one collision sound, in this script is called fx_collide
  761. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  762. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  763.  
  764.  
  765. '******************************************
  766. ' Explanation of the rolling sound routine
  767. '******************************************
  768.  
  769. ' sounds are played based on the ball speed and position
  770.  
  771. ' the routine checks first for deleted balls and stops the rolling sound.
  772.  
  773. ' The For loop goes through all the balls on the table and checks for the ball speed and
  774. ' if the ball is on the table (height lower than 30) then then it plays the sound
  775. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  776.  
  777. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  778. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  779. ' according to the position of the ball on the table.
  780.  
  781.  
  782. '**************************************
  783. ' Explanation of the collision routine
  784. '**************************************
  785.  
  786. ' The collision is built in VP.
  787. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  788. ' 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
  789. ' depending of the speed of the collision.
  790.  
  791.  
  792. Sub Pins_Hit (idx)
  793. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  794. End Sub
  795.  
  796. Sub Targets_Hit (idx)
  797. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  798. End Sub
  799.  
  800. Sub Metals_Thin_Hit (idx)
  801. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  802. End Sub
  803.  
  804. Sub Metals_Medium_Hit (idx)
  805. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  806. End Sub
  807.  
  808. Sub Metals2_Hit (idx)
  809. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  810. End Sub
  811.  
  812. Sub Gates_Hit (idx)
  813. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  814. End Sub
  815.  
  816. Sub Spinner_Spin
  817. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  818. End Sub
  819.  
  820. Sub Rubbers_Hit(idx)
  821. dim finalspeed
  822. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  823. If finalspeed > 20 then
  824. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  825. End if
  826. If finalspeed >= 6 AND finalspeed <= 20 then
  827. RandomSoundRubber()
  828. End If
  829. End Sub
  830.  
  831. Sub Posts_Hit(idx)
  832. dim finalspeed
  833. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  834. If finalspeed > 16 then
  835. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  836. End if
  837. If finalspeed >= 6 AND finalspeed <= 16 then
  838. RandomSoundRubber()
  839. End If
  840. End Sub
  841.  
  842. Sub RandomSoundRubber()
  843. Select Case Int(Rnd*3)+1
  844. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  845. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  846. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  847. End Select
  848. End Sub
  849.  
  850. Sub LeftFlipper_Collide(parm)
  851. RandomSoundFlipper()
  852. End Sub
  853.  
  854. Sub RightFlipper_Collide(parm)
  855. RandomSoundFlipper()
  856. End Sub
  857.  
  858. Sub RandomSoundFlipper()
  859. Select Case Int(Rnd*3)+1
  860. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  861. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  862. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  863. End Select
  864. End Sub
  865.  
  866.  
  867. Sub Table1_Exit()
  868. If B2SOn Then
  869. Controller.Pause = False
  870. Controller.Stop
  871. End If
  872. End Sub
Advertisement
Add Comment
Please, Sign In to add comment