Advertisement
Guest User

Untitled

a guest
May 27th, 2019
287
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 33.80 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="gs_l4",UseSolenoids=2,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  10.  
  11. LoadVPM "01550000", "s11.vbs", 3.26
  12.  
  13. Dim DesktopMode: DesktopMode = Table1.ShowDT
  14.  
  15. If DesktopMode = True Then 'Show Desktop components
  16. Ramp16.visible=1
  17. Ramp15.visible=1
  18. Primitive13.visible=1
  19. Else
  20. Ramp16.visible=0
  21. Ramp15.visible=0
  22. Primitive13.visible=0
  23. End if
  24.  
  25. '*************************************************************
  26. 'Solenoid Call backs
  27. '**********************************************************************************************************
  28. SolCallback(1) = "bsTrough.SolIn"
  29. SolCallback(2) = "bsTrough.SolOut"
  30. SolCallback(5) = "bsL.SolOut"
  31. SolCallback(7) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  32. SolCallback(8) = "dtCar.SolDropUp"
  33. SolCallback(9) = "PFGI"
  34. SolCallback(10) = "SolDIV"
  35. SolCallback(11) = "SetLamp 111,"
  36. SolCallback(13) = "vpmSolSound SoundFX(""Bell"",DOFContactors),"
  37. SolCallback(14) = "VukTopPop"
  38.  
  39. SolCallback(26) = "SetLamp 126,"
  40. SolCallback(27) = "SetLamp 127,"
  41. SolCallback(28) = "SetLamp 128,"
  42. SolCallback(29) = "SetLamp 129,"
  43.  
  44. SolCallback(sLRFlipper) = "SolRFlipper"
  45. SolCallback(sLLFlipper) = "SolLFlipper"
  46.  
  47. Sub SolLFlipper(Enabled)
  48. If Enabled Then
  49. PlaySound SoundFX("fx_Flipperup",DOFContactors):LeftFlipper.RotateToEnd
  50. Else
  51. PlaySound SoundFX("fx_Flipperdown",DOFContactors):LeftFlipper.RotateToStart
  52. End If
  53. End Sub
  54.  
  55. Sub SolRFlipper(Enabled)
  56. If Enabled Then
  57. PlaySound SoundFX("fx_Flipperup",DOFContactors):RightFlipper.RotateToEnd
  58. Else
  59. PlaySound SoundFX("fx_Flipperdown",DOFContactors):RightFlipper.RotateToStart
  60. End If
  61. End Sub
  62. '**********************************************************************************************************
  63.  
  64. 'Solenoid Controlled toys
  65. '**********************************************************************************************************
  66.  
  67. 'Playfield GI
  68. Sub PFGI(Enabled)
  69. If Enabled Then
  70. dim xx, i
  71. For each xx in GI:xx.State = 0: Next
  72. PlaySound "fx_relay"
  73. Diodes.Enabled = 0
  74. ' For each i in bd(0):SetLamp i, 0:Next
  75. ' For each i in bd(1):SetLamp i, 0:Next
  76. ' For each i in bd(2):SetLamp i, 0:Next
  77. Else
  78. For each xx in GI:xx.State = 1: Next
  79. PlaySound "fx_relay"
  80. ' Diodes.Enabled = 1
  81. End If
  82. End Sub
  83.  
  84. Sub SolDIV(Enabled)
  85. If Enabled Then
  86. LockGate.Open = 1
  87. PlaySound "Diverter"
  88. Else
  89. LockGate.Open = 0
  90. PlaySound "Diverter"
  91. End If
  92. End Sub
  93.  
  94. 'Backwall diodes
  95. 'Dim bd(2)
  96. 'Dim bdCount:bdCount = 0
  97. '
  98. 'bd(0) = Array(133, 136, 139, 142, 145)
  99. 'bd(1) = Array(131, 134, 137, 140, 143, 146)
  100. 'bd(2) = Array(132, 135, 138, 141, 144)
  101. '
  102. 'Sub Diodes_Timer
  103. ' Dim i
  104. ' Select Case bdCount
  105. ' Case 0:For each i in bd(0):SetLamp i, 1:Next
  106. ' For each i in bd(2):SetLamp i, 0:Next
  107. ' Case 1:For each i in bd(1):SetLamp i, 1:Next
  108. ' For each i in bd(0):SetLamp i, 0:Next
  109. ' Case 2:For each i in bd(2):SetLamp i, 1:Next
  110. ' For each i in bd(1):SetLamp i, 0:Next
  111. ' End Select
  112. ' bdCount = bdCount + 1
  113. ' If bdCount> 2 Then bdCount = 0
  114. 'End Sub
  115.  
  116. '**********************************************************************************************************
  117.  
  118. 'Initiate Table
  119. '**********************************************************************************************************
  120.  
  121. Dim bsTrough, bsL, bsBP, dtCar
  122.  
  123. Sub Table1_Init
  124. vpmInit Me
  125. On Error Resume Next
  126. With Controller
  127. .GameName = cGameName
  128. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  129. .SplashInfoLine = "The Bally Game Show - Bally/Midway 1990"&chr(13)&"You Suck"
  130. .HandleMechanics=0
  131. .HandleKeyboard=0
  132. .ShowDMDOnly=1
  133. .ShowFrame=0
  134. .ShowTitle=0
  135. .hidden = 1
  136. On Error Resume Next
  137. .Run GetPlayerHWnd
  138. If Err Then MsgBox Err.Description
  139. On Error Goto 0
  140. End With
  141. On Error Goto 0
  142.  
  143. PinMAMETimer.Interval = PinMAMEInterval
  144. PinMAMETimer.Enabled = 1
  145.  
  146. vpmNudge.TiltSwitch = swTilt
  147. vpmNudge.Sensitivity = 2
  148. vpmNudge.TiltObj = Array(bumper1, bumper2, bumper3, LeftSlingshot, RightSlingshot)
  149.  
  150. Set bsTrough = New cvpmBallStack
  151. bsTrough.InitSw 10, 11, 12, 0, 0, 0, 0, 0
  152. bsTrough.InitKick BallRelease, 80, 6
  153. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  154. bsTrough.Balls = 2
  155.  
  156. Set bsL = New cvpmBallStack
  157. bsL.InitSaucer sw23, 23, 0, 21
  158. bsL.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  159. bsL.KickForceVar = 3
  160.  
  161. Set dtCar = New cvpmDropTarget
  162. dtCar.InitDrop sw39, 39
  163. dtCar.initsnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  164.  
  165. Diodes.Enabled = 1
  166. LockGate.Open = 0
  167.  
  168. End Sub
  169.  
  170.  
  171. '**********************************************************************************************************
  172. 'Plunger code
  173. '**********************************************************************************************************
  174.  
  175. Sub Table1_KeyDown(ByVal KeyCode)
  176.  
  177. If Keycode = LeftFlipperKey then Controller.Switch(58) = 1
  178. If Keycode = RightFlipperKey then Controller.Switch(57) = 1
  179. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  180. If KeyDownHandler(keycode) Then Exit Sub
  181. End Sub
  182.  
  183. Sub Table1_KeyUp(ByVal KeyCode)
  184.  
  185. If Keycode = LeftFlipperKey then Controller.Switch(58) = 0
  186. If Keycode = RightFlipperKey then Controller.Switch(57) = 0
  187. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  188. If KeyUpHandler(keycode) Then Exit Sub
  189. End Sub
  190.  
  191. '**********************************************************************************************************
  192.  
  193. ' Drain hole and kickers
  194. Sub Drain_Hit:bsTrough.addball me : playsound"drain" : End Sub
  195. Sub sw23_Hit:bsL.AddBall Me : playsound "rollover": End Sub
  196.  
  197. '***********************************
  198. ' Raising VUK
  199. '***********************************
  200. Dim raiseballsw, raiseball
  201. Sub TopVUK_Hit()
  202. Stopsound"Subway"
  203. playsound"popper_ball"
  204. TopVUK.Enabled=FALSE
  205. Controller.switch (21) = True
  206. End Sub
  207.  
  208. Sub VukTopPop(enabled)
  209. if(enabled and Controller.switch (21)) then
  210. playsound SoundFX("Popper",DOFContactors)
  211. TopVUK.DestroyBall
  212. Set raiseball = TopVUK.CreateBall
  213. raiseballsw = True
  214. TopVukraiseballtimer.Enabled = True
  215. TopVUK.Enabled=TRUE
  216. Controller.switch (21) = False
  217. else
  218. PlaySound "Popper"
  219. end if
  220. End Sub
  221.  
  222. Sub TopVukraiseballtimer_Timer()
  223. If raiseballsw = True then
  224. raiseball.z = raiseball.z + 10
  225. If raiseball.z > 190 then
  226. 'msgbox ("Over")
  227. TopVUK.Kick 180, 10
  228. Set raiseball = Nothing
  229. TopVukraiseballtimer.Enabled = False
  230. raiseballsw = False
  231. PlaySound "Wire Ramp"
  232. End If
  233. End If
  234. End Sub
  235.  
  236. 'Drop Targets
  237. Sub Sw39_Dropped:dtCar.Hit 1 :End Sub
  238.  
  239. 'Wire Triggers
  240. Sub sw14_Hit:Controller.Switch(14) = 1 : playsound"rollover" : End Sub
  241. Sub sw14_Unhit:Controller.Switch(14) = 0:End Sub
  242. Sub sw17_Hit:Controller.Switch(17) = 1 : playsound"rollover" : End Sub
  243. Sub sw17_Unhit:Controller.Switch(17) = 0:End Sub
  244. Sub sw18_Hit:Controller.Switch(18) = 1 : playsound"rollover" : End Sub
  245. Sub sw18_Unhit:Controller.Switch(18) = 0:End Sub
  246. Sub sw19_Hit:Controller.Switch(19) = 1 : playsound"rollover" : End Sub
  247. Sub sw19_Unhit:Controller.Switch(19) = 0:End Sub
  248. Sub sw45_Hit:Controller.Switch(45) = 1 : playsound"rollover" : End Sub
  249. Sub sw45_UnHit:Controller.Switch(45) = 0:End Sub
  250. Sub sw46_Hit:Controller.Switch(46) = 1 : playsound"rollover" : End Sub
  251. Sub sw46_UnHit:Controller.Switch(46) = 0:End Sub
  252. Sub sw47_Hit:Controller.Switch(47) = 1 : playsound"rollover" : End Sub
  253. Sub sw47_UnHit:Controller.Switch(47) = 0:End Sub
  254. Sub sw48_Hit:Controller.Switch(48) = 1 : playsound"rollover" : End Sub
  255. Sub sw48_UnHit:Controller.Switch(48) = 0:End Sub
  256.  
  257. 'Subway entrance
  258. Sub sw16_Hit:Controller.Switch(16) = 1 : playsound"Subway" : End Sub
  259. Sub sw16_Unhit:Controller.Switch(16) = 0:End Sub
  260.  
  261. 'Gate Triggers
  262. Sub sw20_Hit:vpmTimer.PulseSw 20:End Sub
  263. Sub sw25_Hit:vpmTimer.PulseSw 25:End Sub
  264. Sub sw26_Hit:vpmTimer.PulseSw 26:End Sub
  265. Sub sw41_Hit:vpmTimer.PulseSw 41:End Sub
  266. Sub sw43_Hit:vpmTimer.PulseSw 43:End Sub
  267.  
  268. 'Stand Up Targets
  269. Sub sw27_Hit:vpmTimer.PulseSw 27:End Sub
  270. Sub sw28_Hit:vpmTimer.PulseSw 28:End Sub
  271. Sub sw29_Hit:vpmTimer.PulseSw 29:End Sub
  272. Sub sw30_Hit:vpmTimer.PulseSw 30:End Sub
  273. Sub sw31_Hit:vpmTimer.PulseSw 31:End Sub
  274. Sub sw32_Hit:vpmTimer.PulseSw 32:End Sub
  275. Sub sw33_Hit:vpmTimer.PulseSw 33:End Sub
  276. Sub sw34_Hit:vpmTimer.PulseSw 34:End Sub
  277. Sub sw35_Hit:vpmTimer.PulseSw 35:End Sub
  278. Sub sw36_Hit:vpmTimer.PulseSw 36:End Sub
  279. Sub sw37_Hit:vpmTimer.PulseSw 37:End Sub
  280.  
  281. 'Spinners
  282. Sub sw42_Spin:vpmTimer.PulseSw 42 : playsound"fx_spinner" : End Sub
  283.  
  284. 'Bumpers
  285. Sub Bumper1_Hit : vpmTimer.PulseSw(60) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  286. Sub Bumper2_Hit : vpmTimer.PulseSw(61) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  287. Sub Bumper3_Hit : vpmTimer.PulseSw(62) : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  288.  
  289. 'Generic Sounds
  290. Sub Trigger2_Hit:PlaySound "fx_ballrampdrop":End Sub
  291. Sub Trigger3_Hit:StopSound "Wire Ramp" : PlaySound "fx_ballrampdrop":End Sub
  292.  
  293. Sub Kicker1_Hit:PlaySound "fx_ballrampdrop":End Sub
  294. Sub Kicker2_Hit:PlaySound "fx_ballrampdrop":End Sub
  295. Sub Kicker3_Hit:PlaySound "fx_ballrampdrop":End Sub
  296. Sub Kicker4_Hit:PlaySound "fx_ballrampdrop":End Sub
  297. Sub Kicker6_Hit:PlaySound "fx_ballrampdrop":End Sub
  298.  
  299. '***************************************************
  300. ' JP's VP10 Fading Lamps & Flashers
  301. ' Based on PD's Fading Light System
  302. ' SetLamp 0 is Off
  303. ' SetLamp 1 is On
  304. ' fading for non opacity objects is 4 steps
  305. '***************************************************
  306.  
  307. Dim LampState(200), FadingLevel(200)
  308. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  309.  
  310. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  311. LampTimer.Interval = 5 'lamp fading speed
  312. LampTimer.Enabled = 1
  313.  
  314. ' Lamp & Flasher Timers
  315.  
  316. Function ByteToBit(myByte)
  317.  
  318. 'Bit == 32103210
  319. ' --------
  320. '&HF0 == "11110000"
  321. '&H0A == "00001010"
  322.  
  323. Dim k
  324. Dim x
  325.  
  326. Dim valofbyte
  327. Dim mybytetobit
  328.  
  329. valofbyte = CInt(myByte)
  330. mybytetobit = ""
  331.  
  332. For k = 0 To 7
  333. x = 2 ^ k
  334. If valofbyte And x Then
  335. mybytetobit = "1" & mybytetobit
  336. Else
  337. mybytetobit = "0" & mybytetobit
  338. End If
  339.  
  340. Next
  341.  
  342. ByteToBit = mybytetobit
  343.  
  344. End Function
  345.  
  346. Sub LampTimer_Timer()
  347. Dim chgLamp, num, chg, ii
  348. chgLamp = Controller.ChangedLamps
  349. If Not IsEmpty(chgLamp) Then
  350. For ii = 0 To UBound(chgLamp)
  351. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  352. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  353. Next
  354. End If
  355. Dim NewSounds, Snd
  356. NewSounds = Controller.NewSoundCommands
  357. If Not IsEmpty(NewSounds) Then
  358. For ii = 0 To UBound(NewSounds)
  359. Snd = NewSounds(ii, 0)
  360. if (snd AND &HE0) = 0 then
  361. dim jj
  362. for jj = 0 to 3
  363. if (snd AND 2 ^ jj) = 0 then
  364. SetLamp 131+jj, 0
  365. SetLamp 135+jj, 0
  366. SetLamp 139+jj, 0
  367. SetLamp 143+jj, 0
  368. Else
  369. SetLamp 131+jj, 1
  370. SetLamp 135+jj, 1
  371. SetLamp 139+jj, 1
  372. SetLamp 143+jj, 1
  373. end if
  374. next
  375. debug.print "snd " & ByteToBit(snd) & " (" & Snd & ")"
  376. end if
  377. Next
  378. end if
  379. UpdateLamps
  380. End Sub
  381.  
  382. Sub UpdateLamps
  383. NFadeL 1, l1
  384. NFadeL 2, l2
  385. NFadeL 3, l3
  386. NFadeL 4, l4
  387. NFadeL 5, l5
  388. NFadeL 6, l6
  389. NFadeL 7, l7
  390. NFadeL 8, l8
  391. NFadeL 9, l9
  392. NFadeL 10, l10
  393. NFadeL 11, l11
  394. NFadeL 12, l12
  395. NFadeL 13, l13
  396. NFadeL 14, l14
  397. NFadeL 15, l15
  398. NFadeL 16, l16
  399. NFadeL 17, l17
  400. NFadeL 18, l18
  401. NFadeL 19, l19
  402. NFadeL 20, l20
  403. NFadeL 21, l21
  404. NFadeL 22, l22
  405. NFadeL 23, l23
  406. NFadeL 24, l24
  407. NFadeL 25, l25
  408. NFadeL 26, l26
  409. NFadeL 27, l27
  410. NFadeL 28, l28
  411. NFadeL 29, l29
  412. NFadeL 30, l30
  413. NFadeL 31, l31
  414. NFadeL 32, l32
  415. NFadeL 33, l33
  416. NFadeL 34, l34
  417. NFadeL 35, l35
  418. NFadeL 36, l36
  419. NFadeL 37, l37
  420. NFadeL 38, l38
  421. NFadeL 39, l39
  422. NFadeL 40, l40
  423. NFadeL 41, l41
  424. NFadeL 42, l42
  425. NFadeL 43, l43
  426. Flash 44, F44 'Car BackWall
  427. NFadeL 45, l45
  428. NFadeL 46, l46
  429. NFadeL 47, l47
  430. NFadeL 48, l48
  431. NFadeL 49, l49
  432. NFadeL 50, l50
  433. NFadeL 51, l51
  434. NFadeL 52, l52
  435. NFadeL 53, l53
  436. NFadeL 54, l54
  437. NFadeLm 55, l55
  438. Flash 55, F55 'BackWall dollar sign
  439. NFadeLm 56, l56
  440. Flash 56, F56 'BackWall dollar sign
  441. NFadeLm 57, l57
  442. Flash 57, F57 'BackWall dollar sign
  443. NFadeL 58, l58
  444. NFadeL 59, l59
  445. NFadeL 60, l60
  446. NFadeL 61, l61
  447. NFadeL 62, l62
  448. NFadeL 63, l63
  449. NFadeL 64, l64
  450.  
  451. 'Solenoid Controlled Flashers
  452.  
  453. NFadeLm 111, S111
  454. NFadeL 111, S111a
  455.  
  456. NFadeObjm 126, P126, "dome2_0_yellowON", "dome2_0_yellow"
  457. Flash 126, F126
  458.  
  459. NFadeLm 127, S127
  460. NFadeL 127, S127a
  461.  
  462. NFadeLm 128, S128
  463. NFadeL 128, S128a
  464.  
  465. NFadeObjm 129, P129, "dome2_0_redON", "dome2_0_red"
  466. NFadeL 129, S129
  467.  
  468.  
  469. 'Backwall LEDs
  470. NFadeObjm 131, L131, "bulbcover1_yellowOn", "bulbcover1_yellow"
  471. Flash 131, f131
  472. NFadeObjm 132, L132, "bulbcover1_yellowOn", "bulbcover1_yellow"
  473. Flash 132, f132
  474. NFadeObjm 133, L133, "bulbcover1_yellowOn", "bulbcover1_yellow"
  475. Flash 133, f133
  476. NFadeObjm 134, L134, "bulbcover1_yellowOn", "bulbcover1_yellow"
  477. Flash 134, f134
  478. NFadeObjm 135, L135, "bulbcover1_yellowOn", "bulbcover1_yellow"
  479. Flash 135, f135
  480. NFadeObjm 136, L136, "bulbcover1_yellowOn", "bulbcover1_yellow"
  481. Flash 136, f136
  482. NFadeObjm 137, L137, "bulbcover1_yellowOn", "bulbcover1_yellow"
  483. Flash 137, f137
  484. NFadeObjm 138, L138, "bulbcover1_yellowOn", "bulbcover1_yellow"
  485. Flash 138, f138
  486. NFadeObjm 139, L139, "bulbcover1_yellowOn", "bulbcover1_yellow"
  487. Flash 139, f139
  488. NFadeObjm 140, L140, "bulbcover1_yellowOn", "bulbcover1_yellow"
  489. Flash 140, f140
  490. NFadeObjm 141, L141, "bulbcover1_yellowOn", "bulbcover1_yellow"
  491. Flash 141, f141
  492. NFadeObjm 142, L142, "bulbcover1_yellowOn", "bulbcover1_yellow"
  493. Flash 142, f142
  494. NFadeObjm 143, L143, "bulbcover1_yellowOn", "bulbcover1_yellow"
  495. Flash 143, f143
  496. NFadeObjm 144, L144, "bulbcover1_yellowOn", "bulbcover1_yellow"
  497. Flash 144, f144
  498. NFadeObjm 145, L145, "bulbcover1_yellowOn", "bulbcover1_yellow"
  499. Flash 145, f145
  500. NFadeObjm 146, L146, "bulbcover1_yellowOn", "bulbcover1_yellow"
  501. Flash 146, f146
  502.  
  503. End Sub
  504.  
  505.  
  506. ' div lamp subs
  507.  
  508. Sub InitLamps()
  509. Dim x
  510. For x = 0 to 200
  511. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  512. FadingLevel(x) = 4 ' used to track the fading state
  513. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  514. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  515. FlashMax(x) = 1 ' the maximum value when on, usually 1
  516. FlashMin(x) = 0 ' the minimum value when off, usually 0
  517. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  518. Next
  519. End Sub
  520.  
  521. Sub AllLampsOff
  522. Dim x
  523. For x = 0 to 200
  524. SetLamp x, 0
  525. Next
  526. End Sub
  527.  
  528. Sub SetLamp(nr, value)
  529. If value <> LampState(nr) Then
  530. LampState(nr) = abs(value)
  531. FadingLevel(nr) = abs(value) + 4
  532. End If
  533. End Sub
  534.  
  535. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  536.  
  537. Sub NFadeL(nr, object)
  538. Select Case FadingLevel(nr)
  539. Case 4:object.state = 0:FadingLevel(nr) = 0
  540. Case 5:object.state = 1:FadingLevel(nr) = 1
  541. End Select
  542. End Sub
  543.  
  544. Sub NFadeLm(nr, object) ' used for multiple lights
  545. Select Case FadingLevel(nr)
  546. Case 4:object.state = 0
  547. Case 5:object.state = 1
  548. End Select
  549. End Sub
  550.  
  551. 'Lights, Ramps & Primitives used as 4 step fading lights
  552. 'a,b,c,d are the images used from on to off
  553.  
  554. Sub FadeObj(nr, object, a, b, c, d)
  555. Select Case FadingLevel(nr)
  556. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  557. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  558. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  559. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  560. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  561. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  562. End Select
  563. End Sub
  564.  
  565. Sub FadeObjm(nr, object, a, b, c, d)
  566. Select Case FadingLevel(nr)
  567. Case 4:object.image = b
  568. Case 5:object.image = a
  569. Case 9:object.image = c
  570. Case 13:object.image = d
  571. End Select
  572. End Sub
  573.  
  574. Sub NFadeObj(nr, object, a, b)
  575. Select Case FadingLevel(nr)
  576. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  577. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  578. End Select
  579. End Sub
  580.  
  581. Sub NFadeObjm(nr, object, a, b)
  582. Select Case FadingLevel(nr)
  583. Case 4:object.image = b
  584. Case 5:object.image = a
  585. End Select
  586. End Sub
  587.  
  588. ' Flasher objects
  589.  
  590. Sub Flash(nr, object)
  591. Select Case FadingLevel(nr)
  592. Case 4 'off
  593. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  594. If FlashLevel(nr) < FlashMin(nr) Then
  595. FlashLevel(nr) = FlashMin(nr)
  596. FadingLevel(nr) = 0 'completely off
  597. End if
  598. Object.IntensityScale = FlashLevel(nr)
  599. Case 5 ' on
  600. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  601. If FlashLevel(nr) > FlashMax(nr) Then
  602. FlashLevel(nr) = FlashMax(nr)
  603. FadingLevel(nr) = 1 'completely on
  604. End if
  605. Object.IntensityScale = FlashLevel(nr)
  606. End Select
  607. End Sub
  608.  
  609. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  610. Object.IntensityScale = FlashLevel(nr)
  611. End Sub
  612.  
  613.  
  614. '**********************************************************************************************************
  615. 'Digital Display
  616. '**********************************************************************************************************
  617. Dim Digits(32)
  618. Digits(0)=Array(a00, a05, a0c, a0d, a08, a01, a06, a0f, a02, a03, a04, a07, a0b, a0a, a09, a0e)
  619. Digits(1)=Array(a10, a15, a1c, a1d, a18, a11, a16, a1f, a12, a13, a14, a17, a1b, a1a, a19, a1e)
  620. Digits(2)=Array(a20, a25, a2c, a2d, a28, a21, a26, a2f, a22, a23, a24, a27, a2b, a2a, a29, a2e)
  621. Digits(3)=Array(a30, a35, a3c, a3d, a38, a31, a36, a3f, a32, a33, a34, a37, a3b, a3a, a39, a3e)
  622. Digits(4)=Array(a40, a45, a4c, a4d, a48, a41, a46, a4f, a42, a43, a44, a47, a4b, a4a, a49, a4e)
  623. Digits(5)=Array(a50, a55, a5c, a5d, a58, a51, a56, a5f, a52, a53, a54, a57, a5b, a5a, a59, a5e)
  624. Digits(6)=Array(a60, a65, a6c, a6d, a68, a61, a66, a6f, a62, a63, a64, a67, a6b, a6a, a69, a6e)
  625. Digits(7)=Array(a70, a75, a7c, a7d, a78, a71, a76, a7f, a72, a73, a74, a77, a7b, a7a, a79, a7e)
  626. Digits(8)=Array(a80, a85, a8c, a8d, a88, a81, a86, a8f, a82, a83, a84, a87, a8b, a8a, a89, a8e)
  627. Digits(9)=Array(a90, a95, a9c, a9d, a98, a91, a96, a9f, a92, a93, a94, a97, a9b, a9a, a99, a9e)
  628. Digits(10)=Array(aa0, aa5, aac, aad, aa8, aa1, aa6, aaf, aa2, aa3, aa4, aa7, aab, aaa, aa9, aae)
  629. Digits(11)=Array(ab0, ab5, abc, abd, ab8, ab1, ab6, abf, ab2, ab3, ab4, ab7, abb, aba, ab9, abe)
  630. Digits(12)=Array(ac0, ac5, acc, acd, ac8, ac1, ac6, acf, ac2, ac3, ac4, ac7, acb, aca, ac9, ace)
  631. Digits(13)=Array(ad0, ad5, adc, add, ad8, ad1, ad6, adf, ad2, ad3, ad4, ad7, adb, ada, ad9, ade)
  632. Digits(14)=Array(ae0, ae5, aec, aed, ae8, ae1, ae6, aef, ae2, ae3, ae4, ae7, aeb, aea, ae9, aee)
  633. Digits(15)=Array(af0, af5, afc, afd, af8, af1, af6, aff, af2, af3, af4, af7, afb, afa, af9, afe)
  634.  
  635. Digits(16)=Array(b00, b05, b0c, b0d, b08, b01, b06, b0f, b02, b03, b04, b07, b0b, b0a, b09, b0e)
  636. Digits(17)=Array(b10, b15, b1c, b1d, b18, b11, b16, b1f, b12, b13, b14, b17, b1b, b1a, b19, b1e)
  637. Digits(18)=Array(b20, b25, b2c, b2d, b28, b21, b26, b2f, b22, b23, b24, b27, b2b, b2a, b29, b2e)
  638. Digits(19)=Array(b30, b35, b3c, b3d, b38, b31, b36, b3f, b32, b33, b34, b37, b3b, b3a, b39, b3e)
  639. Digits(20)=Array(b40, b45, b4c, b4d, b48, b41, b46, b4f, b42, b43, b44, b47, b4b, b4a, b49, b4e)
  640. Digits(21)=Array(b50, b55, b5c, b5d, b58, b51, b56, b5f, b52, b53, b54, b57, b5b, b5a, b59, b5e)
  641. Digits(22)=Array(b60, b65, b6c, b6d, b68, b61, b66, b6f, b62, b63, b64, b67, b6b, b6a, b69, b6e)
  642. Digits(23)=Array(b70, b75, b7c, b7d, b78, b71, b76, b7f, b72, b73, b74, b77, b7b, b7a, b79, b7e)
  643. Digits(24)=Array(b80, b85, b8c, b8d, b88, b81, b86, b8f, b82, b83, b84, b87, b8b, b8a, b89, b8e)
  644. Digits(25)=Array(b90, b95, b9c, b9d, b98, b91, b96, b9f, b92, b93, b94, b97, b9b, b9a, b99, b9e)
  645. Digits(26)=Array(ba0, ba5, bac, bad, ba8, ba1, ba6, baf, ba2, ba3, ba4, ba7, bab, baa, ba9, bae)
  646. Digits(27)=Array(bb0, bb5, bbc, bbd, bb8, bb1, bb6, bbf, bb2, bb3, bb4, bb7, bbb, bba, bb9, bbe)
  647. Digits(28)=Array(bc0, bc5, bcc, bcd, bc8, bc1, bc6, bcf, bc2, bc3, bc4, bc7, bcb, bca, bc9, bce)
  648. Digits(29)=Array(bd0, bd5, bdc, bdd, bd8, bd1, bd6, bdf, bd2, bd3, bd4, bd7, bdb, bda, bd9, bde)
  649. Digits(30)=Array(be0, be5, bec, bed, be8, be1, be6, bef, be2, be3, be4, be7, beb, bea, be9, bee)
  650. Digits(31)=Array(bf0, bf5, bfc, bfd, bf8, bf1, bf6, bff, bf2, bf3, bf4, bf7, bfb, bfa, bf9, bfe)
  651.  
  652. Sub DisplayTimer_Timer
  653. Dim ChgLED, ii, jj, num, chg, stat, obj, b, x
  654. ChgLED=Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  655. If Not IsEmpty(ChgLED)Then
  656. If DesktopMode = True Then
  657. For ii=0 To UBound(chgLED)
  658. num=chgLED(ii, 0) : chg=chgLED(ii, 1) : stat=chgLED(ii, 2)
  659. if (num < 32) then
  660. For Each obj In Digits(num)
  661. If chg And 1 Then obj.State=stat And 1
  662. chg=chg\2 : stat=stat\2
  663. Next
  664. Else
  665. end if
  666. Next
  667. end if
  668. End If
  669. End Sub
  670. '**********************************************************************************************************
  671. '**********************************************************************************************************
  672.  
  673.  
  674.  
  675. '*********************************************************************
  676. ' Start of Default VPX calls
  677. '*********************************************************************
  678.  
  679. '**********Sling Shot Animations
  680. ' Rstep and Lstep are the variables that increment the animation
  681. '****************
  682. Dim RStep, Lstep
  683.  
  684. Sub RightSlingShot_Slingshot
  685. vpmTimer.PulseSw 64
  686. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  687. RSling.Visible = 0
  688. RSling1.Visible = 1
  689. sling1.rotx = 20
  690. RStep = 0
  691. RightSlingShot.TimerEnabled = 1
  692. End Sub
  693.  
  694. Sub RightSlingShot_Timer
  695. Select Case RStep
  696. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  697. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0
  698. End Select
  699. RStep = RStep + 1
  700. End Sub
  701.  
  702. Sub LeftSlingShot_Slingshot
  703. vpmTimer.PulseSw 63
  704. PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  705. LSling.Visible = 0
  706. LSling1.Visible = 1
  707. sling2.rotx = 20
  708. LStep = 0
  709. LeftSlingShot.TimerEnabled = 1
  710. End Sub
  711.  
  712. Sub LeftSlingShot_Timer
  713. Select Case LStep
  714. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  715. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0
  716. End Select
  717. LStep = LStep + 1
  718. End Sub
  719.  
  720.  
  721. '*********************************************************************
  722. ' Positional Sound Playback Functions
  723. '*********************************************************************
  724.  
  725. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  726. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  727. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  728. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  729. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  730. End Sub
  731.  
  732. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  733. Sub PlaySoundAt(soundname, tableobj)
  734. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  735. End Sub
  736.  
  737. Sub PlaySoundAtBall(soundname)
  738. PlaySoundAt soundname, ActiveBall
  739. End Sub
  740.  
  741.  
  742. '*********************************************************************
  743. ' Supporting Ball & Sound Functions
  744. '*********************************************************************
  745.  
  746. 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
  747. Dim tmp
  748. tmp = tableobj.y * 2 / table1.height-1
  749. If tmp > 0 Then
  750. AudioFade = Csng(tmp ^10)
  751. Else
  752. AudioFade = Csng(-((- tmp) ^10) )
  753. End If
  754. End Function
  755.  
  756. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  757. Dim tmp
  758. tmp = tableobj.x * 2 / table1.width-1
  759. If tmp > 0 Then
  760. AudioPan = Csng(tmp ^10)
  761. Else
  762. AudioPan = Csng(-((- tmp) ^10) )
  763. End If
  764. End Function
  765.  
  766. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  767. Vol = Csng(BallVel(ball) ^2 / 2000)
  768. End Function
  769.  
  770. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  771. Pitch = BallVel(ball) * 20
  772. End Function
  773.  
  774. Function BallVel(ball) 'Calculates the ball speed
  775. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  776. End Function
  777.  
  778.  
  779. '********************************************************************
  780. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  781. '********************************************************************
  782.  
  783. Const tnob = 5 ' total number of balls
  784. ReDim rolling(tnob)
  785. InitRolling
  786.  
  787. Sub InitRolling
  788. Dim i
  789. For i = 0 to tnob
  790. rolling(i) = False
  791. Next
  792. End Sub
  793.  
  794. Sub RollingTimer_Timer()
  795. Dim BOT, b
  796. BOT = GetBalls
  797.  
  798. ' stop the sound of deleted balls
  799. For b = UBound(BOT) + 1 to tnob
  800. rolling(b) = False
  801. StopSound("fx_ballrolling" & b)
  802. Next
  803.  
  804. ' exit the sub if no balls on the table
  805. If UBound(BOT) = -1 Then Exit Sub
  806.  
  807. For b = 0 to UBound(BOT)
  808. ' play the rolling sound for each ball
  809. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  810. rolling(b) = True
  811. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  812. Else
  813. If rolling(b) = True Then
  814. StopSound("fx_ballrolling" & b)
  815. rolling(b) = False
  816. End If
  817. End If
  818.  
  819. ' play ball drop sounds
  820. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  821. PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  822. End If
  823. Next
  824. End Sub
  825.  
  826. '**********************
  827. ' Ball Collision Sound
  828. '**********************
  829.  
  830. Sub OnBallBallCollision(ball1, ball2, velocity)
  831. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  832. End Sub
  833.  
  834.  
  835. '*****************************************
  836. ' ninuzzu's FLIPPER SHADOWS
  837. '*****************************************
  838.  
  839. sub FlipperTimer_Timer()
  840. FlipperLSh.RotZ = LeftFlipper.currentangle
  841. FlipperRSh.RotZ = RightFlipper.currentangle
  842. Flipperbatleft.RotAndTra8 = LeftFlipper.CurrentAngle - 90
  843. Flipperbatright.RotAndTra8 = RightFlipper.CurrentAngle + 90
  844. End Sub
  845.  
  846. '*****************************************
  847. ' ninuzzu's BALL SHADOW
  848. '*****************************************
  849. Dim BallShadow
  850. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  851.  
  852. Sub BallShadowUpdate_timer()
  853. Dim BOT, b
  854. BOT = GetBalls
  855. ' hide shadow of deleted balls
  856. If UBound(BOT)<(tnob-1) Then
  857. For b = (UBound(BOT) + 1) to (tnob-1)
  858. BallShadow(b).visible = 0
  859. Next
  860. End If
  861. ' exit the Sub if no balls on the table
  862. If UBound(BOT) = -1 Then Exit Sub
  863. ' render the shadow for each ball
  864. For b = 0 to UBound(BOT)
  865. If BOT(b).X < Table1.Width/2 Then
  866. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  867. Else
  868. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  869. End If
  870. ballShadow(b).Y = BOT(b).Y + 12
  871. If BOT(b).Z > 20 Then
  872. BallShadow(b).visible = 1
  873. Else
  874. BallShadow(b).visible = 0
  875. End If
  876. Next
  877. End Sub
  878.  
  879.  
  880.  
  881. '************************************
  882. ' What you need to add to your table
  883. '************************************
  884.  
  885. ' a timer called RollingTimer. With a fast interval, like 10
  886. ' one collision sound, in this script is called fx_collide
  887. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  888. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  889.  
  890.  
  891. '******************************************
  892. ' Explanation of the rolling sound routine
  893. '******************************************
  894.  
  895. ' sounds are played based on the ball speed and position
  896.  
  897. ' the routine checks first for deleted balls and stops the rolling sound.
  898.  
  899. ' The For loop goes through all the balls on the table and checks for the ball speed and
  900. ' if the ball is on the table (height lower than 30) then then it plays the sound
  901. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  902.  
  903. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  904. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  905. ' according to the position of the ball on the table.
  906.  
  907.  
  908. '**************************************
  909. ' Explanation of the collision routine
  910. '**************************************
  911.  
  912. ' The collision is built in VP.
  913. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  914. ' 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
  915. ' depending of the speed of the collision.
  916.  
  917.  
  918. Sub Pins_Hit (idx)
  919. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  920. End Sub
  921.  
  922. Sub Targets_Hit (idx)
  923. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  924. End Sub
  925.  
  926. Sub Metals_Thin_Hit (idx)
  927. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  928. End Sub
  929.  
  930. Sub Metals_Medium_Hit (idx)
  931. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  932. End Sub
  933.  
  934. Sub Metals2_Hit (idx)
  935. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  936. End Sub
  937.  
  938. Sub Gates_Hit (idx)
  939. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  940. End Sub
  941.  
  942. Sub Spinner_Spin
  943. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  944. End Sub
  945.  
  946. Sub Rubbers_Hit(idx)
  947. dim finalspeed
  948. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  949. If finalspeed > 20 then
  950. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  951. End if
  952. If finalspeed >= 6 AND finalspeed <= 20 then
  953. RandomSoundRubber()
  954. End If
  955. End Sub
  956.  
  957. Sub Posts_Hit(idx)
  958. dim finalspeed
  959. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  960. If finalspeed > 16 then
  961. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  962. End if
  963. If finalspeed >= 6 AND finalspeed <= 16 then
  964. RandomSoundRubber()
  965. End If
  966. End Sub
  967.  
  968. Sub RandomSoundRubber()
  969. Select Case Int(Rnd*3)+1
  970. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  971. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  972. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  973. End Select
  974. End Sub
  975.  
  976. Sub LeftFlipper_Collide(parm)
  977. RandomSoundFlipper()
  978. End Sub
  979.  
  980. Sub RightFlipper_Collide(parm)
  981. RandomSoundFlipper()
  982. End Sub
  983.  
  984. Sub RandomSoundFlipper()
  985. Select Case Int(Rnd*3)+1
  986. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  987. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  988. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  989. End Select
  990. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement