Arngrim

Arena

Jan 8th, 2021
239
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.85 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 BallSize = 50 ' sets the ball size
  10. Const BallMass = 1.8 ' sets the ball mass
  11.  
  12. LoadVPM "01560000","SYS80.VBS",3.2
  13.  
  14. Const cgamename = "arena", UseSolenoids=2,UseLamps=1,SCoin="coin3"
  15.  
  16. Dim DesktopMode: DesktopMode = Table1.ShowDT
  17. If DesktopMode = True Then 'Show Desktop components
  18. Ramp001.visible=1
  19. Ramp002.visible=1
  20. Primitive019.visible=1
  21. Else
  22. Ramp001.visible=0
  23. Ramp002.visible=0
  24. Primitive019.visible=0
  25. End if
  26.  
  27. '*************************************************************
  28. 'Solenoid Call backs
  29. '**********************************************************************************************************
  30.  
  31. SolCallback(1) = "Sol1" 'Light left backdrop skull F1
  32. SolCallback(2) = "DropTargetBank.soldropup"
  33. SolCallback(3) = "Sol3" 'Light right backdrop skull F3
  34. SolCallback(4) = "Sol4" 'Ramp entrance Flasher F4
  35. SolCallback(5) = "bsSecondKicker.solout"
  36. SolCallback(6) = "bsFirstkicker.solout"
  37. SolCallback(7) = "Sol7" 'Ramp made Flasher F7
  38. SolCallback(8) = "vpmSolSound SoundFX(""Knocker"",DOFKnocker)," 'Knocker
  39. SolCallback(9) = "bsTrough.SolIn"
  40. SolCallback(10)= "Sol10" 'GameOn
  41.  
  42. SolCallback(sLRFlipper) = "SolRFlipper"
  43. SolCallback(sLLFlipper) = "SolLFlipper"
  44.  
  45. Sub SolLFlipper(Enabled)
  46. If Enabled Then
  47. PlaySound SoundFX("flipperup",DOFFlippers):LeftFlipper.RotateToEnd
  48. Else
  49. PlaySound SoundFX("flipperdown",DOFFlippers):LeftFlipper.RotateToStart
  50. End If
  51. End Sub
  52.  
  53. Sub SolRFlipper(Enabled)
  54. If Enabled Then
  55. PlaySound SoundFX("flipperup",DOFFlippers):RightFlipper.RotateToEnd
  56. Else
  57. PlaySound SoundFX("flipperdown",DOFFlippers):RightFlipper.RotateToStart
  58. End If
  59. End Sub
  60.  
  61.  
  62. '**********************************************************************************************************
  63. 'Solenoid Controlled toys
  64. '**********************************************************************************************************
  65.  
  66. Sub Sol1(enabled)
  67. if enabled then
  68. F1a.state=1
  69. ' F1b.state=1
  70. playsound "fx_relay"
  71. else
  72. F1a.state=0
  73. ' F1b.state=0
  74. end if
  75. End Sub
  76.  
  77. Sub Sol3(enabled)
  78. if enabled then
  79. F3a.state=1
  80. ' F3b.state=1
  81. playsound "fx_relay"
  82. else
  83. F3a.state=0
  84. ' F3b.state=0
  85. end if
  86. End Sub
  87.  
  88. Sub Sol4(enabled)
  89. if enabled then
  90. F4a.state=1
  91. F4b.state=1
  92. playsound "fx_relay"
  93. else
  94. F4a.state=0
  95. F4b.state=0
  96. end if
  97. End Sub
  98.  
  99. Sub Sol7(enabled)
  100. if enabled then
  101. F7a.state=1
  102. F7b.state=1
  103. playsound "fx_relay"
  104. else
  105. F7a.state=0
  106. F7b.state=0
  107. end if
  108. End Sub
  109.  
  110. Dim FlipperActive
  111. Sub Sol10(enabled)
  112. FlipperActive = Enabled
  113. End Sub
  114.  
  115. 'Playfield GI
  116. '*****GI Lights On
  117. dim xx
  118. For each xx in GI:xx.State = 1: Next
  119.  
  120. '**********************************************************************************************************
  121. 'Initiate Table
  122. '**********************************************************************************************************
  123.  
  124. Dim bsTrough,bsFirstKicker,bsSecondKicker,DropTargetBank,obj
  125. '
  126. Sub Table1_Init
  127. vpmInit Me
  128. On Error Resume Next
  129. With Controller
  130. .GameName = cGameName
  131. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  132. .SplashInfoLine = "Sega Viper Night Drivin'"&chr(13)&"You Suck"
  133. .HandleMechanics=0
  134. .HandleKeyboard=0
  135. .ShowDMDOnly=1
  136. .ShowFrame=0
  137. .ShowTitle=0
  138. .hidden = 0
  139. .Games(cGameName).Settings.Value("sound")=1
  140. '.PuPHide = 1
  141. On Error Resume Next
  142. .Run GetPlayerHWnd
  143. If Err Then MsgBox Err.Description
  144. On Error Goto 0
  145. End With
  146. On Error Goto 0
  147.  
  148. PinMAMETimer.Interval=PinMAMEInterval
  149. PinMAMETimer.Enabled= true
  150.  
  151. vpmNudge.TiltSwitch=57
  152. vpmNudge.Sensitivity=5
  153. vpmNudge.TiltObj=Array(LeftslingShot,RightslingShot)
  154.  
  155. Set bsTrough=New cvpmBallStack
  156. bsTrough.InitSw 66,0,0,20,0,0,0,0
  157. bsTrough.Balls=3
  158. bsTrough.initkick BallRelease,90,5
  159. bsTrough.InitExitSnd SoundFX("BallRel",DOFContactors),SoundFX("Solenoid",DOFContactors)
  160.  
  161. Set bsFirstKicker=New cvpmBallStack
  162. bsFirstKicker.InitSaucer Kicker21,21,120,5
  163. bsFirstKicker.InitExitSnd SoundFX("Kicker",DOFContactors),SoundFX("solon",DOFContactors)
  164.  
  165. Set bsSecondKicker=New cvpmBallStack
  166. bsSecondKicker.InitSaucer Kicker31,31,120,5
  167. bsSecondKicker.InitExitSnd SoundFX("Kicker",DOFContactors),SoundFX("solon",DOFContactors)
  168.  
  169. Set DropTargetBank=New cvpmDropTarget
  170. DropTargetBank.InitDrop array(DT40,DT50,DT60,DT70), Array(40,50,60,70)
  171. DropTargetBank.InitSnd SoundFX("Targetdrop1",DOFDropTargets),SoundFX("TargetBankreset1",DOFContactors)
  172. DropTargetBank.CreateEvents "DropTargetBank"
  173.  
  174. vpmMapLights AllLights
  175.  
  176. End Sub
  177.  
  178. Sub Table1_Exit()
  179. Controller.Pause = False
  180. Controller.Stop
  181. End Sub
  182.  
  183.  
  184. '**********************************************************************************************************
  185. 'Plunger code
  186. '**********************************************************************************************************
  187.  
  188.  
  189. Sub Table1_KeyDown(ByVal KeyCode)
  190. If keycode = LeftMagnaSave Then bLutActive = True
  191. If keycode = RightMagnaSave Then
  192. If bLutActive Then NextLUT: End If
  193. End If
  194. If KeyCode=LeftFlipperKey Then
  195. Controller.Switch(6)=1
  196. if FlipperActive then
  197. end if
  198. end if
  199. If KeyCode=RightFlipperKey Then
  200. Controller.Switch(16)=1
  201. Controller.Switch(45)=1
  202. if FlipperActive then
  203. end if
  204. end if
  205. If vpmKeyDown(KeyCode) Then Exit Sub
  206. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  207. End Sub
  208.  
  209. Sub Table1_KeyUp(ByVal KeyCode)
  210. If keycode = LeftMagnaSave Then bLutActive = False
  211. If KeyCode=LeftFlipperKey Then
  212. Controller.Switch(6)=0
  213. if FlipperActive then
  214. end if
  215. end if
  216. If KeyCode=RightFlipperKey Then
  217. Controller.Switch(16)=0
  218. Controller.Switch(45)=0
  219. if FlipperActive then
  220. end if
  221. end if
  222. If vpmKeyUp(KeyCode) Then Exit Sub
  223. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  224. End Sub
  225.  
  226. '**********************************************************************************************************
  227. ' Drain hole and kickers
  228. '**********************************************************************************************************
  229.  
  230. Sub Drain_Hit:bsTrough.AddBall Me :playsound"drain5" : End Sub
  231.  
  232. '------------------------------
  233. '------ Switch Handler ------
  234. '------------------------------
  235.  
  236. Sub Kicker21_hit:bsFirstKicker.addball me:End Sub
  237. Sub Kicker31_hit:bsSecondKicker.addball me:End Sub
  238.  
  239. '------------------------------
  240. '------ Gates & Spinner ------
  241. '------------------------------
  242.  
  243. sub Trigger34_hit:Controller.Switch(34)=1:PlaySound "Gate5",0,0.1,-0.05,0.1:End Sub
  244. sub Gate4_hit:PlaySound "Gate5",0,0.1,-0.05,0.1:End Sub
  245. sub Gate5_hit:PlaySound "Gate5",0,0.1,-0.05,0.1:End Sub
  246.  
  247. Sub Spinner24_Spin:vpmTimer.PulseSwitch 24,0,0:playsound "fx_spinner",0,0.1,-0.1,0.1:End Sub
  248.  
  249. '------------------------------
  250. '------ Wire Triggers ------
  251. '------------------------------
  252.  
  253. sub Trigger30_hit:Controller.Switch(30)=1:PlaySound "rollover",0,0.1,-0.08,0.1:End Sub
  254. sub Trigger30_unhit:Controller.Switch(30)=0:End Sub
  255.  
  256. sub Trigger22_hit:Controller.Switch(22)=1:PlaySound "rollover",0,0.1,-0.18,0.1:End Sub
  257. sub Trigger22_unhit:Controller.Switch(22)=0:End Sub
  258. sub Trigger32_hit:Controller.Switch(32)=1:PlaySound "rollover",0,0.1,-0.15,0.1:End Sub
  259. sub Trigger32_unhit:Controller.Switch(32)=0:End Sub
  260. sub Trigger42_hit:Controller.Switch(42)=1:PlaySound "rollover",0,0.1,-0.12,0.1:End Sub
  261. sub Trigger42_unhit:Controller.Switch(42)=0:End Sub
  262.  
  263. sub Trigger41_hit:Controller.Switch(41)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  264. sub Trigger41_unhit:Controller.Switch(41)=0:End Sub
  265. sub Trigger51_hit:Controller.Switch(51)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  266. sub Trigger51_unhit:Controller.Switch(51)=0:End Sub
  267. sub Trigger61_hit:Controller.Switch(61)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  268. sub Trigger61_unhit:Controller.Switch(61)=0:End Sub
  269. sub Trigger71_hit:Controller.Switch(71)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  270. sub Trigger71_unhit:Controller.Switch(71)=0:End Sub
  271.  
  272. sub Trigger44_hit:Controller.Switch(44)=1:PlaySound "rollover",0,0.1,-0.05,0.1:End Sub
  273. sub Trigger44_unhit:Controller.Switch(44)=0:End Sub
  274.  
  275. sub Trigger55_hit:Controller.Switch(55)=1:PlaySound "rollover",0,0.1,0.15,0.1:End Sub
  276. sub Trigger55_unhit:Controller.Switch(55)=0:End Sub
  277. sub Trigger54_hit:Controller.Switch(54)=1:PlaySound "rollover",0,0.1,-0.18,0.1:End Sub
  278. sub Trigger54_unhit:Controller.Switch(54)=0:End Sub
  279.  
  280. sub Trigger74_hit:Controller.Switch(74)=1:PlaySound "rollover",0,0.1,-0.18,0.1:End Sub
  281. sub Trigger74_unhit:Controller.Switch(74)=0:End Sub
  282. sub Trigger64_hit:Controller.Switch(64)=1:PlaySound "rollover",0,0.1,-0.16,0.1:End Sub
  283. sub Trigger64_unhit:Controller.Switch(64)=0:End Sub
  284.  
  285. sub Trigger65_hit:Controller.Switch(65)=1:PlaySound "rollover",0,0.1,0.12,0.1:End Sub
  286. sub Trigger65_unhit:Controller.Switch(65)=0:End Sub
  287. sub Trigger75_hit:Controller.Switch(75)=1:PlaySound "rollover",0,0.1,0.15,0.1:End Sub
  288. sub Trigger75_unhit:Controller.Switch(75)=0:End Sub
  289.  
  290. '------------------------------
  291. '------ Drop Targets ------
  292. '------------------------------
  293.  
  294. Sub DT40_Hit:DropTargetBank.Hit 1:End Sub '40
  295. Sub DT50_Hit:DropTargetBank.Hit 2:End Sub '50
  296. Sub DT60_Hit:DropTargetBank.Hit 3:End Sub '60
  297. Sub DT70_Hit:DropTargetBank.Hit 4:End Sub '70
  298.  
  299. '------------------------------
  300. '------ Stand Up Targets ------
  301. '------------------------------
  302.  
  303. Sub Target23_Hit:vpmTimer.PulseSw 23:PlaySound SoundFX("Target1",DOFTargets),0,1,0.02,0.25:End Sub
  304. Sub Target33_Hit:vpmTimer.PulseSw 33:PlaySound SoundFX("Target1",DOFTargets),0,1,0.05,0.25:End Sub
  305. Sub Target43_Hit:vpmTimer.PulseSw 43:PlaySound SoundFX("Target1",DOFTargets),0,1,0.08,0.25:End Sub
  306.  
  307. Sub Target53_Hit:vpmTimer.PulseSw 53:PlaySound SoundFX("Target1",DOFTargets),0,1,0.12,0.25:End Sub
  308. Sub Target63_Hit:vpmTimer.PulseSw 63:PlaySound SoundFX("Target1",DOFTargets),0,1,0.12,0.25:End Sub
  309. Sub Target73_Hit:vpmTimer.PulseSw 73:PlaySound SoundFX("Target1",DOFTargets),0,1,0.12,0.25:End Sub
  310.  
  311. Sub Target52_Hit:vpmTimer.PulseSw 52:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.25:End Sub
  312. Sub Target62_Hit:vpmTimer.PulseSw 62:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.25:End Sub
  313. Sub Target72_Hit:vpmTimer.PulseSw 72:PlaySound SoundFX("Target1",DOFTargets),0,1,-0.15,0.25:End Sub
  314.  
  315. '**********Sling Shot Animations
  316. ' Rstep and Lstep are the variables that increment the animation
  317. '****************
  318.  
  319. Dim RStep, Lstep
  320.  
  321. Sub RightSlingShot_Slingshot
  322. vpmTimer.PulseSw 25
  323. DOF 102, DOFPulse
  324. PlaySound SoundFX("RSling",DOFContactors), 0,1,0.15,0.1 '0,1, AudioPan(RightSlingShot), 0.05,0,0,1,AudioFade(RightSlingShot)
  325. RSling.Visible = 0
  326. RSling1.Visible = 1
  327. sling1.rotx = 20
  328. RStep = 0
  329. RightSlingShot.TimerEnabled = 1
  330. ' gi1.State = 0:Gi2.State = 0
  331. End Sub
  332.  
  333. Sub RightSlingShot_Timer
  334. Select Case RStep
  335. Case 3:RSLing1.Visible = 0:RSLing2.Visible = 1:sling1.rotx = 10
  336. Case 4:RSLing2.Visible = 0:RSLing.Visible = 1:sling1.rotx = 0:RightSlingShot.TimerEnabled = 0:
  337. End Select
  338. RStep = RStep + 1
  339. End Sub
  340.  
  341. Sub LeftSlingShot_Slingshot
  342. vpmTimer.PulseSw 25
  343. DOF 101, DOFPulse
  344. PlaySound SoundFX("LSling",DOFContactors), 0,1,-0.16,0.1 '0,1, AudioPan(LeftSlingShot), 0.05,0,0,1,AudioFade(LeftSlingShot)
  345. LSling.Visible = 0
  346. LSling1.Visible = 1
  347. sling2.rotx = 20
  348. LStep = 0
  349. LeftSlingShot.TimerEnabled = 1
  350. ' gi3.State = 0:Gi4.State = 0
  351. End Sub
  352.  
  353. Sub LeftSlingShot_Timer
  354. Select Case LStep
  355. Case 3:LSLing1.Visible = 0:LSLing2.Visible = 1:sling2.rotx = 10
  356. Case 4:LSLing2.Visible = 0:LSLing.Visible = 1:sling2.rotx = 0:LeftSlingShot.TimerEnabled = 0:
  357. End Select
  358. LStep = LStep + 1
  359. End Sub
  360.  
  361.  
  362. '--------------------------------
  363. '------ Helper Functions ------
  364. '--------------------------------
  365. 'Ramp running Light
  366. Dim LSPos1,LSPos2,LSPos3,LSPos4
  367. LSPos1 = 0
  368. LSPos2 = 3
  369. LSPos3 = 6
  370. LSPos4 = 9
  371.  
  372. Sub LightSeqTimer_Timer
  373. LS(LSPos1).state = 0
  374. LS(LSPos2).state = 0
  375. LS(LSPos3).state = 0
  376. LS(LSPos4).state = 0
  377.  
  378. LSPos1 = LSPos1 + 1
  379. LSPos2 = LSPos2 + 1
  380. LSPos3 = LSPos3 + 1
  381. LSPos4 = LSPos4 + 1
  382.  
  383. if LSPos1 > 9 then
  384. LSPos1 = 0
  385. end if
  386. if LSPos2 > 9 then
  387. LSPos2 = 0
  388. end if
  389. if LSPos3 > 9 then
  390. LSPos3 = 0
  391. end if
  392. if LSPos4 > 9 then
  393. LSPos4 = 0
  394. end if
  395.  
  396. LS(LSPos1).state = 1
  397. LS(LSPos2).state = 1
  398. LS(LSPos3).state = 1
  399. LS(LSPos4).state = 1
  400. End Sub
  401.  
  402.  
  403. 'Lamp Callback for Ball Release and Ballsaver
  404. Dim O12,OL12,O13,OL13,O14,OL14
  405. O12=0:OL12=0:O13=0:OL13=0:O14=0:OL14=0
  406.  
  407. Sub LampTimer_Timer
  408. if Controller.Lamp(17) <> 0 then
  409. LightSeqTimer.enabled = True
  410. else
  411. LightSeqTimer.enabled = False
  412. LS(LSPos1).state = 0
  413. LS(LSPos2).state = 0
  414. LS(LSPos3).state = 0
  415. LS(LSPos4).state = 0
  416. end if
  417.  
  418. O12=Controller.Lamp(12)
  419. If OL12<>O12 Then
  420. If O12=0 Then bsTrough.ExitSol_On
  421. End If
  422. OL12=O12
  423. O13=Controller.Lamp(13)
  424. If OL13<>O13 Then
  425. If (O13=0) and (O14=0) Then
  426. RightInlaneGate1.RotateToStart
  427. RightInlaneGate2.RotateToStart
  428. Controller.Switch(35)=0
  429. Else
  430. RightInlaneGate1.RotateToEnd
  431. RightInlaneGate2.RotateToEnd
  432. Controller.Switch(35)=1
  433. End If
  434. End If
  435. OL13=O13
  436. O14=Controller.Lamp(14)
  437. If OL14<>O14 Then
  438. If O14=0 Then
  439. RightOutlaneGate1.RotateToStart
  440. RightOutlaneGate2.RotateToStart
  441. Else
  442. RightOutlaneGate1.RotateToEnd
  443. RightOutlaneGate2.RotateToEnd
  444. End If
  445. End If
  446. OL14=O14
  447.  
  448. End Sub
  449.  
  450.  
  451. '---------------------------------------
  452. 'Gottlieb Arena
  453. 'added by Inkochnito
  454. '---------------------------------------
  455. Sub EditDips
  456. Dim vpmDips:Set vpmDips = New cvpmDips
  457. With vpmDips
  458. .AddForm 700,400,"Arena - DIP switches"
  459. .AddFrame 2,4,190,"Maximum credits",49152,Array("8 credits",0,"10 credits",32768,"15 credits",&H00004000,"20 credits",49152)'dip 15&16
  460. .AddFrame 2,80,190,"Coin chute 1 and 2 control",&H00002000,Array("seperate",0,"same",&H00002000)'dip 14
  461. .AddFrame 2,126,190,"Playfield special",&H00200000,Array("replay",0,"extra ball",&H00200000)'dip 22
  462. .AddFrame 2,172,190,"High games to date control",&H00000020,Array("no effect",0,"reset high games 2-5 on power off",&H00000020)'dip 6
  463. .AddFrame 2,218,190,"Auto-percentage control",&H00000080,Array("disabled (normal high score mode)",0,"enabled",&H00000080)'dip 8
  464. .AddFrame 2,264,190,"Top 'GUARDS' targets",&H40000000,Array("are reset every ball",0,"are memorized ball to ball",&H40000000)'dip 31
  465. .AddFrame 2,310,190,"Completing all 6 spot targets",&H80000000,Array("2X lights special",0,"1X lights special",&H80000000)'dip 32
  466. .AddFrame 205,4,190,"High game to date awards",&H00C00000,Array("not displayed and no award",0,"displayed and no award",&H00800000,"displayed and 2 replays",&H00400000,"displayed and 3 replays",&H00C00000)'dip 23&24
  467. .AddFrame 205,80,190,"Balls per game",&H01000000,Array("5 balls",0,"3 balls",&H01000000)'dip 25
  468. .AddFrame 205,126,190,"Replay limit",&H04000000,Array("no limit",0,"one per game",&H04000000)'dip 27
  469. .AddFrame 205,172,190,"Novelty",&H08000000,Array("normal",0,"extra ball and replay scores 500K",&H08000000)'dip 28
  470. .AddFrame 205,218,190,"Game mode",&H10000000,Array("replay",0,"extra ball",&H10000000)'dip 29
  471. .AddFrame 205,264,190,"3rd coin chute credits control",&H20000000,Array("no effect",0,"add 9",&H20000000)'dip 30
  472. .AddChk 205,316,180,Array("Match feature",&H02000000)'dip 26
  473. .AddChk 205,331,190,Array("Attract sound",&H00000040)'dip 7
  474. .AddLabel 50,360,300,20,"After hitting OK, press F3 to reset game with new settings."
  475. .ViewDips
  476. End With
  477. End Sub
  478. Set vpmShowDips=GetRef("EditDips")
  479.  
  480.  
  481. '*************
  482. ' JP'S LUT
  483. '*************
  484.  
  485. Dim bLutActive, LUTImage
  486. Sub LoadLUT
  487. Dim x
  488. x = LoadValue(cGameName, "LUTImage")
  489. If(x <> "") Then LUTImage = x Else LUTImage = 0
  490. UpdateLUT
  491. End Sub
  492.  
  493. Sub SaveLUT
  494. SaveValue cGameName, "LUTImage", LUTImage
  495. End Sub
  496.  
  497. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  498.  
  499. Sub UpdateLUT
  500. Select Case LutImage
  501. Case 0: table1.ColorGradeImage = "LUT0"
  502. Case 1: table1.ColorGradeImage = "LUT1"
  503. Case 2: table1.ColorGradeImage = "LUT2"
  504. Case 3: table1.ColorGradeImage = "LUT3"
  505. Case 4: table1.ColorGradeImage = "LUT4"
  506. Case 5: table1.ColorGradeImage = "LUT5"
  507. Case 6: table1.ColorGradeImage = "LUT6"
  508. Case 7: table1.ColorGradeImage = "LUT7"
  509. Case 8: table1.ColorGradeImage = "LUT8"
  510. Case 9: table1.ColorGradeImage = "LUT9"
  511.  
  512. End Select
  513. End Sub
  514.  
  515. '*********************************************************************
  516. ' Positional Sound Playback Functions
  517. '*********************************************************************
  518.  
  519. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  520. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  521. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  522. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  523. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  524. End Sub
  525.  
  526. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  527. Sub PlaySoundAt(soundname, tableobj)
  528. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  529. End Sub
  530.  
  531. Sub PlaySoundAtBall(soundname)
  532. PlaySoundAt soundname, ActiveBall
  533. End Sub
  534.  
  535.  
  536. '*********************************************************************
  537. ' Supporting Ball & Sound Functions
  538. '*********************************************************************
  539.  
  540. 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
  541. Dim tmp
  542. tmp = tableobj.y * 2 / Table1.height-1
  543. If tmp > 0 Then
  544. AudioFade = Csng(tmp ^10)
  545. Else
  546. AudioFade = Csng(-((- tmp) ^10) )
  547. End If
  548. End Function
  549.  
  550. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  551. Dim tmp
  552. tmp = tableobj.x * 2 / Table1.width-1
  553. If tmp > 0 Then
  554. AudioPan = Csng(tmp ^10)
  555. Else
  556. AudioPan = Csng(-((- tmp) ^10) )
  557. End If
  558. End Function
  559.  
  560. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  561. Vol = Csng(BallVel(ball) ^2 / 2000)
  562. End Function
  563.  
  564. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  565. Pitch = BallVel(ball) * 20
  566. End Function
  567.  
  568. Function BallVel(ball) 'Calculates the ball speed
  569. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  570. End Function
  571.  
  572.  
  573. '********************************************************************
  574. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  575. '********************************************************************
  576.  
  577. Const tnob = 5 ' total number of balls
  578. ReDim rolling(tnob)
  579. InitRolling
  580.  
  581. Sub InitRolling
  582. Dim i
  583. For i = 0 to tnob
  584. rolling(i) = False
  585. Next
  586. End Sub
  587.  
  588. Sub RollingTimer_Timer()
  589. Dim BOT, b
  590. BOT = GetBalls
  591.  
  592. ' stop the sound of deleted balls
  593. For b = UBound(BOT) + 1 to tnob
  594. rolling(b) = False
  595. StopSound("fx_ballrolling" & b)
  596. Next
  597.  
  598. ' exit the sub if no balls on the table
  599. If UBound(BOT) = -1 Then Exit Sub
  600.  
  601. For b = 0 to UBound(BOT)
  602. ' play the rolling sound for each ball
  603. If BallVel(BOT(b) ) > 1 AND BOT(b).z < 30 Then
  604. rolling(b) = True
  605. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b)), AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  606. Else
  607. If rolling(b) = True Then
  608. StopSound("fx_ballrolling" & b)
  609. rolling(b) = False
  610. End If
  611. End If
  612.  
  613. ' play ball drop sounds
  614. If BOT(b).VelZ < -1 and BOT(b).z < 55 and BOT(b).z > 27 Then 'height adjust for ball drop sounds
  615. PlaySound "fx_ball_drop" & b, 0, ABS(BOT(b).velz)/17, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  616. End If
  617. Next
  618. End Sub
  619.  
  620. '**********************
  621. ' Ball Collision Sound
  622. '**********************
  623.  
  624. Sub OnBallBallCollision(ball1, ball2, velocity)
  625. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  626. End Sub
  627.  
  628.  
  629. '*****************************************
  630. ' ninuzzu's FLIPPER SHADOWS
  631. '*****************************************
  632.  
  633. sub FlipperTimer_Timer()
  634. FlipperLSh.RotZ = LeftFlipper.currentangle
  635. FlipperRSh.RotZ = RightFlipper.currentangle
  636.  
  637. Prim_LeftFlipper.RotY=LeftFlipper.currentangle-90
  638. Prim_RightFlipper.RotY=RightFlipper.currentangle-90
  639.  
  640. End Sub
  641.  
  642.  
  643. '*****************************************
  644. ' ninuzzu's BALL SHADOW
  645. '*****************************************
  646. Dim BallShadow
  647. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  648.  
  649. Sub BallShadowUpdate_timer()
  650. Dim BOT, b
  651. BOT = GetBalls
  652. ' hide shadow of deleted balls
  653. If UBound(BOT)<(tnob-1) Then
  654. For b = (UBound(BOT) + 1) to (tnob-1)
  655. BallShadow(b).visible = 0
  656. Next
  657. End If
  658. ' exit the Sub if no balls on the table
  659. If UBound(BOT) = -1 Then Exit Sub
  660. ' render the shadow for each ball
  661. For b = 0 to UBound(BOT)
  662. If BOT(b).X < Table1.Width/2 Then
  663. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) + 6
  664. Else
  665. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/7)) - 6
  666. End If
  667. ballShadow(b).Y = BOT(b).Y + 12
  668. If BOT(b).Z > 20 Then
  669. BallShadow(b).visible = 1
  670. Else
  671. BallShadow(b).visible = 0
  672. End If
  673. Next
  674. End Sub
  675.  
  676.  
  677.  
  678. '************************************
  679. ' What you need to add to your table
  680. '************************************
  681.  
  682. ' a timer called RollingTimer. With a fast interval, like 10
  683. ' one collision sound, in this script is called fx_collide
  684. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  685. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  686.  
  687.  
  688. '******************************************
  689. ' Explanation of the rolling sound routine
  690. '******************************************
  691.  
  692. ' sounds are played based on the ball speed and position
  693.  
  694. ' the routine checks first for deleted balls and stops the rolling sound.
  695.  
  696. ' The For loop goes through all the balls on the table and checks for the ball speed and
  697. ' if the ball is on the table (height lower than 30) then then it plays the sound
  698. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  699.  
  700. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  701. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  702. ' according to the position of the ball on the table.
  703.  
  704.  
  705. '**************************************
  706. ' Explanation of the collision routine
  707. '**************************************
  708.  
  709. ' The collision is built in VP.
  710. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  711. ' 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
  712. ' depending of the speed of the collision.
  713.  
  714.  
  715. Sub Pins_Hit (idx)
  716. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  717. End Sub
  718.  
  719. Sub Targets_Hit (idx)
  720. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  721. End Sub
  722.  
  723. Sub Metals_Thin_Hit (idx)
  724. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  725. End Sub
  726.  
  727. Sub Metals_Medium_Hit (idx)
  728. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  729. End Sub
  730.  
  731. Sub Metals2_Hit (idx)
  732. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  733. End Sub
  734.  
  735. Sub Gates_Hit (idx)
  736. PlaySound "gate4", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  737. End Sub
  738.  
  739. Sub Spinner_Spin
  740. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  741. End Sub
  742.  
  743. Sub Rubbers_Hit(idx)
  744. dim finalspeed
  745. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  746. If finalspeed > 20 then
  747. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  748. End if
  749. If finalspeed >= 6 AND finalspeed <= 20 then
  750. RandomSoundRubber()
  751. End If
  752. End Sub
  753.  
  754. Sub Posts_Hit(idx)
  755. dim finalspeed
  756. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  757. If finalspeed > 16 then
  758. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  759. End if
  760. If finalspeed >= 6 AND finalspeed <= 16 then
  761. RandomSoundRubber()
  762. End If
  763. End Sub
  764.  
  765. Sub RandomSoundRubber()
  766. Select Case Int(Rnd*3)+1
  767. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  768. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  769. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  770. End Select
  771. End Sub
  772.  
  773. Sub LeftFlipper_Collide(parm)
  774. RandomSoundFlipper()
  775. End Sub
  776.  
  777. Sub RightFlipper_Collide(parm)
  778. RandomSoundFlipper()
  779. End Sub
  780.  
  781. Sub RandomSoundFlipper()
  782. Select Case Int(Rnd*3)+1
  783. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  784. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  785. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  786. End Select
  787. End Sub
  788.  
  789.  
  790. ' Ramps sounds
  791.  
  792. Sub RampSound2_Hit: PlaySound "fx_plasticrolling1": End Sub
  793. Sub RampSound3_Hit: PlaySound "fx_metalrolling1": End Sub
  794.  
  795. ' Stop Ramps Sounds
  796.  
  797. Sub RampSound1_Hit: StopSound "fx_plasticrolling1": End Sub
  798. Sub RampSound1a_Hit: StopSound "fx_plasticrolling1": End Sub
  799. Sub RampSound4_Hit: StopSound "fx_metalrolling1": End Sub
  800. Sub RampSound5_Hit: StopSound "fx_plasticrolling1": End Sub
  801.  
  802.  
  803. Sub Table1_Exit
  804. If B2SOn Then Controller.Stop
  805. End Sub
Advertisement
Add Comment
Please, Sign In to add comment