Advertisement
Guest User

Untitled

a guest
Dec 19th, 2018
150
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.38 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="cueball",UseSolenoids=1,UseLamps=0,UseGI=0,SSolenoidOn="SolOn",SSolenoidOff="SolOff", SCoin="coin"
  10.  
  11. Const BallSize = 54
  12.  
  13. LoadVPM "01570000", "gts3.vbs", 3.26
  14.  
  15. Dim DesktopMode: DesktopMode = Table1.ShowDT
  16. If DesktopMode = True Then 'Show Desktop components
  17. Ramp16.visible=1
  18. Ramp15.visible=1
  19. Primitive13.visible=1
  20. Else
  21. Ramp16.visible=0
  22. Ramp15.visible=0
  23. Primitive13.visible=0
  24. End if
  25.  
  26. '*************************************************************
  27. 'Solenoid Call backs
  28. '**********************************************************************************************************
  29.  
  30. SolCallback(8) = "Solgate"
  31. SolCallback(9) = "dtRBank.SolDropUp"
  32. SolCallback(10) = "SolShoot8Ball"
  33. SolCallback(11) = "bsBSaucer.SolOut"
  34. SolCallback(12) = "dtLBank.SolDropUp"
  35. SolCallback(13) = "bsLSaucer.SolOut"
  36. SolCallback(14) = "bsRSaucer.SolOut"
  37. SolCallback(15) = "SetLamp 151,"
  38. SolCallback(16) = "SetLamp 152,"
  39. SolCallback(17) = "SetLamp 153,"
  40. SolCallback(18) = "SetLamp 154,"
  41. SolCallback(19) = "SetLamp 155,"
  42. SolCallback(21) = "SetLamp 156,"
  43. SolCallback(22) = "SetLamp 157,"
  44. SolCallback(28) = "bsTrough.SolOut"
  45. 'SolCallback(25) = "shootermotor"
  46. SolCallback(29) = "bsTrough.SolIn"
  47. SolCallback(30) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  48.  
  49.  
  50. SolCallback(sLRFlipper) = "SolRFlipper"
  51. SolCallback(sLLFlipper) = "SolLFlipper"
  52.  
  53. Sub SolLFlipper(Enabled)
  54. If Enabled Then
  55. PlaySound SoundFX("fx_Flipperup",DOFContactors):LeftFlipper.RotateToEnd
  56. Else
  57. PlaySound SoundFX("fx_Flipperdown",DOFContactors):LeftFlipper.RotateToStart
  58. End If
  59. End Sub
  60.  
  61. Sub SolRFlipper(Enabled)
  62. If Enabled Then
  63. PlaySound SoundFX("fx_Flipperup",DOFContactors):RightFlipper.RotateToEnd
  64. Else
  65. PlaySound SoundFX("fx_Flipperdown",DOFContactors):RightFlipper.RotateToStart
  66. End If
  67. End Sub
  68.  
  69. '**********************************************************************************************************
  70.  
  71. 'Solenoid Controlled toys
  72. '**********************************************************************************************************
  73.  
  74. Sub Solgate(Enabled)
  75. If Enabled Then
  76. PlungerGate.IsDropped=1
  77. PlungerGate1.Enabled= 0
  78. PlungerGate1.kick 0,0
  79. PlaySound SoundFX("fx_Flipperup",DOFContactors)
  80. Else
  81. PlungerGate.IsDropped=0
  82. PlungerGate1.Enabled= 1
  83.  
  84. End If
  85. End Sub
  86.  
  87. '*****GI Lights On
  88. dim xx
  89. For each xx in GI:xx.State = 1: Next
  90.  
  91.  
  92. '**********************************************************************************************************
  93.  
  94. 'Initiate Table
  95. '**********************************************************************************************************
  96.  
  97. Dim bsTrough, dtLBank, dtRBank, mShooter, bsLSaucer, bsRSaucer, bsBSaucer
  98.  
  99. Sub Table1_Init
  100. vpmInit Me
  101. On Error Resume Next
  102. With Controller
  103. .GameName = cGameName
  104. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  105. .SplashInfoLine = ""&chr(13)&"You Suck"
  106. .HandleMechanics=0
  107. .HandleKeyboard=0
  108. .ShowDMDOnly=1
  109. .ShowFrame=0
  110. .ShowTitle=0
  111. .hidden = 0
  112. On Error Resume Next
  113. .Run GetPlayerHWnd
  114. If Err Then MsgBox Err.Description
  115. On Error Goto 0
  116. End With
  117. On Error Goto 0
  118.  
  119. PinMAMETimer.Interval=PinMAMEInterval
  120. PinMAMETimer.Enabled=1
  121. vpmNudge.TiltSwitch = 151
  122. vpmNudge.Sensitivity = 2
  123. vpmNudge.TiltObj = Array(Bumper1, Bumper2, LeftSlingshot, RightSlingshot)
  124.  
  125. ' Trough
  126. Set bsTrough = New cvpmBallStack
  127. bsTrough.InitSw 40, 41, 0, 0, 0, 0, 0, 0
  128. bsTrough.InitKick BallRelease, 80, 6
  129. bsTrough.InitExitSnd SoundFX("ballrelease",DOFContactors), SoundFX("Solenoid",DOFContactors)
  130. bsTrough.Balls = 3
  131.  
  132. Set bsLSaucer = New cvpmBallStack
  133. bsLSaucer.InitSaucer sw27, 27, 225, 11
  134. bsLSaucer.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  135. bsLSaucer.KickAngleVar = 2
  136.  
  137. Set bsRSaucer = New cvpmBallStack
  138. bsRSaucer.InitSaucer sw37, 37, 145, 11
  139. bsRSaucer.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  140. bsRSaucer.KickAngleVar = 2
  141.  
  142. Set bsBSaucer = New cvpmBallStack
  143. bsBSaucer.InitSaucer sw17, 17, 134, 19
  144. bsBSaucer.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solenoid",DOFContactors)
  145. bsBSaucer.KickAngleVar = 2
  146.  
  147. set dtLBank = new cvpmdroptarget
  148. dtLBank.initdrop array(sw20, sw30, sw21, sw31, sw22, sw32, sw26), array(20, 30, 21, 31, 22, 32, 26)
  149. dtLBank.initsnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  150. dtLBank.CreateEvents "dtLBank"
  151.  
  152. set dtRBank = new cvpmdroptarget
  153. dtRBank.initdrop array(sw23, sw33, sw24, sw34, sw25, sw35, sw36), array(23, 33, 24, 34, 25, 35, 36)
  154. dtRBank.initsnd SoundFX("DTDrop",DOFContactors),SoundFX("DTReset",DOFContactors)
  155. dtRBank.CreateEvents "dtRBank"
  156.  
  157. Set mShooter = New cvpmMech
  158. With mShooter
  159. .MType = vpmMechOneSol + vpmMechReverse + vpmMechLinear
  160. .Sol1 = 25
  161. .Length = 80
  162. .Steps = 9
  163. .Callback = GetRef("UpdateShooter")
  164. .Start
  165. End With
  166.  
  167. CreateBlackBall
  168. CreateWhiteBall
  169.  
  170. End Sub
  171.  
  172. Sub Table1_Paused:Controller.Pause = 1:End Sub
  173. Sub Table1_unPaused:Controller.Pause = 0:End Sub
  174.  
  175. '**********************************************************************************************************
  176. 'Plunger code
  177. '**********************************************************************************************************
  178.  
  179.  
  180. Sub Table1_KeyDown(ByVal Keycode)
  181. If keycode = LeftFlipperKey Then Controller.Switch(81) = 1
  182. If keycode = RightFlipperKey Then Controller.Switch(82) = 1
  183. If keycode = StartGameKey Then Controller.Switch(4) = 1
  184. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  185.  
  186. If vpmKeyDown(keycode) Then Exit Sub
  187. End Sub
  188.  
  189. Sub Table1_KeyUp(ByVal Keycode)
  190. If keycode = LeftFlipperKey Then Controller.Switch(81) = 0
  191. If keycode = RightFlipperKey Then Controller.Switch(82) = 0
  192. If keycode = StartGameKey Then Controller.Switch(4) = 0
  193. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  194.  
  195. If vpmKeyUp(keycode) Then Exit Sub
  196. End Sub
  197.  
  198.  
  199. '**********************************************************************************************************
  200.  
  201. ' Drain & Holes
  202. Sub Drain_Hit:bsTrough.addball me : playsound"drain" : End Sub
  203. Sub Drain2_Hit:bsTrough.addball me : playsound"drain" : End Sub
  204. Sub Drain3_Hit:bsTrough.addball me : playsound"drain" : End Sub
  205. Sub Drain4_Hit:bsTrough.addball me : playsound"drain" : End Sub
  206.  
  207. Sub sw17_Hit:bsBSaucer.AddBall 0 : playsound "popper_ball": End Sub
  208. Sub sw27_Hit:bsLSaucer.AddBall 0 : playsound "popper_ball": End Sub
  209. Sub sw37_Hit:bsRSaucer.AddBall 0 : playsound "popper_ball": End Sub
  210.  
  211. 'wire triggers
  212. Sub sw7_Hit:Controller.Switch(7) = 1 : playsound"rollover" : End Sub
  213. Sub sw7_UnHit:Controller.Switch(7) = 0:End Sub
  214. Sub sw91_Hit:Controller.Switch(91) = 1 : playsound"rollover" : End Sub
  215. Sub sw91_UnHit:Controller.Switch(91) = 0:End Sub
  216. Sub sw92_Hit:Controller.Switch(92) = 1 : playsound"rollover" : End Sub
  217. Sub sw92_UnHit:Controller.Switch(92) = 0:End Sub
  218. Sub sw101_Hit:Controller.Switch(101) = 1 : playsound"rollover" : End Sub
  219. Sub sw101_UnHit:Controller.Switch(101) = 0:End Sub
  220. Sub sw102_Hit:Controller.Switch(102) = 1 : playsound"rollover" : End Sub
  221. Sub sw102_UnHit:Controller.Switch(102) = 0:End Sub
  222.  
  223. 'Scoring Rubbers
  224. Sub sw12_Slingshot:vpmTimer.PulseSw 12 : playsound"flip_hit_3" : End Sub
  225. Sub sw13_SlingShot:vpmTimer.PulseSw 13 : playsound"flip_hit_3" : End Sub
  226.  
  227. ' Bumpers
  228. Sub Bumper1_Hit:vpmTimer.PulseSw 10 : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  229. Sub Bumper2_Hit:vpmTimer.PulseSw 11 : playsound SoundFX("fx_bumper1",DOFContactors): End Sub
  230.  
  231. ' Targets
  232. Sub sw16_Hit:vpmTimer.PulseSw 16::Me.TimerEnabled = 1:PlaySound "target":End Sub
  233. Sub sw16_Timer::Me.TimerEnabled = 0:End Sub
  234. Sub sw93_Hit:vpmTimer.PulseSw 93:End Sub
  235. Sub sw930_Hit:vpmTimer.PulseSw 93:End Sub
  236. Sub sw94_Hit:vpmTimer.PulseSw 94:End Sub
  237. Sub sw95_Hit:vpmTimer.PulseSw 95:End Sub
  238. Sub sw950_Hit:vpmTimer.PulseSw 95:End Sub
  239. Sub sw96_Hit:vpmTimer.PulseSw 96:End Sub
  240. Sub sw97_Hit:vpmTimer.PulseSw 97:End Sub
  241. Sub sw970_Hit:vpmTimer.PulseSw 97:End Sub
  242. Sub sw103_Hit:vpmTimer.PulseSw 103:End Sub
  243. Sub sw1030_Hit:vpmTimer.PulseSw 103:End Sub
  244. Sub sw111_Hit:vpmTimer.PulseSw 111:End Sub
  245. Sub sw112_Hit:vpmTimer.PulseSw 112:End Sub
  246. Sub sw1120_Hit:vpmTimer.PulseSw 112:End Sub
  247. Sub sw113_Hit:vpmTimer.PulseSw 113:End Sub
  248. Sub sw114_Hit:vpmTimer.PulseSw 114:End Sub
  249. Sub sw1140_Hit:vpmTimer.PulseSw 114:End Sub
  250. Sub sw115_Hit:vpmTimer.PulseSw 115:End Sub
  251. Sub sw116_Hit:vpmTimer.PulseSw 116:End Sub
  252. Sub sw1160_Hit:vpmTimer.PulseSw 116:End Sub
  253. Sub sw117_Hit:vpmTimer.PulseSw 117:End Sub
  254. Sub sw1170_Hit:vpmTimer.PulseSw 117:End Sub
  255.  
  256. 'Ramp Triggers
  257. Sub sw80_Hit:Controller.Switch(80) = 1:PlaySound "Wire Ramp":End Sub
  258. Sub sw80_UnHit:Controller.Switch(80) = 0:End Sub
  259. Sub sw90_Hit:Controller.Switch(90) = 1:End Sub
  260. Sub sw90_UnHit:Controller.Switch(90) = 0:End Sub
  261.  
  262. ' Opto Sensors
  263. Sub sw100_Hit:Controller.Switch(100) = 1:End Sub
  264. Sub sw100_UnHit:Controller.Switch(100) = 0:End Sub
  265. Sub sw110_Hit:Controller.Switch(110) = 1:End Sub
  266. Sub sw110_UnHit:Controller.Switch(110) = 0:End Sub
  267.  
  268.  
  269. 'Generic Sounds
  270. Sub Trigger1_Hit:PlaySound "fx_ballrampdrop":StopSound "Wire Ramp":End Sub
  271. Sub Trigger2_Hit:StopSound "Wire Ramp":End Sub
  272. Sub Trigger3_Hit:PlaySound "Wire Ramp":End Sub
  273.  
  274. ' **************
  275. ' White Ball
  276. ' **************
  277.  
  278. Dim WBall
  279.  
  280. Sub CreateWhiteBall()
  281. Set WBall = kicker9.Createsizedball(55):WBall.Image = "CBallW":kicker9.Kick 0, 0
  282. WBall.X = 464
  283. WBall.Y = 1022
  284. 'WBall.CollisionMass = 1.7
  285. End Sub
  286.  
  287. Sub kicker9_UnHit() NewBallid:End Sub
  288.  
  289. Sub CaptiveHelp1_Hit
  290. If ActiveBall is WBall Then
  291. With ActiveBall
  292. .VelX = -.VelX / 3: .VelY = -.VelY / 3
  293. End With
  294. sw103_Hit
  295. End If
  296. End Sub
  297.  
  298. Sub CaptiveHelp2_Hit
  299. If ActiveBall is WBall Then
  300. With ActiveBall
  301. .VelX = -.VelX / 3: .VelY = -.VelY / 3
  302. End With
  303. sw1030_Hit
  304. End If
  305. End Sub
  306.  
  307. ' **************
  308. ' Black Ball
  309. ' **************
  310.  
  311. Dim Bball
  312.  
  313. Sub CreateBlackBall()
  314. Set BBall = kicker10.Createsizedball(55)
  315. BBall.Image = "CBallB"
  316. 'BBall.CollisionMass = 1.7
  317. kicker10.Kick 0, 0
  318. End Sub
  319.  
  320. '************************
  321. ' 8 Ball Platform Update
  322. '************************
  323.  
  324. ' Init 8 Ball Shooter Platform
  325.  
  326. Dim ShooterWalls1, ShooterWalls2, ShooterWalls3, ShooterPos, BallInShooter
  327.  
  328. ShooterWalls1 = Array(pl11, pl21, pl31, pl41, pl51, pl61, pl71, pl81, pl91, pl91)
  329. ShooterWalls2 = Array(pl12, pl22, pl32, pl42, pl52, pl62, pl72, pl82, pl92, pl92)
  330. ShooterWalls3 = Array(pl13, pl23, pl33, pl43, pl53, pl63, pl73, pl83, pl93, pl93)
  331.  
  332. vpmSolWall ShooterWalls1, 0, 1
  333. vpmSolWall ShooterWalls2, 0, 1
  334. vpmSolWall ShooterWalls3, 0, 1
  335.  
  336. Sub UpdateShooter(aNewPos, aSpeed, aLastPos)
  337. ShooterWalls1(aLastPos).IsDropped = 1
  338. ShooterWalls2(aLastPos).IsDropped = 1
  339. ShooterWalls3(aLastPos).IsDropped = 1
  340. ShooterWalls1(aNewPos).IsDropped = 0
  341. ShooterWalls2(aNewPos).IsDropped = 0
  342. ShooterWalls3(aNewPos).IsDropped = 0
  343. ShooterPos = aNewPos
  344. CheckBallInShooter
  345. End Sub
  346.  
  347. Sub SolShoot8Ball(Enabled)
  348. If Enabled AND BallInShooter Then
  349. Select Case ShooterPos
  350. Case 0:BBall.VelX = -8
  351. Case 1:BBall.VelX = -6
  352. Case 2:BBall.VelX = -4
  353. Case 3:BBall.VelX = -2
  354. Case 4:BBall.VelX = 0
  355. Case 5:BBall.VelX = 0
  356. Case 6:BBall.VelX = 2
  357. Case 7:BBall.VelX = 4
  358. Case 8:BBall.VelX = 6
  359. Case 9:BBall.VelX = 8
  360. End Select
  361.  
  362. playsound SoundFX("Popper",DOFContactors)
  363. BBall.VelY = 85
  364. End If
  365. End Sub
  366.  
  367. Sub SwShooter_Hit:BallInShooter = 1:End Sub
  368. Sub SwShooter_UnHit:BallInShooter = 0:End Sub
  369.  
  370. Sub CheckBallInShooter
  371. If BallInShooter Then
  372. Select Case ShooterPos
  373. Case 0:BBall.X = 432
  374. Case 1:BBall.X = 442
  375. Case 2:BBall.X = 452
  376. Case 3:BBall.X = 462
  377. Case 4:BBall.X = 472
  378. Case 5:BBall.X = 482
  379. Case 6:BBall.X = 492
  380. Case 7:BBall.X = 502
  381. Case 8:BBall.X = 512
  382. Case 9:BBall.X = 512
  383. End Select
  384. End If
  385. End Sub
  386.  
  387. '***************************************************
  388. ' JP's VP10 Fading Lamps & Flashers
  389. ' Based on PD's Fading Light System
  390. ' SetLamp 0 is Off
  391. ' SetLamp 1 is On
  392. ' fading for non opacity objects is 4 steps
  393. '***************************************************
  394.  
  395. Dim LampState(200), FadingLevel(200)
  396. Dim FlashSpeedUp(200), FlashSpeedDown(200), FlashMin(200), FlashMax(200), FlashLevel(200)
  397.  
  398. InitLamps() ' turn off the lights and flashers and reset them to the default parameters
  399. LampTimer.Interval = 5 'lamp fading speed
  400. LampTimer.Enabled = 1
  401.  
  402. ' Lamp & Flasher Timers
  403.  
  404. Sub LampTimer_Timer()
  405. Dim chgLamp, num, chg, ii
  406. chgLamp = Controller.ChangedLamps
  407. If Not IsEmpty(chgLamp) Then
  408. For ii = 0 To UBound(chgLamp)
  409. LampState(chgLamp(ii, 0) ) = chgLamp(ii, 1) 'keep the real state in an array
  410. FadingLevel(chgLamp(ii, 0) ) = chgLamp(ii, 1) + 4 'actual fading step
  411.  
  412. 'Special Handling
  413. 'If chgLamp(ii,0) = 2 Then solTrough chgLamp(ii,1)
  414. 'If chgLamp(ii,0) = 4 Then PFGI chgLamp(ii,1)
  415.  
  416. Next
  417. End If
  418. UpdateLamps
  419. End Sub
  420.  
  421. Sub UpdateLamps()
  422. NFadeL 0, l0
  423. NFadeObjm 2, p2, "bulbcover1_greenON", "bulbcover1_green"
  424. NFadeL 2, l2 'Apron LED
  425. NFadeObjm 3, p3, "bulbcover1_greenON", "bulbcover1_green"
  426. NFadeL 3, l3 'Apron LED
  427. NFadeObjm 4, p4, "bulbcover1_greenON", "bulbcover1_green"
  428. NFadeL 4, l4 'Apron LED
  429. NFadeObjm 5, p5, "bulbcover1_greenON", "bulbcover1_green"
  430. NFadeL 5, l5 'Apron LED
  431. NFadeObjm 6, p6, "bulbcover1_greenON", "bulbcover1_green"
  432. NFadeL 6, l6 'Apron LED
  433. NFadeObjm 7, p7, "bulbcover1_greenON", "bulbcover1_green"
  434. NFadeL 7, l7 'Apron LED
  435. NFadeL 10, L10 'Bumper 1
  436. NFadeL 10, L10a 'Bumper 1
  437. NFadeL 11, L11 'Bumper 2
  438. NFadeL 11, L11a 'Bumper 2
  439. NFadeObjm 12, p12, "bulbcover1_redON", "bulbcover1_red"
  440. NFadeL 12, l12 'Apron LED
  441. NFadeObjm 13, p13, "bulbcover1_redON", "bulbcover1_red"
  442. NFadeL 13, l13 'Apron LED
  443. NFadeObjm 14, p14, "bulbcover1_redON", "bulbcover1_red"
  444. NFadeL 14, l14 'Apron LED
  445. NFadeObjm 15, p15, "bulbcover1_redON", "bulbcover1_red"
  446. NFadeL 15, l15 'Apron LED
  447. NFadeObjm 16, p16, "bulbcover1_redON", "bulbcover1_red"
  448. NFadeL 16, l16 'Apron LED
  449. NFadeObjm 17, p17, "bulbcover1_redON", "bulbcover1_red"
  450. NFadeL 17, l17 'Apron LED
  451. NFadeL 20, l20
  452. NFadeL 21, l21
  453. NFadeL 22, l22
  454. NFadeL 23, l23
  455. NFadeL 24, l24
  456. NFadeL 25, l25
  457. NFadeL 26, l26
  458. NFadeL 27, l27
  459. NFadeL 30, l30
  460. NFadeL 31, l31
  461. NFadeL 32, l32
  462. NFadeL 33, l33
  463. NFadeL 34, l34
  464. NFadeL 35, l35
  465. NFadeL 36, l36
  466. NFadeL 37, l37
  467. NFadeL 40, l40
  468. NFadeL 41, l41
  469. NFadeL 42, l42
  470. NFadeL 43, l43
  471. NFadeL 44, l44
  472. NFadeL 45, l45
  473. NFadeL 46, l46
  474. NFadeL 47, l47
  475. NFadeL 50, l50
  476. NFadeL 51, l51
  477. NFadeL 52, l52
  478. NFadeL 53, l53
  479. NFadeL 54, l54
  480. NFadeL 55, l55
  481. NFadeL 56, l56
  482. NFadeL 57, l57
  483. NFadeL 60, l60
  484. NFadeL 61, l61
  485. NFadeL 62, l62
  486. NFadeL 63, l63
  487. NFadeL 64, l64
  488. NFadeL 65, l65
  489. NFadeL 66, l66
  490. NFadeL 67, l67
  491. NFadeL 70, l70
  492. NFadeL 71, l71
  493. NFadeL 72, l72
  494. NFadeL 73, l73
  495. NFadeL 74, l74
  496. NFadeL 75, l75
  497. NFadeL 76, l76
  498. NFadeL 77, l77
  499. NFadeL 80, l80
  500. NFadeL 81, l81
  501. NFadeL 82, l82
  502. NFadeL 83, l83
  503. NFadeL 84, l84
  504. NFadeL 85, l85
  505. NFadeL 86, l86
  506. NFadeL 87, l87
  507. NFadeObjm 90, p90, "bulbcover1_redON", "bulbcover1_red"
  508. Flash 90, F90 'LED
  509. NFadeObjm 91, p91, "bulbcover1_redON", "bulbcover1_red"
  510. Flash 91, F91 'LED
  511. NFadeL 92, l92
  512. NFadeL 93, l93
  513. NFadeL 94, l94
  514. NFadeL 95, l95
  515. NFadeL 96, l96
  516. NFadeL 97, l97
  517. NFadeL 100, l100
  518. NFadeL 101, l101
  519. NFadeL 102, l102
  520. NFadeL 103, l103
  521. NFadeL 104, l104
  522. NFadeL 105, l105
  523. NFadeL 106, l106
  524. NFadeL 107, l107
  525. NFadeL 110, l110
  526. NFadeL 111, l111
  527. NFadeL 112, l112
  528. NFadeL 113, l113
  529. NFadeL 114, l114
  530. NFadeL 115, l115
  531. NFadeL 116, l116
  532. NFadeL 117, l117
  533.  
  534. ' Solenoid Controlled
  535. NFadeObjm 151, p151a, "dome2_0_clearON", "dome2_0_clear" 'Dome
  536. NFadeObjm 151, p151b, "dome2_0_clearON", "dome2_0_clear" 'Dome
  537. NFadeObjm 151, p151c, "dome2_0_clearON", "dome2_0_clear" 'Dome
  538. NFadeObjm 151, p151d, "dome2_0_clearON", "dome2_0_clear" 'Dome
  539. Flashm 151, f151a
  540. Flashm 151, f151b
  541. Flashm 151, f151c
  542. Flash 151, f151d
  543.  
  544. NFadeObjm 152, p152a, "dome2_0_clearON", "dome2_0_clear" 'Dome
  545. NFadeObjm 152, p152b, "dome2_0_clearON", "dome2_0_clear" 'Dome
  546. NFadeObjm 152, p152c, "dome2_0_clearON", "dome2_0_clear" 'Dome
  547. NFadeObjm 152, p152d, "dome2_0_clearON", "dome2_0_clear" 'Dome
  548. Flashm 152, f152a
  549. Flashm 152, f152b
  550. Flashm 152, f152c
  551. Flash 152, f152d
  552.  
  553. NFadeObjm 153, P153, "dome2_0_yellowON", "dome2_0_yellow" 'Dome
  554. Flash 153, f153
  555.  
  556. NFadeObjm 154, P154, "dome2_0_blueON", "dome2_0_blue" 'Dome
  557. Flash 154, f154
  558.  
  559. NFadeObjm 155, P155, "dome2_0_redON", "dome2_0_red" 'Dome
  560. Flash 155, f155
  561.  
  562. NFadeObjm 156, f156, "dome2_0_clearON", "dome2_0_clear" 'Dome
  563. NFadeL 156, F156
  564.  
  565. NFadeObjm 157, P157, "dome2_0_clearON", "dome2_0_clear" 'Dome
  566. NFadeL 157, F157
  567.  
  568. End Sub
  569.  
  570. ' div lamp subs
  571.  
  572. Sub InitLamps()
  573. Dim x
  574. For x = 0 to 200
  575. LampState(x) = 0 ' current light state, independent of the fading level. 0 is off and 1 is on
  576. FadingLevel(x) = 4 ' used to track the fading state
  577. FlashSpeedUp(x) = 0.4 ' faster speed when turning on the flasher
  578. FlashSpeedDown(x) = 0.2 ' slower speed when turning off the flasher
  579. FlashMax(x) = 1 ' the maximum value when on, usually 1
  580. FlashMin(x) = 0 ' the minimum value when off, usually 0
  581. FlashLevel(x) = 0 ' the intensity of the flashers, usually from 0 to 1
  582. Next
  583. End Sub
  584.  
  585. Sub AllLampsOff
  586. Dim x
  587. For x = 0 to 200
  588. SetLamp x, 0
  589. Next
  590. End Sub
  591.  
  592. Sub SetLamp(nr, value)
  593. If value <> LampState(nr) Then
  594. LampState(nr) = abs(value)
  595. FadingLevel(nr) = abs(value) + 4
  596. End If
  597. End Sub
  598.  
  599. ' Lights: used for VP10 standard lights, the fading is handled by VP itself
  600.  
  601. Sub NFadeL(nr, object)
  602. Select Case FadingLevel(nr)
  603. Case 4:object.state = 0:FadingLevel(nr) = 0
  604. Case 5:object.state = 1:FadingLevel(nr) = 1
  605. End Select
  606. End Sub
  607.  
  608. Sub NFadeLm(nr, object) ' used for multiple lights
  609. Select Case FadingLevel(nr)
  610. Case 4:object.state = 0
  611. Case 5:object.state = 1
  612. End Select
  613. End Sub
  614.  
  615. 'Lights, Ramps & Primitives used as 4 step fading lights
  616. 'a,b,c,d are the images used from on to off
  617.  
  618. Sub FadeObj(nr, object, a, b, c, d)
  619. Select Case FadingLevel(nr)
  620. Case 4:object.image = b:FadingLevel(nr) = 6 'fading to off...
  621. Case 5:object.image = a:FadingLevel(nr) = 1 'ON
  622. Case 6, 7, 8:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  623. Case 9:object.image = c:FadingLevel(nr) = FadingLevel(nr) + 1 'fading...
  624. Case 10, 11, 12:FadingLevel(nr) = FadingLevel(nr) + 1 'wait
  625. Case 13:object.image = d:FadingLevel(nr) = 0 'Off
  626. End Select
  627. End Sub
  628.  
  629. Sub FadeObjm(nr, object, a, b, c, d)
  630. Select Case FadingLevel(nr)
  631. Case 4:object.image = b
  632. Case 5:object.image = a
  633. Case 9:object.image = c
  634. Case 13:object.image = d
  635. End Select
  636. End Sub
  637.  
  638. Sub NFadeObj(nr, object, a, b)
  639. Select Case FadingLevel(nr)
  640. Case 4:object.image = b:FadingLevel(nr) = 0 'off
  641. Case 5:object.image = a:FadingLevel(nr) = 1 'on
  642. End Select
  643. End Sub
  644.  
  645. Sub NFadeObjm(nr, object, a, b)
  646. Select Case FadingLevel(nr)
  647. Case 4:object.image = b
  648. Case 5:object.image = a
  649. End Select
  650. End Sub
  651.  
  652. ' Flasher objects
  653.  
  654. Sub Flash(nr, object)
  655. Select Case FadingLevel(nr)
  656. Case 4 'off
  657. FlashLevel(nr) = FlashLevel(nr) - FlashSpeedDown(nr)
  658. If FlashLevel(nr) < FlashMin(nr) Then
  659. FlashLevel(nr) = FlashMin(nr)
  660. FadingLevel(nr) = 0 'completely off
  661. End if
  662. Object.IntensityScale = FlashLevel(nr)
  663. Case 5 ' on
  664. FlashLevel(nr) = FlashLevel(nr) + FlashSpeedUp(nr)
  665. If FlashLevel(nr) > FlashMax(nr) Then
  666. FlashLevel(nr) = FlashMax(nr)
  667. FadingLevel(nr) = 1 'completely on
  668. End if
  669. Object.IntensityScale = FlashLevel(nr)
  670. End Select
  671. End Sub
  672.  
  673. Sub Flashm(nr, object) 'multiple flashers, it just sets the flashlevel
  674. Object.IntensityScale = FlashLevel(nr)
  675. End Sub
  676.  
  677. '**********Sling Shot Animations
  678. ' Rstep and Lstep are the variables that increment the animation
  679. '****************
  680. Dim RStep, Lstep
  681.  
  682. Sub RightSlingShot_Slingshot
  683. vpmTimer.PulseSw 15
  684. PlaySound SoundFX("right_slingshot",DOFContactors), 0,1, 0.05,0.05 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  685. RSling.Visible = 0
  686. RSling1.Visible = 1
  687. sling1.rotx = 20
  688. RStep = 0
  689. RightSlingShot.TimerEnabled = 1
  690. End Sub
  691.  
  692. Sub RightSlingShot_Timer
  693. Select Case RStep
  694. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  695. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0
  696. End Select
  697. RStep = RStep + 1
  698. End Sub
  699.  
  700. Sub LeftSlingShot_Slingshot
  701. vpmTimer.PulseSw 14
  702. PlaySound SoundFX("left_slingshot",DOFContactors), 0,1, -0.05,0.05 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  703. LSling.Visible = 0
  704. LSling1.Visible = 1
  705. sling2.rotx = 20
  706. LStep = 0
  707. LeftSlingShot.TimerEnabled = 1
  708. End Sub
  709.  
  710. Sub LeftSlingShot_Timer
  711. Select Case LStep
  712. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  713. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0
  714. End Select
  715. LStep = LStep + 1
  716. End Sub
  717.  
  718.  
  719. '*********************************************************************
  720. ' Positional Sound Playback Functions
  721. '*********************************************************************
  722.  
  723. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  724. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  725. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  726. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  727. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  728. End Sub
  729.  
  730. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  731. Sub PlaySoundAt(soundname, tableobj)
  732. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  733. End Sub
  734.  
  735. Sub PlaySoundAtBall(soundname)
  736. PlaySoundAt soundname, ActiveBall
  737. End Sub
  738.  
  739.  
  740. '*********************************************************************
  741. ' Supporting Ball & Sound Functions
  742. '*********************************************************************
  743.  
  744. 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
  745. Dim tmp
  746. tmp = tableobj.y * 2 / table1.height-1
  747. If tmp > 0 Then
  748. AudioFade = Csng(tmp ^10)
  749. Else
  750. AudioFade = Csng(-((- tmp) ^10) )
  751. End If
  752. End Function
  753.  
  754. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  755. Dim tmp
  756. tmp = tableobj.x * 2 / table1.width-1
  757. If tmp > 0 Then
  758. AudioPan = Csng(tmp ^10)
  759. Else
  760. AudioPan = Csng(-((- tmp) ^10) )
  761. End If
  762. End Function
  763.  
  764. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  765. Vol = Csng(BallVel(ball) ^2 / 2000)
  766. End Function
  767.  
  768. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  769. Pitch = BallVel(ball) * 20
  770. End Function
  771.  
  772. Function BallVel(ball) 'Calculates the ball speed
  773. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  774. End Function
  775.  
  776.  
  777.  
  778. '*****************************************
  779. ' JP's VP10 Rolling Sounds
  780. '*****************************************
  781.  
  782. Const tnob = 5 ' total number of balls
  783. ReDim rolling(tnob)
  784. InitRolling
  785.  
  786. Sub InitRolling
  787. Dim i
  788. For i = 0 to tnob
  789. rolling(i) = False
  790. Next
  791. End Sub
  792.  
  793. Sub RollingTimer_Timer()
  794. Dim BOT, b
  795. BOT = GetBalls
  796.  
  797. ' stop the sound of deleted balls
  798. For b = UBound(BOT) + 1 to tnob
  799. rolling(b) = False
  800. StopSound("fx_ballrolling" & b)
  801. Next
  802.  
  803. ' exit the sub if no balls on the table
  804. If UBound(BOT) = -1 Then Exit Sub
  805.  
  806. ' play the rolling sound for each ball
  807. For b = 0 to UBound(BOT)
  808. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  809. rolling(b) = True
  810. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  811. Else
  812. If rolling(b) = True Then
  813. StopSound("fx_ballrolling" & b)
  814. rolling(b) = False
  815. End If
  816. End If
  817. Next
  818. End Sub
  819.  
  820. '**********************
  821. ' Ball Collision Sound
  822. '**********************
  823.  
  824. Sub OnBallBallCollision(ball1, ball2, velocity)
  825. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  826. End Sub
  827.  
  828.  
  829. '*****************************************
  830. ' ninuzzu's FLIPPER SHADOWS
  831. '*****************************************
  832.  
  833. sub FlipperTimer_Timer()
  834. FlipperLSh.RotZ = LeftFlipper.currentangle
  835. FlipperRSh.RotZ = RightFlipper.currentangle
  836. LeftFlipperP.objRotZ = LeftFlipper.CurrentAngle-90
  837. RightFlipperP.objRotZ = RightFlipper.CurrentAngle-90
  838. End Sub
  839.  
  840. '*****************************************
  841. ' ninuzzu's BALL SHADOW
  842. '*****************************************
  843. Dim BallShadow
  844. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  845.  
  846. Sub BallShadowUpdate_timer()
  847. Dim BOT, b
  848. BOT = GetBalls
  849. ' hide shadow of deleted balls
  850. If UBound(BOT)<(tnob-1) Then
  851. For b = (UBound(BOT) + 1) to (tnob-1)
  852. BallShadow(b).visible = 0
  853. Next
  854. End If
  855. ' exit the Sub if no balls on the table
  856. If UBound(BOT) = -1 Then Exit Sub
  857. ' render the shadow for each ball
  858. For b = 0 to UBound(BOT)
  859. If BOT(b).X < Table1.Width/2 Then
  860. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  861. Else
  862. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  863. End If
  864. ballShadow(b).Y = BOT(b).Y + 12
  865. If BOT(b).Z > 20 Then
  866. BallShadow(b).visible = 1
  867. Else
  868. BallShadow(b).visible = 0
  869. End If
  870. Next
  871. End Sub
  872.  
  873.  
  874.  
  875. '************************************
  876. ' What you need to add to your table
  877. '************************************
  878.  
  879. ' a timer called RollingTimer. With a fast interval, like 10
  880. ' one collision sound, in this script is called fx_collide
  881. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  882. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  883.  
  884.  
  885. '******************************************
  886. ' Explanation of the rolling sound routine
  887. '******************************************
  888.  
  889. ' sounds are played based on the ball speed and position
  890.  
  891. ' the routine checks first for deleted balls and stops the rolling sound.
  892.  
  893. ' The For loop goes through all the balls on the table and checks for the ball speed and
  894. ' if the ball is on the table (height lower than 30) then then it plays the sound
  895. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  896.  
  897. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  898. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  899. ' according to the position of the ball on the table.
  900.  
  901.  
  902. '**************************************
  903. ' Explanation of the collision routine
  904. '**************************************
  905.  
  906. ' The collision is built in VP.
  907. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  908. ' 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
  909. ' depending of the speed of the collision.
  910.  
  911.  
  912. Sub Pins_Hit (idx)
  913. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  914. End Sub
  915.  
  916. Sub Targets_Hit (idx)
  917. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  918. End Sub
  919.  
  920. Sub Metals_Thin_Hit (idx)
  921. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  922. End Sub
  923.  
  924. Sub Metals_Medium_Hit (idx)
  925. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  926. End Sub
  927.  
  928. Sub Metals2_Hit (idx)
  929. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  930. End Sub
  931.  
  932. Sub Gates_Hit (idx)
  933. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  934. End Sub
  935.  
  936. Sub Spinner_Spin
  937. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  938. End Sub
  939.  
  940. Sub Rubbers_Hit(idx)
  941. dim finalspeed
  942. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  943. If finalspeed > 20 then
  944. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  945. End if
  946. If finalspeed >= 6 AND finalspeed <= 20 then
  947. RandomSoundRubber()
  948. End If
  949. End Sub
  950.  
  951. Sub Posts_Hit(idx)
  952. dim finalspeed
  953. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  954. If finalspeed > 16 then
  955. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  956. End if
  957. If finalspeed >= 6 AND finalspeed <= 16 then
  958. RandomSoundRubber()
  959. End If
  960. End Sub
  961.  
  962. Sub RandomSoundRubber()
  963. Select Case Int(Rnd*3)+1
  964. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  965. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  966. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  967. End Select
  968. End Sub
  969.  
  970. Sub LeftFlipper_Collide(parm)
  971. RandomSoundFlipper()
  972. End Sub
  973.  
  974. Sub RightFlipper_Collide(parm)
  975. RandomSoundFlipper()
  976. End Sub
  977.  
  978. Sub RandomSoundFlipper()
  979. Select Case Int(Rnd*3)+1
  980. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  981. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  982. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  983. End Select
  984. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement