Arngrim

Corsario

Feb 28th, 2021
240
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 24.28 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="corsario",UseSolenoids=1,UseLamps=1,UseGI=0, UseSync=1, SCoin="coin3"
  10.  
  11. LoadVPM "01560000","inder.vbs",3.26
  12.  
  13. Dim DesktopMode: DesktopMode = Table1.ShowDT
  14.  
  15. If DesktopMode = True Then 'Show Desktop components
  16. Ramp673.visible=1
  17. Ramp674.visible=1
  18. Primitive124.visible=1
  19. EB1.visible=1
  20. EB2.visible=1
  21. TextBox1.visible=1
  22. Else
  23. Ramp673.visible=0
  24. Ramp674.visible=0
  25. Primitive124.visible=0
  26. EB1.visible=0
  27. EB2.visible=0
  28. TextBox1.visible=0
  29. End if
  30.  
  31. '*************************************************************
  32. 'Solenoid Call backs
  33. '*************************************************************
  34.  
  35. SolCallback(3)= "vpmSolSound SoundFX(""Knocker"",DOFKnocker),"
  36. SolCallback(4)= "bsTrough.SolOut"
  37. 'SolCallback(5)="GameStart"
  38. SolCallback(8)="dtL.SolDropUp"
  39.  
  40. SolCallback(sLRFlipper) = "SolRFlipper"
  41. SolCallback(sLLFlipper) = "SolLFlipper"
  42.  
  43. Sub SolLFlipper(Enabled)
  44. If Enabled Then
  45. PlaySound SoundFX("Flipperup",DOFFlippers):LeftFlipper.RotateToEnd
  46. Else
  47. PlaySound SoundFX("Flipperdown",DOFFlippers):LeftFlipper.RotateToStart
  48. End If
  49. End Sub
  50.  
  51. Sub SolRFlipper(Enabled)
  52. If Enabled Then
  53. PlaySound SoundFX("Flipperup",DOFFlippers):RightFlipper.RotateToEnd
  54. Else
  55. PlaySound SoundFX("Flipperdown",DOFFlippers):RightFlipper.RotateToStart
  56. End If
  57. End Sub
  58.  
  59.  
  60. '**********************************************************************************************************
  61.  
  62. 'Solenoid Controlled toys
  63. '**********************************************************************************************************
  64.  
  65. '*****GI Lights On
  66. dim xx
  67. For each xx in GI:xx.State = 1: Next
  68.  
  69. '**********************************************************************************************************
  70. 'Initiate Table
  71. '**********************************************************************************************************
  72.  
  73. Dim bsTrough,dtL,bsBT
  74.  
  75. Sub Table1_Init
  76. DivOpen.IsDropped=1
  77. DivOpen1.IsDropped=1
  78. Primitive102.z=35
  79. Primitive103.z=-35
  80. vpmInit Me
  81. On Error Resume Next
  82. With Controller
  83. .GameName = cGameName
  84. If Err Then MsgBox "Can't start Game" & cGameName & vbNewLine & Err.Description : Exit Sub
  85. .SplashInfoLine = ""&chr(13)&"You Suck"
  86. .HandleMechanics=0
  87. .HandleKeyboard=0
  88. .ShowDMDOnly=1
  89. .ShowFrame=0
  90. .ShowTitle=0
  91. .hidden = 1
  92. .Games(cGameName).Settings.Value("sound")=1
  93. '.PuPHide = 1
  94. On Error Resume Next
  95. .Run GetPlayerHWnd
  96. If Err Then MsgBox Err.Description
  97. On Error Goto 0
  98. End With
  99. On Error Goto 0
  100.  
  101. PinMAMETimer.Interval=PinMAMEInterval
  102. PinMAMETimer.Enabled=1
  103.  
  104. vpmNudge.TiltSwitch=53
  105. vpmNudge.Sensitivity=5
  106. vpmNudge.TiltObj=Array(Bumper1,Bumper2,Bumper3)
  107.  
  108. Set bsTrough=New cvpmBallStack
  109. bsTrough.InitSw 0,91,0,0,0,0,0,0
  110. bsTrough.InitKick BallRelease,93,5
  111. bsTrough.InitExitSnd SoundFX("ballrel",DOFContactors), SoundFX("Solenoid",DOFContactors)
  112. bsTrough.Balls=1
  113.  
  114. Set dtL=New cvpmDropTarget
  115. dtL.InitDrop Array(S51,S52,S53,S54),Array(71,72,73,74)
  116. dtL.InitSnd SoundFX("DTDrop",DOFDropTargets),SoundFX("DTReset",DOFContactors)
  117. dtL.CreateEvents "dtL"
  118.  
  119.  
  120. Set bsBT=New cvpmBallStack
  121. bsBT.InitSw 0,70,0,0,0,0,0,0
  122. bsBT.InitKick Kicker4,97,5
  123. bsBT.InitExitSnd SoundFX("Popper",DOFContactors), SoundFX("Solon",DOFContactors)
  124.  
  125. vpmMapLights AllLights
  126. End Sub
  127.  
  128. '**********************************************************************************************************
  129. 'Plunger code
  130. '**********************************************************************************************************
  131.  
  132. Sub Table1_KeyDown(ByVal KeyCode)
  133. If keycode = LeftMagnaSave Then bLutActive = True
  134. If keycode = RightMagnaSave Then
  135. If bLutActive Then NextLUT: End If
  136. End If
  137. If keycode = PlungerKey Then Plunger.Pullback:playsound"plungerpull"
  138. If KeyDownHandler(keycode) Then Exit Sub
  139. End Sub
  140.  
  141. Sub Table1_KeyUp(ByVal KeyCode)
  142. If keycode = LeftMagnaSave Then bLutActive = False
  143. If keycode = PlungerKey Then Plunger.Fire:PlaySound"plunger"
  144. If KeyUpHandler(keycode) Then Exit Sub
  145. End Sub
  146.  
  147. '*******************
  148. 'Inder Switches +20
  149. '*******************
  150.  
  151. 'Kickers
  152.  
  153. Sub S47_Hit:S47.DestroyBall:vpmTimer.PulseSw 67:Kicker2.CreateBall:Kicker2.Kick 180,3:End Sub
  154. Sub S50_Hit:bsBT.AddBall Me:Kicker4.Kick 97,5:End Sub
  155.  
  156.  
  157. 'Targets
  158.  
  159. Sub S61_Hit:vpmTimer.PulseSw 81: PlaySound SoundFX("Target",DOFTargets):End Sub
  160. Sub S64_Hit:vpmTimer.PulseSw 84: PlaySound SoundFX("Target",DOFTargets):End Sub
  161. Sub S65_Hit:vpmTimer.PulseSw 85: PlaySound SoundFX("Target",DOFTargets):End Sub
  162. Sub S75_Hit:vpmTimer.PulseSw 95: PlaySound SoundFX("Target",DOFTargets):End Sub
  163.  
  164.  
  165. 'Triggers
  166.  
  167. Sub S40_Hit:Controller.Switch(60)=1:PlaySound "sensor" : End Sub
  168. Sub S40_unHit:Controller.Switch(60)=0:End Sub
  169.  
  170. Sub S41_Hit:Controller.Switch(61)=1:S41p.z = 33 : PlaySound "sensor":End Sub
  171. Sub S41_unHit:Controller.Switch(61)=0:S41p.z = 55:End Sub
  172.  
  173. Sub S42_Hit:Controller.Switch(62)=1:S42p.z = 33 : PlaySound "sensor":End Sub
  174. Sub S42_unHit:Controller.Switch(62)=0:S42p.z = 55:End Sub
  175.  
  176. Sub S43_Hit:Controller.Switch(63)=1:PlaySound "sensor": End Sub
  177. Sub S43_unHit:Controller.Switch(63)=0:End Sub
  178.  
  179. Sub S57_Hit:Controller.Switch(77)=1:PlaySound "sensor" : End Sub
  180. Sub S57_unHit:Controller.Switch(77)=0:End Sub
  181.  
  182. Sub S62_Hit:Controller.Switch(82)=1:S62p.z = -30 : PlaySound "sensor":End Sub
  183. Sub S62_unHit:Controller.Switch(82)=0:S62p.z = -8:End Sub
  184.  
  185. Sub S63_Hit:Controller.Switch(83)=1:S63p.z = -30 : PlaySound "sensor":End Sub
  186. Sub S63_unHit:Controller.Switch(83)=0:S63p.z = -8:End Sub
  187.  
  188. Sub S67_Hit:Controller.Switch(87)=1:PlaySound "sensor" : End Sub
  189. Sub S67_unHit:Controller.Switch(87)=0:End Sub
  190.  
  191. Sub S70_Hit:Controller.Switch(90)=1:PlaySound "sensor" : End Sub
  192. Sub S70_unHit:Controller.Switch(90)=0: End Sub
  193.  
  194. Sub S73A_Hit:Controller.Switch(93)=1:PlaySound "sensor" : End Sub
  195. Sub S73A_unHit:Controller.Switch(93)=0: End Sub
  196.  
  197. Sub S73B_Hit:Controller.Switch(93)=1:PlaySound "sensor" : End Sub
  198. Sub S73B_unHit:Controller.Switch(93)=0:End Sub
  199.  
  200. Sub S74_Hit:Controller.Switch(94)=1:PlaySound "sensor" : End Sub
  201. Sub S74_unHit:Controller.Switch(94)=0: End Sub
  202.  
  203. Sub S77_Hit:Controller.Switch(97)=1:PlaySound "sensor" : End Sub
  204. Sub S77_unHit:Controller.Switch(97)=0:End Sub
  205.  
  206.  
  207. 'Spinner
  208.  
  209. Sub S44_Spin:vpmTimer.PulseSw 64:PlaySound "spinner":End Sub
  210.  
  211.  
  212. 'Slings & Rebounds
  213.  
  214. Sub S60_Hit:vpmTimer.PulseSw 80:PlaySound"fx_rubber":End Sub
  215.  
  216. Sub S72_Hit:vpmTimer.PulseSw 92:PlaySound"fx_rubber":End Sub
  217.  
  218. 'Door
  219.  
  220. Sub Drain_Hit
  221. If DivClosed.IsDropped Then
  222. DivOpen.IsDropped=1:PlaySound "metalhit"
  223. DivOpen1.IsDropped=1
  224. DivClosed.IsDropped=0:PlaySound "metalhit"
  225. DivClosed1.IsDropped=0
  226. End If
  227. Primitive102.z=35
  228. Primitive103.z=-35
  229. bsTrough.AddBall Me:playsound "Drain"
  230. End Sub
  231.  
  232.  
  233. 'Bumpers
  234.  
  235. Sub Bumper1_Hit: vpmTimer.PulseSw 66 : PlayBumperSound
  236. Light17.State = 1
  237. Me.TimerEnabled = 1
  238. End Sub
  239.  
  240. Sub Bumper1_Timer
  241. Light17.State = 0
  242. Me.Timerenabled = 0
  243. End Sub
  244.  
  245. Sub Bumper2_Hit: vpmTimer.PulseSw 86 : PlayBumperSound
  246. Light18.State = 1
  247. Me.TimerEnabled = 1
  248. End Sub
  249.  
  250. Sub Bumper2_Timer
  251. Light18.State = 0
  252. Me.Timerenabled = 0
  253. End Sub
  254.  
  255. Sub Bumper3_Hit: vpmTimer.PulseSw 96 : PlayBumperSound
  256. Light19.State = 1
  257. Me.TimerEnabled = 1
  258. End Sub
  259.  
  260. Sub Bumper3_Timer
  261. Light19.State = 0
  262. Me.Timerenabled = 0
  263. End Sub
  264.  
  265. Sub PlayBumperSound()
  266. Select Case Int(Rnd*3)+1
  267. Case 1 : PlaySound SoundFX("fx_bumper1",DOFContactors)
  268. Case 2 : PlaySound SoundFX("fx_bumper2",DOFContactors)
  269. Case 3 : PlaySound SoundFX("fx_bumper3",DOFContactors)
  270. End Select
  271. End Sub
  272.  
  273. 'Gates
  274.  
  275. Sub Gate1_Hit():PlaySound "Gate5":End Sub
  276. Sub Gate2_Hit():PlaySound "Gate5":End Sub
  277. Sub Gate3_Hit():PlaySound "Gate5":End Sub
  278.  
  279. '*****************
  280. ' Trigger
  281. '*****************
  282.  
  283. Sub Trigger2_UnHit
  284. ActiveBall.VelX = -2
  285. End Sub
  286.  
  287. '*****************
  288. 'Lamps & Flashers
  289. '*****************
  290.  
  291. Set LampCallback=GetRef("UpdateMultipleLamps")
  292.  
  293. Dim Old14,New14,Old9,New9,Old15,New15,Old24,New24,Old25,New25,ST1,ST2
  294. Old14=1:Old9=1:Old15=1:Old24=1:Old25=1:ST1=0:ST2=0
  295.  
  296. Sub UpdateMultipleLamps
  297. New14=Light14.State
  298. If New14<>Old14 Then
  299. If New14=0 Then
  300. If bsBT.Balls Then bsBT.ExitSol_On
  301. End If
  302. End If
  303. Old14=New14
  304.  
  305. New9=Light9.State
  306. If New9<>Old9 Then
  307. If New9=0 Then
  308. DivClosed.IsDropped=1
  309. DivClosed1.IsDropped=1
  310. DivOpen.IsDropped=0
  311. DivOpen1.IsDropped=0
  312. Primitive102.z=-35
  313. Primitive103.z=35
  314. End If
  315. End If
  316. Old9=New9
  317.  
  318. New24=A24.State
  319. If New24<>Old24 Then
  320. If New24=0 Then
  321. EB1.State=1
  322. ST1=1
  323. Else
  324. EB1.State=0
  325. ST1=0
  326. End If
  327. End If
  328. Old24=New24
  329.  
  330. New25=A25.State
  331. If New25<>Old25 Then
  332. If New25=0 Then
  333. EB2.State=1
  334. ST2=1
  335. Else
  336. EB2.State=0
  337. ST2=0
  338. End If
  339. End If
  340.  
  341. If A13.State = 0 then S41p.image = "bprim1"
  342. If A13.State = 1 then S41p.image = "bprim_luz1"
  343. If A9.State = 0 then S42p.image = "bprim1"
  344. If A9.State = 1 then S42p.image = "bprim_luz1"
  345. Old25=New25
  346.  
  347. If ST1=0 And ST2=0 Then Textbox1.Text="0"
  348. If ST1=1 And ST2=0 Then Textbox1.Text="1"
  349. If ST1=0 And ST2=1 Then Textbox1.Text="2"
  350. If ST1=1 And ST2=1 Then Textbox1.Text="3"
  351.  
  352. End Sub
  353.  
  354. Sub Trigger1_Hit
  355. If DivClosed.IsDropped Then
  356. DivOpen.IsDropped=1
  357. DivOpen1.IsDropped=1
  358. DivClosed.IsDropped=0
  359. DivClosed1.IsDropped=0
  360. Primitive102.z=35
  361. Primitive103.z=-35
  362. End If
  363. End Sub
  364.  
  365. '******
  366. 'LED's
  367. '******
  368.  
  369. Dim Digits(32)
  370. Digits(0)=Array(B1,B2,B3,B4,B5,B6,B7)
  371. Digits(1)=Array(B8,B9,B10,B11,B12,B13,B14)
  372. Digits(2)=Array(B15,B16,B17,B18,B19,B20,B21)
  373. Digits(3)=Array(B22,B23,Light1,B25,B26,B27,B28)
  374. Digits(4)=Array(B29,B30,B31,B32,B33,B34,B35)
  375. Digits(5)=Array(B36,B37,B38,B39,B40,B41,B42)
  376. Digits(6)=Array(B43,B44,B45,B46,B47,B48,B49)
  377. Digits(7)=Array(B50,B51,B52,B53,B54,B55,B56)
  378. Digits(8)=Array(B57,B58,B59,B60,B61,B62,B63)
  379. Digits(9)=Array(B64,B65,B66,B67,B68,B69,B70)
  380. Digits(10)=Array(B71,B72,B73,B74,B75,B76,B77)
  381. Digits(11)=Array(B78,B79,B80,B81,B82,B83,B84)
  382. Digits(12)=Array(B85,B86,B87,B88,B89,B90,B91)
  383. Digits(13)=Array(B92,B93,B94,B95,B96,B97,B98)
  384. Digits(14)=Array(B99,B100,B101,B102,B103,B104,B105)
  385. Digits(15)=Array(B106,B107,B108,B109,B110,B111,B112)
  386. Digits(16)=Array(B113,B114,B115,B116,B117,B118,B119)
  387. Digits(17)=Array(B120,B121,B122,B123,B124,B125,B126)
  388. Digits(18)=Array(B127,B128,B129,B130,B131,B132,B133)
  389. Digits(19)=Array(B134,B135,B136,B137,B138,B139,B140)
  390. Digits(20)=Array(B141,B142,B143,B144,B145,B146,B147)
  391. Digits(21)=Array(B148,B149,B150,B151,B152,B153,B154)
  392. Digits(22)=Array(B155,B156,B157,B158,B159,B160,B161)
  393. Digits(23)=Array(B162,B163,B164,B165,B166,B167,B168)
  394. Digits(24)=Array(B169,B170,B171,B172,B173,B174,B175)
  395. Digits(25)=Array(B176,B177,B178,B179,B180,B181,B182)
  396. Digits(26)=Array(B183,B184,B185,B186,B187,B188,B189)
  397. Digits(27)=Array(B190,B191,B192,B193,B194,B195,B196)
  398. Digits(28)=Array(B197,B198,B199,B200,B201,B202,B203)
  399. Digits(29)=Array(B204,B205,B206,B207,B208,B209,B210)
  400. Digits(30)=Array(B211,B212,B213,B214,B215,B216,B217)
  401. Digits(31)=Array(B218,B219,B220,B221,B222,B223,B224)
  402.  
  403.  
  404. Sub DisplayTimer_Timer
  405. Dim ChgLED,ii,num,chg,stat,obj
  406. ChgLed = Controller.ChangedLEDs(&Hffffffff, &Hffffffff)
  407. If Not IsEmpty(ChgLED) Then
  408. If DesktopMode = True Then
  409. For ii = 0 To UBound(chgLED)
  410. num = chgLED(ii, 0) : chg = chgLED(ii, 1) : stat = chgLED(ii, 2)
  411. if (num < 32) then
  412. For Each obj In Digits(num)
  413. If chg And 1 Then obj.State = stat And 1
  414. chg = chg\2 : stat = stat\2
  415. Next
  416. else
  417.  
  418. end if
  419. next
  420. end if
  421. end if
  422. End Sub
  423.  
  424. '*********************
  425. ' Inder "Corsario"
  426. 'Added By Inkochnito
  427. '*********************
  428.  
  429. Sub editDips
  430. Dim vpmDips:Set vpmDips=New cvpmDips
  431. With vpmDips
  432. .AddForm 700,400,"Corsario - DIP switches"
  433. .AddFrame 0,0,340,"Credits per coin",&H00000003,Array("1 coin - 1 credit && 1 coin - 4 credits",0,"2 coins - 1 credit (4 coins - 3 credits) && 1 coin - 3 credits",&H00000003)'SL1-3&4 (dip 1&2)
  434. .AddFrame 0,46,100,"Handicap value",&H00000300,Array("4,500,000 points",0,"5,000,000 points",&H00000100,"5,500,000 points",&H00000200,"6,000,000 points",&H00000300)'SL2-4&3(dip 9&10)
  435. .AddFrame 240,46,100,"Balls per game",&H00000008,Array("3 balls",0,"5 balls",&H00000008)'SL1-1 (dip 4)
  436. .AddFrame 120,46,100,"Replay threshold",&H000000C0,Array("3,000,000 points",0,"3,500,000 points",&H00000080,"4,000,000 points",&H00000040,"4,500,000 points",&H000000C0)'SL1-6&5 (dip 7&8)
  437. .AddLabel 50,130,300,20,"After hitting OK, press F3 to reset game with new settings."
  438. .ViewDips
  439. End With
  440. End Sub
  441. Set vpmShowDips=GetRef("editDips")
  442.  
  443.  
  444. '*************
  445. ' JP'S LUT
  446. '*************
  447.  
  448. Dim bLutActive, LUTImage
  449. Sub LoadLUT
  450. Dim x
  451. x = LoadValue(cGameName, "LUTImage")
  452. If(x <> "") Then LUTImage = x Else LUTImage = 0
  453. UpdateLUT
  454. End Sub
  455.  
  456. Sub SaveLUT
  457. SaveValue cGameName, "LUTImage", LUTImage
  458. End Sub
  459.  
  460. Sub NextLUT: LUTImage = (LUTImage +1 ) MOD 10: UpdateLUT: SaveLUT: End Sub
  461.  
  462. Sub UpdateLUT
  463. Select Case LutImage
  464. Case 0: table1.ColorGradeImage = "LUT0"
  465. Case 1: table1.ColorGradeImage = "LUT1"
  466. Case 2: table1.ColorGradeImage = "LUT2"
  467. Case 3: table1.ColorGradeImage = "LUT3"
  468. Case 4: table1.ColorGradeImage = "LUT4"
  469. Case 5: table1.ColorGradeImage = "LUT5"
  470. Case 6: table1.ColorGradeImage = "LUT6"
  471. Case 7: table1.ColorGradeImage = "LUT7"
  472. Case 8: table1.ColorGradeImage = "LUT8"
  473. Case 9: table1.ColorGradeImage = "LUT9"
  474.  
  475. End Select
  476. End Sub
  477.  
  478. '*********************************************************************
  479. ' Positional Sound Playback Functions
  480. '*********************************************************************
  481.  
  482. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  483. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  484. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  485. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  486. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  487. End Sub
  488.  
  489. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  490. Sub PlaySoundAt(soundname, tableobj)
  491. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  492. End Sub
  493.  
  494. Sub PlaySoundAtBall(soundname)
  495. PlaySoundAt soundname, ActiveBall
  496. End Sub
  497.  
  498.  
  499. '*********************************************************************
  500. ' Supporting Ball & Sound Functions
  501. '*********************************************************************
  502.  
  503. 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
  504. Dim tmp
  505. tmp = tableobj.y * 2 / table1.height-1
  506. If tmp > 0 Then
  507. AudioFade = Csng(tmp ^10)
  508. Else
  509. AudioFade = Csng(-((- tmp) ^10) )
  510. End If
  511. End Function
  512.  
  513. Function AudioPan(tableobj) ' Calculates the pan for a tableobj based on the X position on the table. "table1" is the name of the table
  514. Dim tmp
  515. tmp = tableobj.x * 2 / table1.width-1
  516. If tmp > 0 Then
  517. AudioPan = Csng(tmp ^10)
  518. Else
  519. AudioPan = Csng(-((- tmp) ^10) )
  520. End If
  521. End Function
  522.  
  523. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  524. Vol = Csng(BallVel(ball) ^2 / 2000)
  525. End Function
  526.  
  527. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  528. Pitch = BallVel(ball) * 20
  529. End Function
  530.  
  531. Function BallVel(ball) 'Calculates the ball speed
  532. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  533. End Function
  534.  
  535.  
  536. '********************************************************************
  537. ' JP's VP10 Rolling Sounds (+rothbauerw's Dropping Sounds)
  538. '********************************************************************
  539.  
  540. Const tnob = 5 ' total number of balls
  541. ReDim rolling(tnob)
  542. InitRolling
  543.  
  544. Sub InitRolling
  545. Dim i
  546. For i = 0 to tnob
  547. rolling(i) = False
  548. Next
  549. End Sub
  550.  
  551. Sub RollingTimer_Timer()
  552. Dim BOT, b
  553. BOT = GetBalls
  554.  
  555. ' stop the sound of deleted balls
  556. For b = UBound(BOT) + 1 to tnob
  557. rolling(b) = False
  558. StopSound "fx_ballrolling" & b
  559. StopSound "fx_plasticrolling" & b
  560. StopSound "fx_metalrolling" & b
  561. Next
  562.  
  563. ' exit the sub if no balls on the table
  564. If UBound(BOT) = -1 Then Exit Sub
  565.  
  566. ' play the rolling sound for each ball
  567. For b = 0 to UBound(BOT)
  568. If BallVel(BOT(b) ) > 1 Then
  569. rolling(b) = True
  570. If BOT(b).Z > 30 Then
  571. ' ball on plastic ramp
  572. StopSound "fx_ballrolling" & b
  573. StopSound "fx_metalrolling" & b
  574. PlaySound "fx_plasticrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  575. Else
  576. ' ball on playfield
  577. StopSound "fx_plasticrolling" & b
  578. StopSound "fx_metalrolling" & b
  579. PlaySound "fx_ballrolling" & b, -1, Vol(BOT(b)) / 2, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  580. End If
  581. Else
  582. If rolling(b) Then
  583. StopSound "fx_ballrolling" & b
  584. StopSound "fx_plasticrolling" & b
  585. StopSound "fx_metalrolling" & b
  586. rolling(b) = False
  587. End If
  588. End If
  589.  
  590. ' ball drop sounds matching the adjusted height params but not the way down the ramps
  591. If BOT(b).VelZ < -1 And BOT(b).Z < 55 And BOT(b).Z > 27 then 'And Not InRect(BOT(b).X, BOT(b).Y, 610,320, 740,320, 740,550, 610,550) And Not InRect(BOT(b).X, BOT(b).Y, 180,400, 230,400, 230, 550, 180,550) Then
  592. PlaySound "fx_ball_drop" & Int(Rnd()*3), 0, ABS(BOT(b).VelZ)/17*5, AudioPan(BOT(b)), 0, Pitch(BOT(b)), 1, 0, AudioFade(BOT(b))
  593. End If
  594.  
  595. Next
  596. End Sub
  597.  
  598. '**********************
  599. ' Ball Collision Sound
  600. '**********************
  601.  
  602. Sub OnBallBallCollision(ball1, ball2, velocity)
  603. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, AudioPan(ball1), 0, Pitch(ball1), 0, 0, AudioFade(ball1)
  604. End Sub
  605.  
  606. '*****************************************
  607. ' ninuzzu's FLIPPER SHADOWS
  608. '*****************************************
  609.  
  610. sub FlipperTimer_Timer()
  611. FlipperLSh.RotZ = LeftFlipper.currentangle
  612. FlipperRSh.RotZ = RightFlipper.currentangle
  613.  
  614. LFPrim.roty=leftFlipper.CurrentAngle
  615. RFPrim.roty=rightFlipper.CurrentAngle
  616.  
  617. End Sub
  618.  
  619. '*****************************************
  620. ' ninuzzu's BALL SHADOW
  621. '*****************************************
  622.  
  623. Dim BallShadow
  624. BallShadow = Array (BallShadow1,BallShadow2,BallShadow3,BallShadow4,BallShadow5)
  625.  
  626. Sub BallShadowUpdate_timer()
  627. Dim BOT, b
  628. BOT = GetBalls
  629. ' hide shadow of deleted balls
  630. If UBound(BOT)<(tnob-1) Then
  631. For b = (UBound(BOT) + 1) to (tnob-1)
  632. BallShadow(b).visible = 0
  633. Next
  634. End If
  635. ' exit the Sub if no balls on the table
  636. If UBound(BOT) = -1 Then Exit Sub
  637. ' render the shadow for each ball
  638. For b = 0 to UBound(BOT)
  639. If BOT(b).X < Table1.Width/2 Then
  640. BallShadow(b).X = ((BOT(b).X) - (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) + 6
  641. Else
  642. BallShadow(b).X = ((BOT(b).X) + (Ballsize/6) + ((BOT(b).X - (Table1.Width/2))/21)) - 6
  643. End If
  644. ballShadow(b).Y = BOT(b).Y + 4
  645. If BOT(b).Z > 20 Then
  646. BallShadow(b).visible = 1
  647. Else
  648. BallShadow(b).visible = 0
  649. End If
  650. Next
  651. End Sub
  652.  
  653.  
  654. '************************************
  655. ' What you need to add to your table
  656. '************************************
  657.  
  658. ' a timer called RollingTimer. With a fast interval, like 10
  659. ' one collision sound, in this script is called fx_collide
  660. ' as many sound files as max number of balls, with names ending with 0, 1, 2, 3, etc
  661. ' for ex. as used in this script: fx_ballrolling0, fx_ballrolling1, fx_ballrolling2, fx_ballrolling3, etc
  662.  
  663.  
  664. '******************************************
  665. ' Explanation of the rolling sound routine
  666. '******************************************
  667.  
  668. ' sounds are played based on the ball speed and position
  669.  
  670. ' the routine checks first for deleted balls and stops the rolling sound.
  671.  
  672. ' The For loop goes through all the balls on the table and checks for the ball speed and
  673. ' if the ball is on the table (height lower than 30) then then it plays the sound
  674. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  675.  
  676. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  677. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  678. ' according to the position of the ball on the table.
  679.  
  680.  
  681. '**************************************
  682. ' Explanation of the collision routine
  683. '**************************************
  684.  
  685. ' The collision is built in VP.
  686. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  687. ' 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
  688. ' depending of the speed of the collision.
  689.  
  690.  
  691. Sub Pins_Hit (idx)
  692. PlaySound "pinhit_low", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  693. End Sub
  694.  
  695. Sub Targets_Hit (idx)
  696. PlaySound "target", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 0, 0, AudioFade(ActiveBall)
  697. End Sub
  698.  
  699. Sub Metals_Thin_Hit (idx)
  700. PlaySound "metalhit_thin", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  701. End Sub
  702.  
  703. Sub Metals_Medium_Hit (idx)
  704. PlaySound "metalhit_medium", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  705. End Sub
  706.  
  707. Sub Metals2_Hit (idx)
  708. PlaySound "metalhit2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  709. End Sub
  710.  
  711. Sub Gates_Hit (idx)
  712. PlaySound "Gate5", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  713. End Sub
  714.  
  715. Sub Spinner_Spin
  716. PlaySound "fx_spinner", 0, .25, AudioPan(Spinner), 0.25, 0, 0, 1, AudioFade(Spinner)
  717. End Sub
  718.  
  719. Sub Rubbers_Hit(idx)
  720. dim finalspeed
  721. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  722. If finalspeed > 20 then
  723. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  724. End if
  725. If finalspeed >= 6 AND finalspeed <= 20 then
  726. RandomSoundRubber()
  727. End If
  728. End Sub
  729.  
  730. Sub Posts_Hit(idx)
  731. dim finalspeed
  732. finalspeed=SQR(activeball.velx * activeball.velx + activeball.vely * activeball.vely)
  733. If finalspeed > 16 then
  734. PlaySound "fx_rubber2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  735. End if
  736. If finalspeed >= 6 AND finalspeed <= 16 then
  737. RandomSoundRubber()
  738. End If
  739. End Sub
  740.  
  741. Sub RandomSoundRubber()
  742. Select Case Int(Rnd*3)+1
  743. Case 1 : PlaySound "rubber_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  744. Case 2 : PlaySound "rubber_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  745. Case 3 : PlaySound "rubber_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  746. End Select
  747. End Sub
  748.  
  749. Sub LeftFlipper_Collide(parm)
  750. RandomSoundFlipper()
  751. End Sub
  752.  
  753. Sub RightFlipper_Collide(parm)
  754. RandomSoundFlipper()
  755. End Sub
  756.  
  757. Sub RandomSoundFlipper()
  758. Select Case Int(Rnd*3)+1
  759. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  760. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  761. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), AudioPan(ActiveBall), 0, Pitch(ActiveBall), 1, 0, AudioFade(ActiveBall)
  762. End Select
  763. End Sub
  764.  
  765. ' Ramps sounds
  766.  
  767. Sub RampSound1_Hit: PlaySound "fx_metalrolling1": End Sub
  768. Sub RampSound3_Hit: PlaySound "fx_metalrolling1": End Sub
  769.  
  770. ' Stop Ramps Sounds
  771.  
  772. Sub RampSound2_Hit: StopSound "fx_metalrolling1": End Sub
  773. Sub RampSound4_Hit: StopSound "fx_metalrolling1": End Sub
  774.  
  775.  
  776. Sub Table1_Exit()
  777. If B2SOn Then
  778. Controller.Pause = False
  779. Controller.Stop
  780. End If
  781. End Sub
Advertisement
Add Comment
Please, Sign In to add comment