Outhere

Major League Warbler33_(PAMCO 1934) 0.37

Sep 15th, 2021 (edited)
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.38 KB | None | 0 0
  1. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  2. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  3. '~~~ ~~~
  4. '~~~ Major League ~~~
  5. '~~~ (PAMCO 1934) ~~~
  6. '~~~ ~~~
  7. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  8. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  9. 'Made by Warbler33 / CactusDude
  10. 'Released
  11. 'Version
  12.  
  13. ' Very Basic DOF added by Outhere
  14.  
  15. ' DOF SETUP
  16. ' ---------
  17. '101 - Chime Unit Mid Tone
  18. '102 - Beacon
  19. '103 - Shaker
  20. '104 -
  21. '105 - 1st Base
  22. '106 - Chime Unit Low Tone
  23. '107 - Chime Unit High Tone
  24. '108 - 2nd Base
  25. '109 - 3rd Base
  26. '110 - Topper Bell
  27. '111 - Flipper Right
  28. '112 -
  29. '113 -
  30. '114 -
  31. '115 -
  32.  
  33. Option Explicit
  34.  
  35. On Error Resume Next
  36. ExecuteGlobal GetTextFile("controller.vbs")
  37. If Err Then MsgBox "You need the Controller.vbs file in order to run this table (installed with the VPX package in the scripts folder)"
  38. On Error Goto 0
  39.  
  40.  
  41. Const cGameName = "MajorLeague1934"
  42.  
  43. '~~~~~~~~~~~~~~~~~~~~~~~~~~~
  44. '~~~~~ Configuration ~~~~~
  45. '~~~~~~~~~~~~~~~~~~~~~~~~~~~
  46. Const BallsperGame = 10
  47. Const FreePlay = True
  48. Const RollingSoundFactor = 2.5 'set sound level factor here for Ball Rolling Sound, 1=default level
  49.  
  50. Const VolumeMultiplier = 3 'adjusts table sound volume
  51.  
  52. Const EndSound = 1 '1 = "Take Me Out to the Ballgame"; 2 = Chime
  53.  
  54. Const BallSize = 20 'Ball radius
  55.  
  56. Const BackglassOn = True 'set to false to play without using the backglass
  57.  
  58. '(remove/comment out following 4 lines to prevent the backglass from launching)
  59. Dim Controller
  60. Set Controller = CreateObject("B2S.Server")
  61. Controller.B2SName = ""
  62. Controller.Run
  63.  
  64. '***
  65.  
  66. Dim i,HighScore,Credits,GameStarted,BallinPlay,BallReleaseLocked,BallsonBoard
  67. Dim LaneClear
  68.  
  69. '--------------------------
  70. '------ Table Init ------
  71. '--------------------------
  72.  
  73. Sub MajorLeague_Init
  74. FINISHGAME = False
  75. LoadHS
  76. If Hiscore="" then hiscore=300
  77. Backglasstimer.enabled = true
  78.  
  79. Randomize
  80.  
  81. if FreePlay then
  82. Credits = 5
  83. DOF 126, DOFOn
  84. end If
  85.  
  86. ' TiltKicker.CreateBall
  87. TiltCount = 0
  88. BallinPlay = 0
  89. GameStarted = False
  90. LaneClear = True
  91. RBI = 0
  92. Playerscore = 0
  93. UsedMarbles = 0
  94. B2SBall = 0
  95. If BackglassOn = True then Controller.B2SSetScorePlayer 1, PlayerScore end if
  96. If BackglassOn = True then Controller.B2SSetScorePlayer 2, RBI end if
  97. If BackglassOn = True then Controller.B2SSetScorePlayer 3, hiscore end if
  98. If BackglassOn = True then Controller.B2SSetScorePlayer 4, B2SBall end if
  99. LoadEM
  100. End Sub
  101.  
  102.  
  103. '~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104. '~~~~~ Game Features ~~~~~
  105. '~~~~~~~~~~~~~~~~~~~~~~~~~~~
  106.  
  107. Sub StartGame
  108. if Credits > 0 Then
  109. if not GameStarted then
  110. GameEndTimer.interval = 2000
  111. BallReleaseLocked = False
  112. Playerscore = 0
  113. RBI = 0
  114. GameStarted = True
  115. BallinPlay = 0
  116. UsedMarbles = 0
  117. B2SBall = 0
  118. UsedMarbles = 0
  119. B2SBall = 0
  120. If BackglassOn = True then Controller.B2SSetScorePlayer 1, PlayerScore end if
  121. If BackglassOn = True then Controller.B2SSetScorePlayer 2, RBI end if
  122. If BackglassOn = True then Controller.B2SSetScorePlayer 3, hiscore end if
  123. If BackglassOn = True then Controller.B2SSetScorePlayer 4, B2SBall end if
  124. Credits = Credits - 1
  125. If Credits < 1 Then DOF 126, DOFOff
  126. if FreePlay and (Credits = 0) then
  127. Credits = 5
  128. DOF 126, DOFOn
  129. end If
  130. end If
  131. end If
  132. End Sub
  133.  
  134. Dim B2SBall
  135.  
  136. Sub NextBall
  137. If LaneClear = False then Exit Sub end if
  138. if BallsonBoard <= BallsperGame Then
  139. BallReleaseLocked = False
  140. PlaySound SoundFXDOF("BallLift",111,2,DOFFlippers),0,0.5,Pan(Plunger),0.25,0,0,1,0
  141. ' BallinPlay = BallinPlay + 1'
  142. B2SBall = B2SBall + 1
  143. If BackglassOn = True then Controller.B2SSetScorePlayer 4, B2SBall end if
  144. end If
  145. BallRelease.Timerenabled = True
  146. ' End If
  147. End Sub
  148.  
  149. Sub BallRelease_Timer
  150. BallRelease.Timerenabled = False
  151. BallRelease.CreateBall
  152. BallRelease.Kick 270, 7
  153. 'DOF 122, DOFPulse
  154. End Sub
  155.  
  156. Sub CheckFinish
  157. If FINISHGAME = False then Exit Sub end If
  158. CheckLastBall_Timer
  159. End Sub
  160.  
  161. Sub CheckLastBall_Timer
  162. If BallsonBoard >= 10 then LastBall.Enabled = True
  163. End Sub
  164.  
  165. Sub LastBall_Timer
  166. LastBall.Enabled = False
  167. EndGame
  168. End Sub
  169.  
  170. Sub EndGame
  171. ' CheckNewHighScorePostIt(Playerscore)
  172. if PlayerScore>hiscore then hiscore=PlayerScore
  173. If EndSound = 1 then PlaySound "Take Me Out to the Ballgame" end if
  174. If EndSound = 2 then PlaySound "Chime" end if
  175. GameStarted = False
  176. BallinPlay = 0
  177. SaveHS
  178. If BackglassOn = True then Controller.B2SSetScorePlayer 3, hiscore end if
  179. End Sub
  180.  
  181. '--------------------------------
  182. '------ Helper Functions ------
  183. '--------------------------------
  184. Sub SpringWall_Hit
  185. PlaySound "fx_spinner",0,.25,0,0.25
  186. WireHook.RotY = 15
  187. SpringWallMovement.enabled = True
  188. End Sub
  189.  
  190. Sub SpringWallMovement_Timer()
  191. SpringWall.timerenabled = False
  192. WireHook.RotY = 10
  193. End Sub
  194.  
  195. Sub Drain_Hit()
  196. ' PlaySound "drain3",0,0.2,0,0.25
  197. ' DOF 121, DOFPulse
  198. Drain.DestroyBall
  199. End Sub
  200.  
  201. Dim BOT2, LBall, FINISHGAME, BallCleared
  202.  
  203. Sub LaneEnd_Hit
  204. BallCleared = True
  205. End Sub
  206.  
  207. Sub EnterPF_Hit
  208. If BallCleared = True Then
  209. BallCleared = False
  210. BallsonBoard = BallsonBoard + 1
  211. If BallsonBoard = 0 then BallReleaseLocked = False end if
  212. If BallsonBoard = 1 then BallReleaseLocked = False end if
  213. If BallsonBoard = 2 then BallReleaseLocked = False end if
  214. If BallsonBoard = 3 then BallReleaseLocked = False end if
  215. If BallsonBoard = 4 then BallReleaseLocked = False end if
  216. If BallsonBoard = 5 then BallReleaseLocked = False end if
  217. If BallsonBoard = 6 then BallReleaseLocked = False end if
  218. If BallsonBoard = 7 then BallReleaseLocked = False end if
  219. If BallsonBoard = 8 then BallReleaseLocked = False end if
  220. If BallsonBoard = 9 then BallReleaseLocked = False end if
  221. If BallsonBoard = 10 then BallReleaseLocked = True end if
  222. Set LBall = ActiveBall
  223. End If
  224. End Sub
  225.  
  226. Sub CheckMarbles
  227. If UsedMarbles < 10 then exit sub end If
  228. If UsedMarbles => 10 then FINISHGAME = True end if
  229. Checkfinish
  230. end sub
  231.  
  232.  
  233. Dim BoardDir
  234. Sub MoveBoardTimer_Timer
  235.  
  236. P_Board.Transy = P_Board.Transy + BoardDir
  237. if P_Board.Transy < -40 Then
  238. KickerHoleWall.isdropped = True
  239. Else
  240. KickerHoleWall.isdropped = False
  241. End If
  242.  
  243. if P_Board.Transy < -57 Then
  244. BoardDir = -Boarddir
  245. HoldBoardTimer.enabled = True
  246. MoveBoardTimer.enabled = False
  247. end If
  248.  
  249. if P_Board.Transy >= 0 Then
  250. P_Board.Transy = 0
  251. MoveBoardTimer.enabled = False
  252. StartGame
  253. end If
  254. End Sub
  255.  
  256. Sub HoldBoardTimer_Timer
  257. HoldBoardTimer.enabled = False
  258. MoveBoardTimer.enabled = True
  259. PlaySound "BallIn",0,0.75,0,0.25,0,0,1,0
  260. end Sub
  261.  
  262. '-------------------------------
  263. '------ Keybord Handler ------
  264. '-------------------------------
  265. Sub MajorLeague_KeyDown(ByVal keycode)
  266. If keycode = StartGameKey Then
  267. if BallsonBoard>9 or BallsonBoard=0 then
  268. If LastBall.Enabled = False then
  269. BallsonBoard = 0
  270. Ballinplay = 0
  271. BoardDir = -1
  272. MoveBoardTimer.enabled = True
  273. PlaySound "CoinTray",0,0.75,0,0.25,0,0,1,0
  274. PlayerScore=0
  275. KickerReset
  276. end if
  277. end If
  278. End if
  279.  
  280. If keycode = PlungerKey Then
  281. Plunger.PullBack
  282. ' PlaySound "plungerpull",0,1,Pan(Plunger),0.25,0,0,1,0
  283. End If
  284.  
  285. If keycode = 48 Then 'B (test)
  286. PitcherKicker.CreateBall
  287. End If
  288.  
  289. If keycode = 25 then 'P (test)
  290. PitcherKicker.Kick 180,5
  291. End If
  292.  
  293. If keycode = 31 Then 'S (test)
  294. SlabKicking
  295. SlabReset.enabled = true
  296. HomePlate.Kick 45,20
  297. FirstBase.Kick -40,20
  298. SecondBase.Kick -130,20
  299. ThirdBase.Kick 135,10
  300. End If
  301.  
  302. If keycode = RightFlipperKey or keycode = RightMagnaSave and LaneClear = True then
  303. if GameStarted and BallReleaseLocked = False Then
  304. NextBall
  305. ' PlaySound "ballrelease"
  306. end If
  307. End If
  308.  
  309. If keycode = LeftTiltKey Then
  310. Nudge 90, 2
  311. ' TiltIt
  312. End If
  313.  
  314. If keycode = RightTiltKey Then
  315. Nudge 270, 2
  316. ' TiltIt
  317. End If
  318.  
  319. If keycode = CenterTiltKey OR keycode = 57 Then
  320. Nudge 0, 2
  321. ' StuckBallSweep
  322. ' TiltIt
  323. End If
  324.  
  325. End Sub
  326.  
  327. Sub MajorLeague_KeyUp(ByVal keycode)
  328. If keycode = PlungerKey Then
  329. Plunger.Fire
  330. PlaySound "PlungerHit",0,1,Pan(Plunger),0.25,0,0,1,0
  331. End If
  332.  
  333. If keycode = LeftFlipperKey Then
  334.  
  335. End If
  336.  
  337. If keycode = RightFlipperKey Then
  338.  
  339. End If
  340.  
  341. End Sub
  342.  
  343. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  344. ' Lane Check
  345. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  346. Sub ShooterLaneLaunch_Hit
  347. LaneClear = False
  348. End Sub
  349.  
  350. Sub Gate_Hit
  351. LaneClear = True
  352. PlaySound "gate4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  353. End Sub
  354.  
  355.  
  356. '~~~~~~~~~~~~~~~~~~~~
  357. ' Tilt (currently not working)
  358. '~~~~~~~~~~~~~~~~~~~~
  359. Dim TableTilted
  360. Dim TiltCount
  361. 'Dim CheckTilt
  362.  
  363. 'Sub TiltIt()
  364. ' TiltCount = TiltCount + 1
  365. ' CheckTilt
  366. 'End sub
  367.  
  368. 'Sub CheckTilt
  369. ' If TiltCount > 4 then TiltKicker.Kick
  370. 'End sub
  371.  
  372. 'Haven't figure out how to get the ball to kick out when you tilt it
  373.  
  374.  
  375. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  376. ' Baseball Actions
  377. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  378. 'Primitives
  379. Sub SlabKicking
  380. HomeKickSlab.RotY = 120
  381. FirstKickSlab.RotY = -120
  382. SecondKickSlab.RotY = -120
  383. ThirdKickSlab.RotY = 105
  384. End Sub
  385.  
  386. Sub SlabKickingMinusHome
  387. FirstKickSlab.RotY = -120
  388. SecondKickSlab.RotY = -120
  389. ThirdKickSlab.RotY = 105
  390. End Sub
  391.  
  392. Sub SlabReset_Timer()
  393. SlabReset.enabled = false
  394. HomeKickSlab.RotY = 90
  395. FirstKickSlab.RotY = 90
  396. SecondKickSlab.RotY = 90
  397. ThirdKickSlab.RotY = 90
  398. End Sub
  399.  
  400. 'Hits
  401. Sub BatterUpKicker_Hit
  402. WindUpTimer.enabled = True
  403. UsedMarbles = UsedMarbles + 1
  404. CheckMarbles
  405. End Sub
  406.  
  407. 'Should all of these require a batter up?
  408.  
  409. Sub SingleKicker_Hit
  410. DOF 105, DOFPulse
  411. OneBagTimer.enabled = True
  412. BallinPlay = BallinPlay - 1
  413. UsedMarbles = UsedMarbles + 1
  414. CheckMarbles
  415. End Sub
  416.  
  417. Sub StolenBaseKicker_Hit
  418. DOF 101, DOFPulse
  419. DoingAJobTimer.enabled = True
  420. UsedMarbles = UsedMarbles + 1
  421. CheckMarbles
  422. End Sub
  423.  
  424. Sub SacHitKicker_Hit
  425. DOF 201, DOFPulse
  426. DoingAJobTimer.enabled = True
  427. UsedMarbles = UsedMarbles + 1
  428. CheckMarbles
  429. End Sub
  430.  
  431. Sub DoubleKicker_Hit
  432. DOF 108, DOFPulse
  433. TwoBagTimer.enabled = True
  434. UsedMarbles = UsedMarbles + 1
  435. CheckMarbles
  436. End Sub
  437.  
  438. Sub TripleKicker_Hit
  439. DOF 109, DOFPulse
  440. ThreeBagTimer.enabled = True
  441. UsedMarbles = UsedMarbles + 1
  442. CheckMarbles
  443. End Sub
  444.  
  445. Sub HomeRunKicker_Hit
  446. DOF 110, DOFPulse
  447. TaterTimer.enabled = True
  448. UsedMarbles = UsedMarbles + 1
  449. CheckMarbles
  450. End Sub
  451.  
  452. 'Timers
  453. Sub WindUpTimer_Timer()
  454. WindUpTimer.enabled = False
  455. PitcherKicker.Kick 180,5
  456. PitcherKicker.CreateBall
  457. Playsound "BatterUpFX"
  458. End Sub
  459.  
  460. Sub DoingAJobTimer_Timer()
  461. DoingAJobTimer.enabled = False
  462. SlabKickingMinusHome
  463. SlabReset.enabled = true
  464. FirstBase.Kick -40,20
  465. SecondBase.Kick -130,20
  466. ThirdBase.Kick 135,10
  467. Playsound "KickersFX"
  468. End Sub
  469.  
  470. Sub OneBagTimer_Timer()
  471. OneBagTimer.enabled = False
  472. SlabKicking
  473. SlabReset.enabled = true
  474. HomePlate.Kick 45,20
  475. FirstBase.Kick -40,20
  476. SecondBase.Kick -130,20
  477. ThirdBase.Kick 135,10
  478. Playsound "KickersFX"
  479. End Sub
  480.  
  481. Sub TwoBagTimer_Timer()
  482. TwoBagTimer.enabled = False
  483. SlabKicking
  484. SlabReset.enabled = true
  485. HomePlate.Kick 45,20
  486. FirstBase.Kick -40,20
  487. SecondBase.Kick -130,20
  488. ThirdBase.Kick 135,10
  489. OneBagTimer.enabled = True
  490. Playsound "KickersFX"
  491. End Sub
  492.  
  493. Sub ThreeBagTimer_Timer()
  494. ThreeBagTimer.enabled = False
  495. SlabKicking
  496. SlabReset.enabled = true
  497. HomePlate.Kick 45,20
  498. FirstBase.Kick -40,20
  499. SecondBase.Kick -130,20
  500. ThirdBase.Kick 135,10
  501. TwoBagTimer.enabled = True
  502. Playsound "KickersFX"
  503. End Sub
  504.  
  505. Sub TaterTimer_Timer()
  506. TaterTimer.enabled = False
  507. SlabKicking
  508. SlabReset.enabled = true
  509. HomePlate.Kick 45,20
  510. FirstBase.Kick -40,20
  511. SecondBase.Kick -130,20
  512. ThirdBase.Kick 135,10
  513. ThreeBagTimer.enabled = True
  514. Playsound "KickersFX"
  515. End Sub
  516.  
  517. 'Outs
  518. Sub LeftFoul_Hit
  519. UsedMarbles = UsedMarbles + 1
  520. CheckMarbles
  521. End Sub
  522.  
  523. Sub RightFoul_Hit
  524. UsedMarbles = UsedMarbles + 1
  525. CheckMarbles
  526. End Sub
  527.  
  528. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  529. ' Scoring / Points
  530. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  531. Dim PlayerScore
  532. Dim UsedMarbles
  533.  
  534. Sub Kick100A_Hit
  535. DOF 106, DOFPulse
  536. Addpoints(100)
  537. UsedMarbles = UsedMarbles + 1
  538. CheckMarbles
  539. End Sub
  540.  
  541. Sub Kick100B_Hit
  542. DOF 106, DOFPulse
  543. Addpoints(100)
  544. UsedMarbles = UsedMarbles + 1
  545. CheckMarbles
  546. End Sub
  547.  
  548. Sub Kick100C_Hit
  549. DOF 106, DOFPulse
  550. Addpoints(100)
  551. UsedMarbles = UsedMarbles + 1
  552. CheckMarbles
  553. End Sub
  554.  
  555. Sub Kick100D_Hit
  556. DOF 106, DOFPulse
  557. Addpoints(100)
  558. UsedMarbles = UsedMarbles + 1
  559. CheckMarbles
  560. End Sub
  561.  
  562. Sub Kick200A_Hit
  563. DOF 107, DOFPulse
  564. Addpoints(200)
  565. UsedMarbles = UsedMarbles + 1
  566. CheckMarbles
  567. End Sub
  568.  
  569. Sub Kick200B_Hit
  570. DOF 107, DOFPulse
  571. Addpoints(200)
  572. UsedMarbles = UsedMarbles + 1
  573. CheckMarbles
  574. End Sub
  575.  
  576. Sub Kick200C_Hit
  577. DOF 107, DOFPulse
  578. Addpoints(200)
  579. UsedMarbles = UsedMarbles + 1
  580. CheckMarbles
  581. End Sub
  582.  
  583. Sub Kick200D_Hit
  584. DOF 107, DOFPulse
  585. Addpoints(200)
  586. UsedMarbles = UsedMarbles + 1
  587. CheckMarbles
  588. End Sub
  589.  
  590. Dim RBI
  591.  
  592. Sub RBITrigger_Hit
  593. Addpoints(3000)
  594. RBI = RBI + 1
  595. If BackglassOn = True then Controller.B2SSetScorePlayer 2, RBI end if
  596. End Sub
  597.  
  598. 'On Base
  599. Sub FirstBase_Hit
  600. DOF 102, DOFPulse
  601. Addpoints(200)
  602. End Sub
  603.  
  604. Sub FirstBase_unHit
  605. Addpoints(-200)
  606. End Sub
  607.  
  608. Sub SecondBase_Hit
  609. DOF 102, DOFPulse
  610. Addpoints(500)
  611. End Sub
  612.  
  613. Sub SecondBase_unHit
  614. Addpoints(-500)
  615. End Sub
  616.  
  617. Sub ThirdBase_Hit
  618. DOF 103, DOFPulse
  619. Addpoints(1000)
  620. End Sub
  621.  
  622. Sub ThirdBase_unHit
  623. Addpoints(-1000)
  624. End Sub
  625.  
  626. 'At end of game, points for balls on base: 1st base = 200, 2nd base = 500, 3rd base = 1,000
  627. 'It actually tallies this during the game (adds and subtracts as needed on the fly)
  628. 'I couldn't figure out how to add it at the end, so this works
  629.  
  630. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  631. ' Kicker Reseting
  632. '~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  633.  
  634. Sub KickerReset
  635.  
  636. Kick100A.DestroyBall
  637. Kick100B.DestroyBall
  638. Kick100C.DestroyBall
  639. Kick100D.DestroyBall
  640.  
  641. Kick200A.DestroyBall
  642. Kick200B.DestroyBall
  643. Kick200C.DestroyBall
  644. Kick200D.DestroyBall
  645.  
  646. HomePlate.DestroyBall
  647. FirstBase.DestroyBall
  648. SecondBase.DestroyBall
  649. ThirdBase.DestroyBall
  650. OnDeckCircle.DestroyBall
  651.  
  652. PitcherKicker.DestroyBall
  653. PitcherKicker.CreateBall
  654.  
  655. End Sub
  656.  
  657. '*********************************************************************
  658. ' Positional Sound Playback Functions
  659. '*********************************************************************
  660.  
  661. ' Play a sound, depending on the X,Y position of the table element (especially cool for surround speaker setups, otherwise stereo panning only)
  662. ' parameters (defaults): loopcount (1), volume (1), randompitch (0), pitch (0), useexisting (0), restart (1))
  663. ' Note that this will not work (currently) for walls/slingshots as these do not feature a simple, single X,Y position
  664. Sub PlayXYSound(soundname, tableobj, loopcount, volume, randompitch, pitch, useexisting, restart)
  665. PlaySound soundname, loopcount, volume, AudioPan(tableobj), randompitch, pitch, useexisting, restart, AudioFade(tableobj)
  666. End Sub
  667.  
  668. ' Similar subroutines that are less complicated to use (e.g. simply use standard parameters for the PlaySound call)
  669. Sub PlaySoundAt(soundname, tableobj)
  670. PlaySound soundname, 1, 1, AudioPan(tableobj), 0,0,0, 1, AudioFade(tableobj)
  671. End Sub
  672.  
  673. Sub PlaySoundAtBall(soundname)
  674. PlaySoundAt soundname, ActiveBall
  675. End Sub
  676.  
  677.  
  678. '*********************************************************************
  679. ' Supporting Ball & Sound Functions
  680. '*********************************************************************
  681.  
  682. Function Vol(ball) ' Calculates the Volume of the sound based on the ball speed
  683. Vol = Csng(BallVel(ball) ^2 / 300) * VolumeMultiplier
  684. End Function
  685.  
  686. Function Pan(ball) ' Calculates the pan for a ball based on the X position on the table. "table1" is the name of the table
  687. Dim tmp
  688. tmp = ball.x * 2 / MajorLeague.width-1
  689. If tmp > 0 Then
  690. Pan = Csng(tmp ^10)
  691. Else
  692. Pan = Csng(-((- tmp) ^10) )
  693. End If
  694. End Function
  695.  
  696. Function Pitch(ball) ' Calculates the pitch of the sound based on the ball speed
  697. Pitch = BallVel(ball) * 20
  698. End Function
  699.  
  700. Function BallVel(ball) 'Calculates the ball speed
  701. Set LBall = ball
  702. BallVel = INT(SQR((ball.VelX ^2) + (ball.VelY ^2) ) )
  703.  
  704. if BallVel > 0 then
  705. GameEndTimer.enabled = False
  706. end If
  707. End Function
  708.  
  709. 'Function BallVel(LBall)
  710. 'BallVel = INT(SQR((lball.VelX ^2) + (LBall.VelY ^2) ) )
  711. 'End Function
  712.  
  713. '*****************************************
  714. ' JP's VP10 Rolling Sounds
  715. '*****************************************
  716.  
  717. Const tnob = 11 ' total number of balls
  718. ReDim rolling(tnob)
  719. InitRolling
  720.  
  721. Sub InitRolling
  722. Dim i
  723. For i = 0 to tnob
  724. rolling(i) = False
  725. Next
  726. End Sub
  727.  
  728. Sub RollingTimer_Timer()
  729. Dim BOT, b
  730. BOT = GetBalls
  731.  
  732. ' stop the sound of deleted balls
  733. For b = UBound(BOT) + 1 to tnob
  734. rolling(b) = False
  735. StopSound("fx_ballrolling" & b)
  736. Next
  737.  
  738. ' exit the sub if no balls on the table
  739. If UBound(BOT) = -1 Then Exit Sub
  740.  
  741. ' play the rolling sound for each ball
  742. For b = 0 to UBound(BOT)
  743. If BallVel(BOT(b) ) > 1 AND BOT(b).z > 30 Then
  744. rolling(b) = True
  745. PlaySound("fx_ballrolling" & b), -1, Vol(BOT(b) ), Pan(BOT(b) ), 0, Pitch(BOT(b) ), 1, 0
  746. Else
  747. If rolling(b) = True Then
  748. StopSound("fx_ballrolling" & b)
  749. rolling(b) = False
  750. End If
  751. End If
  752. Next
  753. End Sub
  754.  
  755. '**********************
  756. ' Ball Collision Sound
  757. '**********************
  758.  
  759. Sub OnBallBallCollision(ball1, ball2, velocity)
  760. PlaySound("fx_collide"), 0, Csng(velocity) ^2 / 2000, Pan(ball1), 0, Pitch(ball1), 0, 0
  761. End Sub
  762.  
  763. '******************************************
  764. ' Explanation of the rolling sound routine
  765. '******************************************
  766.  
  767. ' sounds are played based on the ball speed and position
  768.  
  769. ' the routine checks first for deleted balls and stops the rolling sound.
  770.  
  771. ' The For loop goes through all the balls on the table and checks for the ball speed and
  772. ' if the ball is on the table (height lower than 30) then then it plays the sound
  773. ' otherwise the sound is stopped, like when the ball has stopped or is on a ramp or flying.
  774.  
  775. ' The sound is played using the VOL, AUDIOPAN, AUDIOFADE and PITCH functions, so the volume and pitch of the sound
  776. ' will change according to the ball speed, and the AUDIOPAN & AUDIOFADE functions will change the stereo position
  777. ' according to the position of the ball on the table.
  778.  
  779.  
  780. '**************************************
  781. ' Explanation of the collision routine
  782. '**************************************
  783.  
  784. ' The collision is built in VP.
  785. ' You only need to add a Sub OnBallBallCollision(ball1, ball2, velocity) and when two balls collide they
  786. ' 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
  787. ' depending of the speed of the collision.
  788.  
  789. Sub Pegs_Hit(idx)
  790. Select Case Int(Rnd*2)+1
  791. Case 1 : PlaySound "metalhit_medium", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  792. Case 2 : PlaySound "metalhit_thin", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  793. ' Case 3 : PlaySound "Peg4", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  794. End Select
  795. End Sub
  796.  
  797. Sub Guides_Hit(idx)
  798. Select Case Int(Rnd*3)+1
  799. Case 1 : PlaySound "flip_hit_1", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  800. Case 2 : PlaySound "flip_hit_2", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  801. Case 3 : PlaySound "flip_hit_3", 0, Vol(ActiveBall), Pan(ActiveBall), 0, Pitch(ActiveBall), 1, 0
  802. End Select
  803. End Sub
  804.  
  805. '---------------------------
  806. '----- High Score Code -----
  807. '---------------------------
  808. Dim hiscore
  809.  
  810. sub SaveHS
  811. savevalue "PAMCOMajorLeague", "hiscore", hiscore
  812. end sub
  813.  
  814. sub LoadHS
  815. dim temp
  816. temp = LoadValue("PAMCOMajorLeague", "hiscore")
  817. If (temp <> "") then hiscore = CDbl(temp)
  818. end sub
  819.  
  820. sub backglasstimer_timer
  821. backglasstimer.enabled = false
  822. If BackglassOn = True then Controller.B2SSetScorePlayer 3, hiscore end if
  823. ' me.enabled=0
  824. end sub
  825.  
  826. Sub Addpoints(ScorePar)
  827. if GameStarted Then
  828. Playerscore = Playerscore + ScorePar
  829. end If
  830.  
  831. If BackglassOn = true then Controller.B2SSetScorePlayer 1, Playerscore end if
  832. End Sub
  833.  
  834. '***
  835.  
  836. Sub MajorLeague_Exit
  837. SaveHS
  838. If B2SOn Then Controller.Stop
  839. End Sub
Add Comment
Please, Sign In to add comment